Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
39b36e9
feat: ability to disable extract async modules
lsycxyj Jul 20, 2019
188cf5c
feat: ability to disable extract async modules, lint fix
lsycxyj Jul 20, 2019
4a7a1f6
feat: ability to disable extract async modules, add doc
lsycxyj Jul 20, 2019
399aa9a
feat: ability to disable extract async modules, ci fix
lsycxyj Jul 20, 2019
26646ae
feat: ability to disable extract async modules, order fix
lsycxyj Jul 20, 2019
08b8e52
feat: ability to disable extract async modules, wrong initial chunks fix
lsycxyj Jul 21, 2019
775cc0c
feat: ability to disable extract async modules, add manual test
lsycxyj Jul 21, 2019
f9d7df1
feat: ability to disable extract async modules, update lock file
lsycxyj Jul 21, 2019
c38cc8c
feat: ability to disable extract async modules, add tests for js files
lsycxyj Jul 21, 2019
e2177fd
feat: ability to disable extract modules, wip
lsycxyj Jul 22, 2019
4982afb
feat: ability to disable extract modules, remove duplicated dependencies
lsycxyj Jul 24, 2019
81517cc
feat: ability to disable extract modules, update doc
lsycxyj Jul 24, 2019
5b3fbef
feat: ability to disable extract modules, remove boolean type option
lsycxyj Jul 24, 2019
1da949e
feat: ability to disable extract modules, less code difference
lsycxyj Jul 24, 2019
e59a0e1
feat: ability to disable extract modules, less code difference
lsycxyj Jul 24, 2019
37ce619
Merge remote-tracking branch 'origin/feature/disable_async_20190719' …
lsycxyj Jul 24, 2019
6001569
feat: ability to disable extract modules, less regressions
lsycxyj Jul 26, 2019
b986c54
feat: ability to disable extract modules, ci fix
lsycxyj Jul 26, 2019
fa58310
feat: ability to disable extract modules, ci fix
lsycxyj Jul 26, 2019
5de6572
feat: ability to disable extract modules, replace private property
lsycxyj Jul 27, 2019
5b2c6d3
feat: ability to disable extract modules, remove useless code
lsycxyj Jul 31, 2019
2f29038
merge from master WIP
lsycxyj Feb 3, 2020
f0358d0
fix wrong modules after disable extraction
lsycxyj Feb 4, 2020
cbcfbc5
Merge remote-tracking branch 'upstream/master' into feature/disable_a…
lsycxyj Aug 6, 2020
40af212
fix wrong modification and update package-lock.json
lsycxyj Aug 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix wrong modules after disable extraction
  • Loading branch information
lsycxyj committed Feb 4, 2020
commit f0358d07b7cd36127c17c638b117a7caa0c047bb
11 changes: 10 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class MiniCssExtractPlugin {

apply(compiler) {
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
const moduleToBeRebuild = new Set();
let moduleToBeRebuild = new Set();
// eslint-disable-next-line no-param-reassign
compilation[MODULE_TYPE] = {
moduleToBeRebuild,
Expand Down Expand Up @@ -456,6 +456,15 @@ class MiniCssExtractPlugin {
Promise.all(promises).then(() => callback());
}
);

// Trigger seal again if there are modules to be rebuilt
compilation.hooks.needAdditionalSeal.tap(pluginName, () => {
if (moduleToBeRebuild.size > 0) {
moduleToBeRebuild = new Set();
return true;
}
return false;
});
});
}

Expand Down
116 changes: 116 additions & 0 deletions test/cases/disable-extract-func/expected/1.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,121 @@ module.exports = exports;

// extracted by mini-css-extract-plugin

/***/ }),
/* 11 */,
/* 12 */,
/* 13 */,
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
// eslint-disable-next-line func-names
module.exports = function (useSourceMap) {
var list = []; // return the list of modules as css string

list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item, useSourceMap);

if (item[2]) {
return "@media ".concat(item[2], " {").concat(content, "}");
}

return content;
}).join('');
}; // import a list of modules into the list
// eslint-disable-next-line func-names


list.i = function (modules, mediaQuery, dedupe) {
if (typeof modules === 'string') {
// eslint-disable-next-line no-param-reassign
modules = [[null, modules, '']];
}

var alreadyImportedModules = {};

if (dedupe) {
for (var i = 0; i < this.length; i++) {
// eslint-disable-next-line prefer-destructuring
var id = this[i][0];

if (id != null) {
alreadyImportedModules[id] = true;
}
}
}

for (var _i = 0; _i < modules.length; _i++) {
var item = [].concat(modules[_i]);

if (dedupe && alreadyImportedModules[item[0]]) {
// eslint-disable-next-line no-continue
continue;
}

if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery;
} else {
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
}
}

list.push(item);
}
};

return list;
};

function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring

var cssMapping = item[3];

if (!cssMapping) {
return content;
}

if (useSourceMap && typeof btoa === 'function') {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function (source) {
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
});
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
}

return [content].join('\n');
} // Adapted from convert-source-map (MIT)


function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
return "/*# ".concat(data, " */");
}

/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

// Imports
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(14);
exports = ___CSS_LOADER_API_IMPORT___(false);
// Module
exports.push([module.i, ".async-import {\n background: black;\n}\n", ""]);
// Exports
module.exports = exports;


/***/ })
]]);
100 changes: 100 additions & 0 deletions test/cases/disable-extract-func/expected/3.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,105 @@ exports.push([module.i, ".is-async-1 {\n background: magenta;\n}\n", ""]);
module.exports = exports;


/***/ }),
/* 14 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
// eslint-disable-next-line func-names
module.exports = function (useSourceMap) {
var list = []; // return the list of modules as css string

list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item, useSourceMap);

if (item[2]) {
return "@media ".concat(item[2], " {").concat(content, "}");
}

return content;
}).join('');
}; // import a list of modules into the list
// eslint-disable-next-line func-names


list.i = function (modules, mediaQuery, dedupe) {
if (typeof modules === 'string') {
// eslint-disable-next-line no-param-reassign
modules = [[null, modules, '']];
}

var alreadyImportedModules = {};

if (dedupe) {
for (var i = 0; i < this.length; i++) {
// eslint-disable-next-line prefer-destructuring
var id = this[i][0];

if (id != null) {
alreadyImportedModules[id] = true;
}
}
}

for (var _i = 0; _i < modules.length; _i++) {
var item = [].concat(modules[_i]);

if (dedupe && alreadyImportedModules[item[0]]) {
// eslint-disable-next-line no-continue
continue;
}

if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery;
} else {
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
}
}

list.push(item);
}
};

return list;
};

function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring

var cssMapping = item[3];

if (!cssMapping) {
return content;
}

if (useSourceMap && typeof btoa === 'function') {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function (source) {
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
});
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
}

return [content].join('\n');
} // Adapted from convert-source-map (MIT)


function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
return "/*# ".concat(data, " */");
}

/***/ })
]]);