Skip to content

Commit 117a97a

Browse files
fix: identifier for CssModule (#677)
1 parent 359c00f commit 117a97a

File tree

22 files changed

+1090
-1570
lines changed

22 files changed

+1090
-1570
lines changed

package-lock.json

+971-1,441
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,35 @@
4848
"webpack-sources": "^1.1.0"
4949
},
5050
"devDependencies": {
51-
"@babel/cli": "^7.12.1",
52-
"@babel/core": "^7.12.3",
53-
"@babel/preset-env": "^7.12.1",
51+
"@babel/cli": "^7.12.10",
52+
"@babel/core": "^7.12.10",
53+
"@babel/preset-env": "^7.12.11",
5454
"@commitlint/cli": "^11.0.0",
5555
"@commitlint/config-conventional": "^11.0.0",
5656
"@webpack-contrib/defaults": "^6.3.0",
5757
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
5858
"babel-eslint": "^10.1.0",
5959
"babel-jest": "^26.6.3",
6060
"bootstrap": "^4.5.3",
61-
"cross-env": "^7.0.2",
61+
"cross-env": "^7.0.3",
6262
"css-loader": "^5.0.1",
6363
"del": "^6.0.0",
6464
"del-cli": "^3.0.1",
65-
"es-check": "^5.1.2",
66-
"eslint": "^7.13.0",
67-
"eslint-config-prettier": "^6.15.0",
65+
"es-check": "^5.2.0",
66+
"eslint": "^7.17.0",
67+
"eslint-config-prettier": "^7.1.0",
6868
"eslint-plugin-import": "^2.22.1",
6969
"file-loader": "^6.2.0",
70-
"husky": "^4.3.0",
70+
"husky": "^4.3.7",
7171
"jest": "^26.6.3",
7272
"jsdom": "^16.4.0",
73-
"lint-staged": "^10.4.0",
73+
"lint-staged": "^10.5.3",
7474
"memfs": "^3.0.2",
7575
"npm-run-all": "^4.1.5",
76-
"prettier": "^2.1.2",
77-
"standard-version": "^9.0.0",
76+
"prettier": "^2.2.1",
77+
"standard-version": "^9.1.0",
7878
"webpack": "^5.9.0",
79-
"webpack-cli": "^4.2.0",
79+
"webpack-cli": "^4.3.1",
8080
"webpack-dev-server": "^3.7.2"
8181
},
8282
"keywords": [

src/CssModule.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CssModule extends webpack.Module {
4242
}
4343

4444
identifier() {
45-
return `css ${this._identifier} ${this._identifierIndex}`;
45+
return `css|${this._identifier}|${this._identifierIndex}`;
4646
}
4747

4848
readableIdentifier(requestShortener) {
+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
const webpack = require('webpack');
22

3-
module.exports = () => {
4-
return webpack.version[0] !== '4';
5-
};
3+
module.exports = () => webpack.version[0] !== '4';

test/cases/dependOn-multiple-files-per-entry/expected/webpack-5/common.js

+35-38
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ __webpack_require__.r(__webpack_exports__);
6363
/******/ // expose the modules object (__webpack_modules__)
6464
/******/ __webpack_require__.m = __webpack_modules__;
6565
/******/
66+
/******/ // the startup function
67+
/******/ // It's empty as some runtime module handles the default behavior
68+
/******/ __webpack_require__.x = x => {}
6669
/************************************************************************/
6770
/******/ /* webpack/runtime/hasOwnProperty shorthand */
6871
/******/ (() => {
@@ -105,43 +108,10 @@ __webpack_require__.r(__webpack_exports__);
105108
/******/
106109
/******/ // no HMR manifest
107110
/******/
108-
/******/ var checkDeferredModules = () => {
109-
/******/
110-
/******/ };
111-
/******/ function checkDeferredModulesImpl() {
112-
/******/ var result;
113-
/******/ for(var i = 0; i < deferredModules.length; i++) {
114-
/******/ var deferredModule = deferredModules[i];
115-
/******/ var fulfilled = true;
116-
/******/ for(var j = 1; j < deferredModule.length; j++) {
117-
/******/ var depId = deferredModule[j];
118-
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
119-
/******/ }
120-
/******/ if(fulfilled) {
121-
/******/ deferredModules.splice(i--, 1);
122-
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
123-
/******/ }
124-
/******/ }
125-
/******/ if(deferredModules.length === 0) {
126-
/******/ __webpack_require__.x();
127-
/******/ __webpack_require__.x = () => {
128-
/******/
129-
/******/ }
130-
/******/ }
131-
/******/ return result;
132-
/******/ }
133-
/******/ __webpack_require__.x = () => {
134-
/******/ // reset startup function so it can be called again when more startup code is added
135-
/******/ __webpack_require__.x = () => {
136-
/******/
137-
/******/ }
138-
/******/ chunkLoadingGlobal = chunkLoadingGlobal.slice();
139-
/******/ for(var i = 0; i < chunkLoadingGlobal.length; i++) webpackJsonpCallback(chunkLoadingGlobal[i]);
140-
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
141-
/******/ };
111+
/******/ var checkDeferredModules = x => {};
142112
/******/
143113
/******/ // install a JSONP callback for chunk loading
144-
/******/ var webpackJsonpCallback = (data) => {
114+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
145115
/******/ var [chunkIds, moreModules, runtime, executeModules] = data;
146116
/******/ // add "moreModules" to the modules object,
147117
/******/ // then flag all "chunkIds" as loaded and fire callback
@@ -159,7 +129,7 @@ __webpack_require__.r(__webpack_exports__);
159129
/******/ }
160130
/******/ }
161131
/******/ if(runtime) runtime(__webpack_require__);
162-
/******/ parentChunkLoadingFunction(data);
132+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
163133
/******/ while(resolves.length) {
164134
/******/ resolves.shift()();
165135
/******/ }
@@ -172,8 +142,35 @@ __webpack_require__.r(__webpack_exports__);
172142
/******/ }
173143
/******/
174144
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
175-
/******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
176-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback;
145+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
146+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
147+
/******/
148+
/******/ function checkDeferredModulesImpl() {
149+
/******/ var result;
150+
/******/ for(var i = 0; i < deferredModules.length; i++) {
151+
/******/ var deferredModule = deferredModules[i];
152+
/******/ var fulfilled = true;
153+
/******/ for(var j = 1; j < deferredModule.length; j++) {
154+
/******/ var depId = deferredModule[j];
155+
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
156+
/******/ }
157+
/******/ if(fulfilled) {
158+
/******/ deferredModules.splice(i--, 1);
159+
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
160+
/******/ }
161+
/******/ }
162+
/******/ if(deferredModules.length === 0) {
163+
/******/ __webpack_require__.x();
164+
/******/ __webpack_require__.x = x => {};
165+
/******/ }
166+
/******/ return result;
167+
/******/ }
168+
/******/ var startup = __webpack_require__.x;
169+
/******/ __webpack_require__.x = () => {
170+
/******/ // reset startup function so it can be called again when more startup code is added
171+
/******/ __webpack_require__.x = startup || (x => {});
172+
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
173+
/******/ };
177174
/******/ })();
178175
/******/
179176
/************************************************************************/
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
const webpack = require('webpack');
22

