Skip to content

Commit 3974210

Browse files
authored
fix: add semicolon to avoid Uncaught TypeError on Webpack v5 (#561)
1 parent b146549 commit 3974210

File tree

24 files changed

+586
-1
lines changed

24 files changed

+586
-1
lines changed

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class MiniCssExtractPlugin {
251251
Template.indent(
252252
chunk.ids.map((id) => `${JSON.stringify(id)}: 0`).join(',\n')
253253
),
254-
'}',
254+
'};',
255255
]);
256256
}
257257

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './styleA.css';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './styleB.css';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './styleC.css';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './styleD.css';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.styleC {
2+
background: red;
3+
}
4+
5+
.styleD {
6+
background: blue;
7+
}
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
/******/ (() => { // webpackBootstrap
2+
/******/ var __webpack_modules__ = ([
3+
/* 0 */
4+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5+
6+
"use strict";
7+
__webpack_require__.r(__webpack_exports__);
8+
/* harmony import */ var _styleC_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
9+
/* harmony import */ var _styleC_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleC_css__WEBPACK_IMPORTED_MODULE_0__);
10+
11+
12+
13+
/***/ }),
14+
/* 1 */
15+
/***/ (() => {
16+
17+
// extracted by mini-css-extract-plugin
18+
19+
/***/ }),
20+
/* 2 */
21+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
22+
23+
"use strict";
24+
__webpack_require__.r(__webpack_exports__);
25+
/* harmony import */ var _styleD_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
26+
/* harmony import */ var _styleD_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleD_css__WEBPACK_IMPORTED_MODULE_0__);
27+
28+
29+
30+
/***/ }),
31+
/* 3 */
32+
/***/ (() => {
33+
34+
// extracted by mini-css-extract-plugin
35+
36+
/***/ })
37+
/******/ ]);
38+
/************************************************************************/
39+
/******/ // The module cache
40+
/******/ var __webpack_module_cache__ = {};
41+
/******/
42+
/******/ // The require function
43+
/******/ function __webpack_require__(moduleId) {
44+
/******/ // Check if module is in cache
45+
/******/ if(__webpack_module_cache__[moduleId]) {
46+
/******/ return __webpack_module_cache__[moduleId].exports;
47+
/******/ }
48+
/******/ // Create a new module (and put it into the cache)
49+
/******/ var module = __webpack_module_cache__[moduleId] = {
50+
/******/ // no module.id needed
51+
/******/ // no module.loaded needed
52+
/******/ exports: {}
53+
/******/ };
54+
/******/
55+
/******/ // Execute the module function
56+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
57+
/******/
58+
/******/ // Return the exports of the module
59+
/******/ return module.exports;
60+
/******/ }
61+
/******/
62+
/******/ // expose the modules object (__webpack_modules__)
63+
/******/ __webpack_require__.m = __webpack_modules__;
64+
/******/
65+
/************************************************************************/
66+
/******/ /* webpack/runtime/compat get default export */
67+
/******/ (() => {
68+
/******/ // getDefaultExport function for compatibility with non-harmony modules
69+
/******/ __webpack_require__.n = (module) => {
70+
/******/ var getter = module && module.__esModule ?
71+
/******/ () => module['default'] :
72+
/******/ () => module;
73+
/******/ __webpack_require__.d(getter, { a: getter });
74+
/******/ return getter;
75+
/******/ };
76+
/******/ })();
77+
/******/
78+
/******/ /* webpack/runtime/define property getters */
79+
/******/ (() => {
80+
/******/ // define getter functions for harmony exports
81+
/******/ __webpack_require__.d = (exports, definition) => {
82+
/******/ for(var key in definition) {
83+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
84+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
85+
/******/ }
86+
/******/ }
87+
/******/ };
88+
/******/ })();
89+
/******/
90+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
91+
/******/ (() => {
92+
/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
93+
/******/ })();
94+
/******/
95+
/******/ /* webpack/runtime/make namespace object */
96+
/******/ (() => {
97+
/******/ // define __esModule on exports
98+
/******/ __webpack_require__.r = (exports) => {
99+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
100+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
101+
/******/ }
102+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
103+
/******/ };
104+
/******/ })();
105+
/******/
106+
/******/ /* webpack/runtime/compat */
107+
/******/
108+
/******/
109+
/******/ // object to store loaded CSS chunks
110+
/******/ var installedCssChunks = {
111+
/******/ 0: 0
112+
/******/ };/* webpack/runtime/jsonp chunk loading */
113+
/******/ (() => {
114+
/******/ // object to store loaded and loading chunks
115+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
116+
/******/ // Promise = chunk loading, 0 = chunk loaded
117+
/******/ var installedChunks = {
118+
/******/ 0: 0
119+
/******/ };
120+
/******/
121+
/******/ var deferredModules = [
122+
/******/ [0],
123+
/******/ [2]
124+
/******/ ];
125+
/******/ // no chunk on demand loading
126+
/******/
127+
/******/ // no prefetching
128+
/******/
129+
/******/ // no preloaded
130+
/******/
131+
/******/ // no HMR
132+
/******/
133+
/******/ // no HMR manifest
134+
/******/
135+
/******/ var checkDeferredModules = () => {
136+
/******/
137+
/******/ };
138+
/******/ function checkDeferredModulesImpl() {
139+
/******/ var result;
140+
/******/ for(var i = 0; i < deferredModules.length; i++) {
141+
/******/ var deferredModule = deferredModules[i];
142+
/******/ var fulfilled = true;
143+
/******/ for(var j = 1; j < deferredModule.length; j++) {
144+
/******/ var depId = deferredModule[j];
145+
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
146+
/******/ }
147+
/******/ if(fulfilled) {
148+
/******/ deferredModules.splice(i--, 1);
149+
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
150+
/******/ }
151+
/******/ }
152+
/******/ if(deferredModules.length === 0) {
153+
/******/ __webpack_require__.x();
154+
/******/ __webpack_require__.x = () => {
155+
/******/
156+
/******/ }
157+
/******/ }
158+
/******/ return result;
159+
/******/ }
160+
/******/ __webpack_require__.x = () => {
161+
/******/ // reset startup function so it can be called again when more startup code is added
162+
/******/ __webpack_require__.x = () => {
163+
/******/
164+
/******/ }
165+
/******/ jsonpArray = jsonpArray.slice();
166+
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
167+
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
168+
/******/ };
169+
/******/
170+
/******/ // install a JSONP callback for chunk loading
171+
/******/ function webpackJsonpCallback(data) {
172+
/******/ var chunkIds = data[0];
173+
/******/ var moreModules = data[1];
174+
/******/ var executeModules = data[2];
175+
/******/ var runtime = data[3];
176+
/******/ // add "moreModules" to the modules object,
177+
/******/ // then flag all "chunkIds" as loaded and fire callback
178+
/******/ var moduleId, chunkId, i = 0, resolves = [];
179+
/******/ for(;i < chunkIds.length; i++) {
180+
/******/ chunkId = chunkIds[i];
181+
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
182+
/******/ resolves.push(installedChunks[chunkId][0]);
183+
/******/ }
184+
/******/ installedChunks[chunkId] = 0;
185+
/******/ }
186+
/******/ for(moduleId in moreModules) {
187+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
188+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
189+
/******/ }
190+
/******/ }
191+
/******/ if(runtime) runtime(__webpack_require__);
192+
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
193+
/******/ while(resolves.length) {
194+
/******/ resolves.shift()();
195+
/******/ }
196+
/******/
197+
/******/ // add entry modules from loaded chunk to deferred list
198+
/******/ if(executeModules) deferredModules.push.apply(deferredModules, executeModules);
199+
/******/
200+
/******/ // run deferred modules when all chunks ready
201+
/******/ return checkDeferredModules();
202+
/******/ };
203+
/******/
204+
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
205+
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
206+
/******/ jsonpArray.push = webpackJsonpCallback;
207+
/******/ var parentJsonpFunction = oldJsonpFunction;
208+
/******/ })();
209+
/******/
210+
/************************************************************************/
211+
/******/ // run startup
212+
/******/ return __webpack_require__.x();
213+
/******/ })()
214+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.styleB {
2+
background: blue;
3+
}
4+
5+
.styleA {
6+
background: red;
7+
}
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[
2+
/* 0 */,
3+
/* 1 */,
4+
/* 2 */,
5+
/* 3 */,
6+
/* 4 */
7+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8+
9+
"use strict";
10+
__webpack_require__.r(__webpack_exports__);
11+
/* harmony import */ var _styleB_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
12+
/* harmony import */ var _styleB_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleB_css__WEBPACK_IMPORTED_MODULE_0__);
13+
14+
15+
16+
/***/ }),
17+
/* 5 */
18+
/***/ (() => {
19+
20+
// extracted by mini-css-extract-plugin
21+
22+
/***/ }),
23+
/* 6 */
24+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25+
26+
"use strict";
27+
__webpack_require__.r(__webpack_exports__);
28+
/* harmony import */ var _styleA_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
29+
/* harmony import */ var _styleA_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleA_css__WEBPACK_IMPORTED_MODULE_0__);
30+
31+
32+
33+
/***/ }),
34+
/* 7 */
35+
/***/ (() => {
36+
37+
// extracted by mini-css-extract-plugin
38+
39+
/***/ })
40+
],[[6,0],[4,0]]]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.styleA {
2+
background: red;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.styleB {
2+
background: blue;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.styleC {
2+
background: red;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.styleD {
2+
background: blue;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Self from '../../../src';
2+
3+
module.exports = {
4+
entry: {
5+
entry1: { import: ['./entryA.js', './entryB.js'], dependOn: 'common' },
6+
common: ['./entryC.js', './entryD.js'],
7+
},
8+
module: {
9+
rules: [
10+
{
11+
test: /\.css$/,
12+
use: [Self.loader, 'css-loader'],
13+
},
14+
],
15+
},
16+
plugins: [
17+
new Self({
18+
filename: '[name].css',
19+
}),
20+
],
21+
};

test/cases/dependOn/entryA.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './styleA.css';

test/cases/dependOn/entryB.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './styleB.css';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.styleB {
2+
background: blue;
3+
}
4+

0 commit comments

Comments
 (0)