Skip to content

Commit

Permalink
fix: add semicolon to avoid Uncaught TypeError on Webpack v5 (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhchand committed Aug 10, 2020
1 parent b146549 commit 3974210
Show file tree
Hide file tree
Showing 24 changed files with 586 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class MiniCssExtractPlugin {
Template.indent(
chunk.ids.map((id) => `${JSON.stringify(id)}: 0`).join(',\n')
),
'}',
'};',
]);
}

Expand Down
1 change: 1 addition & 0 deletions test/cases/dependOn-multiple-files-per-entry/entryA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './styleA.css';
1 change: 1 addition & 0 deletions test/cases/dependOn-multiple-files-per-entry/entryB.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './styleB.css';
1 change: 1 addition & 0 deletions test/cases/dependOn-multiple-files-per-entry/entryC.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './styleC.css';
1 change: 1 addition & 0 deletions test/cases/dependOn-multiple-files-per-entry/entryD.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './styleD.css';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.styleC {
background: red;
}

.styleD {
background: blue;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _styleC_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
/* harmony import */ var _styleC_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleC_css__WEBPACK_IMPORTED_MODULE_0__);



/***/ }),
/* 1 */
/***/ (() => {

// extracted by mini-css-extract-plugin

/***/ }),
/* 2 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _styleD_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
/* harmony import */ var _styleD_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleD_css__WEBPACK_IMPORTED_MODULE_0__);



/***/ }),
/* 3 */
/***/ (() => {

// extracted by mini-css-extract-plugin

/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = __webpack_modules__;
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => module['default'] :
/******/ () => module;
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/compat */
/******/
/******/
/******/ // object to store loaded CSS chunks
/******/ var installedCssChunks = {
/******/ 0: 0
/******/ };/* webpack/runtime/jsonp chunk loading */
/******/ (() => {
/******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ // Promise = chunk loading, 0 = chunk loaded
/******/ var installedChunks = {
/******/ 0: 0
/******/ };
/******/
/******/ var deferredModules = [
/******/ [0],
/******/ [2]
/******/ ];
/******/ // no chunk on demand loading
/******/
/******/ // no prefetching
/******/
/******/ // no preloaded
/******/
/******/ // no HMR
/******/
/******/ // no HMR manifest
/******/
/******/ var checkDeferredModules = () => {
/******/
/******/ };
/******/ function checkDeferredModulesImpl() {
/******/ var result;
/******/ for(var i = 0; i < deferredModules.length; i++) {
/******/ var deferredModule = deferredModules[i];
/******/ var fulfilled = true;
/******/ for(var j = 1; j < deferredModule.length; j++) {
/******/ var depId = deferredModule[j];
/******/ if(installedChunks[depId] !== 0) fulfilled = false;
/******/ }
/******/ if(fulfilled) {
/******/ deferredModules.splice(i--, 1);
/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
/******/ }
/******/ }
/******/ if(deferredModules.length === 0) {
/******/ __webpack_require__.x();
/******/ __webpack_require__.x = () => {
/******/
/******/ }
/******/ }
/******/ return result;
/******/ }
/******/ __webpack_require__.x = () => {
/******/ // reset startup function so it can be called again when more startup code is added
/******/ __webpack_require__.x = () => {
/******/
/******/ }
/******/ jsonpArray = jsonpArray.slice();
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
/******/ return (checkDeferredModules = checkDeferredModulesImpl)();
/******/ };
/******/
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/ var executeModules = data[2];
/******/ var runtime = data[3];
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ }
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
/******/ if(runtime) runtime(__webpack_require__);
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ // add entry modules from loaded chunk to deferred list
/******/ if(executeModules) deferredModules.push.apply(deferredModules, executeModules);
/******/
/******/ // run deferred modules when all chunks ready
/******/ return checkDeferredModules();
/******/ };
/******/
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
/******/ jsonpArray.push = webpackJsonpCallback;
/******/ var parentJsonpFunction = oldJsonpFunction;
/******/ })();
/******/
/************************************************************************/
/******/ // run startup
/******/ return __webpack_require__.x();
/******/ })()
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.styleB {
background: blue;
}

.styleA {
background: red;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[
/* 0 */,
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _styleB_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
/* harmony import */ var _styleB_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleB_css__WEBPACK_IMPORTED_MODULE_0__);



/***/ }),
/* 5 */
/***/ (() => {

// extracted by mini-css-extract-plugin

/***/ }),
/* 6 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _styleA_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
/* harmony import */ var _styleA_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_styleA_css__WEBPACK_IMPORTED_MODULE_0__);



/***/ }),
/* 7 */
/***/ (() => {

// extracted by mini-css-extract-plugin

/***/ })
],[[6,0],[4,0]]]);
3 changes: 3 additions & 0 deletions test/cases/dependOn-multiple-files-per-entry/styleA.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.styleA {
background: red;
}
3 changes: 3 additions & 0 deletions test/cases/dependOn-multiple-files-per-entry/styleB.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.styleB {
background: blue;
}
3 changes: 3 additions & 0 deletions test/cases/dependOn-multiple-files-per-entry/styleC.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.styleC {
background: red;
}
3 changes: 3 additions & 0 deletions test/cases/dependOn-multiple-files-per-entry/styleD.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.styleD {
background: blue;
}
21 changes: 21 additions & 0 deletions test/cases/dependOn-multiple-files-per-entry/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Self from '../../../src';

module.exports = {
entry: {
entry1: { import: ['./entryA.js', './entryB.js'], dependOn: 'common' },
common: ['./entryC.js', './entryD.js'],
},
module: {
rules: [
{
test: /\.css$/,
use: [Self.loader, 'css-loader'],
},
],
},
plugins: [
new Self({
filename: '[name].css',
}),
],
};
1 change: 1 addition & 0 deletions test/cases/dependOn/entryA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './styleA.css';
1 change: 1 addition & 0 deletions test/cases/dependOn/entryB.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './styleB.css';
4 changes: 4 additions & 0 deletions test/cases/dependOn/expected/webpack-5/common.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.styleB {
background: blue;
}

Loading

0 comments on commit 3974210

Please sign in to comment.