3-
module.exports = () => {
4-
return webpack.version[0] !== '4';
5-
};
3+
module.exports = () => webpack.version[0] !== '4';

test/cases/dependOn/expected/webpack-5/common.js

+35-38
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ __webpack_require__.r(__webpack_exports__);
4646
/******/ // expose the modules object (__webpack_modules__)
4747
/******/ __webpack_require__.m = __webpack_modules__;
4848
/******/
49+
/******/ // the startup function
50+
/******/ // It's empty as some runtime module handles the default behavior
51+
/******/ __webpack_require__.x = x => {}
4952
/************************************************************************/
5053
/******/ /* webpack/runtime/hasOwnProperty shorthand */
5154
/******/ (() => {
@@ -87,43 +90,10 @@ __webpack_require__.r(__webpack_exports__);
8790
/******/
8891
/******/ // no HMR manifest
8992
/******/
90-
/******/ var checkDeferredModules = () => {
91-
/******/
92-
/******/ };
93-
/******/ function checkDeferredModulesImpl() {
94-
/******/ var result;
95-
/******/ for(var i = 0; i < deferredModules.length; i++) {
96-
/******/ var deferredModule = deferredModules[i];
97-
/******/ var fulfilled = true;
98-
/******/ for(var j = 1; j < deferredModule.length; j++) {
99-
/******/ var depId = deferredModule[j];
100-
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
101-
/******/ }
102-
/******/ if(fulfilled) {
103-
/******/ deferredModules.splice(i--, 1);
104-
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
105-
/******/ }
106-
/******/ }
107-
/******/ if(deferredModules.length === 0) {
108-
/******/ __webpack_require__.x();
109-
/******/ __webpack_require__.x = () => {
110-
/******/
111-
/******/ }
112-
/******/ }
113-
/******/ return result;
114-
/******/ }
115-
/******/ __webpack_require__.x = () => {
116-
/******/ // reset startup function so it can be called again when more startup code is added
117-
/******/ __webpack_require__.x = () => {
118-
/******/
119-
/******/ }
120-
/******/ chunkLoadingGlobal = chunkLoadingGlobal.slice();
121-
/******/ for(var i = 0; i < chunkLoadingGlobal.length; i++) webpackJsonpCallback(chunkLoadingGlobal[i]);
122-
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
123-
/******/ };
93+
/******/ var checkDeferredModules = x => {};
12494
/******/
12595
/******/ // install a JSONP callback for chunk loading
126-
/******/ var webpackJsonpCallback = (data) => {
96+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
12797
/******/ var [chunkIds, moreModules, runtime, executeModules] = data;
12898
/******/ // add "moreModules" to the modules object,
12999
/******/ // then flag all "chunkIds" as loaded and fire callback
@@ -141,7 +111,7 @@ __webpack_require__.r(__webpack_exports__);
141111
/******/ }
142112
/******/ }
143113
/******/ if(runtime) runtime(__webpack_require__);
144-
/******/ parentChunkLoadingFunction(data);
114+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
145115
/******/ while(resolves.length) {
146116
/******/ resolves.shift()();
147117
/******/ }
@@ -154,8 +124,35 @@ __webpack_require__.r(__webpack_exports__);
154124
/******/ }
155125
/******/
156126
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
157-
/******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
158-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback;
127+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
128+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
129+
/******/
130+
/******/ function checkDeferredModulesImpl() {
131+
/******/ var result;
132+
/******/ for(var i = 0; i < deferredModules.length; i++) {
133+
/******/ var deferredModule = deferredModules[i];
134+
/******/ var fulfilled = true;
135+
/******/ for(var j = 1; j < deferredModule.length; j++) {
136+
/******/ var depId = deferredModule[j];
137+
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
138+
/******/ }
139+
/******/ if(fulfilled) {
140+
/******/ deferredModules.splice(i--, 1);
141+
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
142+
/******/ }
143+
/******/ }
144+
/******/ if(deferredModules.length === 0) {
145+
/******/ __webpack_require__.x();
146+
/******/ __webpack_require__.x = x => {};
147+
/******/ }
148+
/******/ return result;
149+
/******/ }
150+
/******/ var startup = __webpack_require__.x;
151+
/******/ __webpack_require__.x = () => {
152+
/******/ // reset startup function so it can be called again when more startup code is added
153+
/******/ __webpack_require__.x = startup || (x => {});
154+
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
155+
/******/ };
159156
/******/ })();
160157
/******/
161158
/************************************************************************/

