Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bloated runtime #687

Merged
merged 2 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,15 @@ class MiniCssExtractPlugin {
MODULE_TYPE,
'mini-css',
`${webpack.RuntimeGlobals.require}.miniCssF`,
(referencedChunk) =>
referencedChunk.canBeInitial()
(referencedChunk) => {
if (!referencedChunk.contentHash[MODULE_TYPE]) {
return false;
}

return referencedChunk.canBeInitial()
? this.options.filename
: this.options.chunkFilename,
: this.options.chunkFilename;
},
true
)
);
Expand Down
2 changes: 1 addition & 1 deletion test/cases/hmr/expected/webpack-5/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ module.exports = function (urlString) {
/******/ // This function allow to reference all chunks
/******/ __webpack_require__.miniCssF = (chunkId) => {
/******/ // return url for filenames based on template
/******/ return "" + "main" + ".css";
/******/ return undefined;
/******/ };
/******/ })();
/******/
Expand Down
1 change: 1 addition & 0 deletions test/cases/hmr/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Self from '../../../src';

module.exports = {
entry: './index.css',
mode: 'development',
module: {
rules: [
{
Expand Down
4 changes: 1 addition & 3 deletions test/cases/insert-function/expected/webpack-5/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
/******/ (() => {
/******/ // This function allow to reference all chunks
/******/ __webpack_require__.miniCssF = (chunkId) => {
/******/ // return url for filenames not based on template
/******/ if (chunkId === 1) return "1.css";
/******/ // return url for filenames based on template
/******/ return "" + "main" + ".css";
/******/ return "" + chunkId + ".css";
/******/ };
/******/ })();
/******/
Expand Down
4 changes: 1 addition & 3 deletions test/cases/insert-string/expected/webpack-5/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
/******/ (() => {
/******/ // This function allow to reference all chunks
/******/ __webpack_require__.miniCssF = (chunkId) => {
/******/ // return url for filenames not based on template
/******/ if (chunkId === 1) return "1.css";
/******/ // return url for filenames based on template
/******/ return "" + "main" + ".css";
/******/ return "" + chunkId + ".css";
/******/ };
/******/ })();
/******/
Expand Down
4 changes: 1 addition & 3 deletions test/cases/insert-undefined/expected/webpack-5/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
/******/ (() => {
/******/ // This function allow to reference all chunks
/******/ __webpack_require__.miniCssF = (chunkId) => {
/******/ // return url for filenames not based on template
/******/ if (chunkId === 1) return "1.css";
/******/ // return url for filenames based on template
/******/ return "" + "main" + ".css";
/******/ return "" + chunkId + ".css";
/******/ };
/******/ })();
/******/
Expand Down
2 changes: 1 addition & 1 deletion test/cases/runtime/expected/webpack-5/runtime~main.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
/******/ // This function allow to reference all chunks
/******/ __webpack_require__.miniCssF = (chunkId) => {
/******/ // return url for filenames based on template
/******/ return "" + ({"0":"main","1":"runtime~main"}[chunkId] || chunkId) + "." + {"0":"a7263f8f763dcf4051bc"}[chunkId] + ".css";
/******/ return "" + "main" + "." + "a7263f8f763dcf4051bc" + ".css";
/******/ };
/******/ })();
/******/
Expand Down