test/cases/dependOn/test.filter.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
const webpack = require('webpack');
22

3-
module.exports = () => {
4-
return webpack.version[0] !== '4';
5-
};
3+
module.exports = () => webpack.version[0] !== '4';

test/cases/hmr/expected/webpack-5/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ module.exports = function (urlString) {
386386
/******/ var inProgress = {};
387387
/******/ // data-webpack is not used as build has no uniqueName
388388
/******/ // loadScript function to load a script via script tag
389-
/******/ __webpack_require__.l = (url, done, key) => {
389+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
390390
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
391391
/******/ var script, needAttach;
392392
/******/ if(key !== undefined) {
@@ -1389,6 +1389,8 @@ module.exports = function (urlString) {
13891389
/******/ // no deferred startup
13901390
/******/
13911391
/******/ // no jsonp function
1392+
/******/
1393+
/******/ // no deferred startup
13921394
/******/ })();
13931395
/******/
13941396
/************************************************************************/

test/cases/insert-function/expected/webpack-5/main.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
/******/ var inProgress = {};
8484
/******/ // data-webpack is not used as build has no uniqueName
8585
/******/ // loadScript function to load a script via script tag
86-
/******/ __webpack_require__.l = (url, done, key) => {
86+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
8787
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
8888
/******/ var script, needAttach;
8989
/******/ if(key !== undefined) {
@@ -280,7 +280,7 @@
280280
/******/ }
281281
/******/ }
282282
/******/ };
283-
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId);
283+
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
284284
/******/ } else installedChunks[chunkId] = 0;
285285
/******/ }
286286
/******/ }
@@ -297,7 +297,7 @@
297297
/******/ // no deferred startup
298298
/******/
299299
/******/ // install a JSONP callback for chunk loading
300-
/******/ var webpackJsonpCallback = (data) => {
300+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
301301
/******/ var [chunkIds, moreModules, runtime] = data;
302302
/******/ // add "moreModules" to the modules object,
303303
/******/ // then flag all "chunkIds" as loaded and fire callback
@@ -315,16 +315,18 @@
315315
/******/ }
316316
/******/ }
317317
/******/ if(runtime) runtime(__webpack_require__);
318-
/******/ parentChunkLoadingFunction(data);
318+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
319319
/******/ while(resolves.length) {
320320
/******/ resolves.shift()();
321321
/******/ }
322322
/******/
323323
/******/ }
324324
/******/
325325
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
326-
/******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
327-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback;
326+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
327+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
328+
/******/
329+
/******/ // no deferred startup
328330
/******/ })();
329331
/******/
330332
/************************************************************************/

test/cases/insert-string/expected/webpack-5/main.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
/******/ var inProgress = {};
8484
/******/ // data-webpack is not used as build has no uniqueName
8585
/******/ // loadScript function to load a script via script tag
86-
/******/ __webpack_require__.l = (url, done, key) => {
86+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
8787
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
8888
/******/ var script, needAttach;
8989
/******/ if(key !== undefined) {
@@ -275,7 +275,7 @@
275275
/******/ }
276276
/******/ }
277277
/******/ };
278-
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId);
278+
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
279279
/******/ } else installedChunks[chunkId] = 0;
280280
/******/ }
281281
/******/ }
@@ -292,7 +292,7 @@
292292
/******/ // no deferred startup
293293
/******/
294294
/******/ // install a JSONP callback for chunk loading
295-
/******/ var webpackJsonpCallback = (data) => {
295+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
296296
/******/ var [chunkIds, moreModules, runtime] = data;
297297
/******/ // add "moreModules" to the modules object,
298298
/******/ // then flag all "chunkIds" as loaded and fire callback
@@ -310,16 +310,18 @@
310310
/******/ }
311311
/******/ }
312312
/******/ if(runtime) runtime(__webpack_require__);
313-
/******/ parentChunkLoadingFunction(data);
313+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
314314
/******/ while(resolves.length) {
315315
/******/ resolves.shift()();
316316
/******/ }
317317
/******/
318318
/******/ }
319319
/******/
320320
/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
321-
/******/ var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);
322-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback;
321+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
322+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
323+
/******/
324+
/******/ // no deferred startup
323325
/******/ })();
324326
/******/
325327
/************************************************************************/

0 commit comments

Comments
 (0)