Skip to content

Commit 102f317

Browse files
fix: pulling additional code from webpack upstream
1 parent 5c8f225 commit 102f317

File tree

18 files changed

+85
-116
lines changed

18 files changed

+85
-116
lines changed

.eslintignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/node_modules
1+
/coverage
22
/dist
3+
/node_modules
4+
/test/fixtures
35
/test/cases/*/expected
46
/test/js
5-
/test/manual

.eslintrc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
module.exports = {
22
root: true,
33
parser: 'babel-eslint',
4-
plugins: ['prettier'],
5-
extends: ['@webpack-contrib/eslint-config-webpack'],
6-
rules: {
7-
'prettier/prettier': ['error'],
8-
},
4+
extends: ['@webpack-contrib/eslint-config-webpack', 'prettier'],
95
};

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ package-lock.json -diff
22
* text=auto
33
test/cases/* eol=lf
44
bin/* eol=lf
5+
yarn.lock -diff

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Thumbs.db
1515
*.sublime-project
1616
*.sublime-workspace
1717
.idea
18+
*.iml

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
/test/cases/*/expected
66
/test/js
77
CHANGELOG.md
8-

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ If you like our work, check out our Redux-based router <a href="https://github.c
3131
3232
So... why did we rebuild `extract-css-chunks`? What does it offer?
3333

34-
It's got all the goodness of `mini-css-extract-plugin` but with 2 gleaming, sought after benefits.
34+
It's got all the goodness of `extract-css-chunks-webpack-plugin` but with 2 gleaming, sought after benefits.
3535

3636
Compared to the existing loaders, we are offering a single solution as opposed to needing to depend on multiple loaders to cater for different features:
3737

husky.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
hooks: {
33
'pre-commit': 'lint-staged',
4+
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
45
},
56
};

src/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class CssModule extends webpack.Module {
7373
this.sourceMap = module.sourceMap;
7474
}
7575

76-
// eslint-disable-next-line class-methods-use-this
7776
needRebuild() {
7877
return true;
7978
}
@@ -94,7 +93,6 @@ class CssModule extends webpack.Module {
9493
}
9594

9695
class CssModuleFactory {
97-
// eslint-disable-next-line class-methods-use-this
9896
create({ dependencies: [dependency] }, callback) {
9997
callback(null, new CssModule(dependency));
10098
}
@@ -401,7 +399,7 @@ class ExtractCssChunksPlugin {
401399
);
402400
});
403401
}
404-
// eslint-disable-next-line class-methods-use-this
402+
405403
getCssChunkObject(mainChunk) {
406404
const obj = {};
407405

test/HMR.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* @jest-environment jsdom
33
*/
4-
54
/* eslint-env browser */
65
/* eslint-disable no-console */
76

File renamed without changes.

test/cases/insert-function/expected/1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* 1 */
44
/***/ (function(module, exports, __webpack_require__) {
55

6-
// extracted by mini-css-extract-plugin
6+
// extracted by extract-css-chunks-webpack-plugin
77

88
/***/ })
99
]]);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
/******/ var promises = [];
8282
/******/
8383
/******/
84-
/******/ // mini-css-extract-plugin CSS loading
84+
/******/ // extract-css-chunks-webpack-plugin CSS loading
8585
/******/ var cssChunks = {"1":1};
8686
/******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);
8787
/******/ else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {

test/cases/insert-string/expected/1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* 1 */
44
/***/ (function(module, exports, __webpack_require__) {
55

6-
// extracted by mini-css-extract-plugin
6+
// extracted by extract-css-chunks-webpack-plugin
77

88
/***/ })
99
]]);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
/******/ var promises = [];
8282
/******/
8383
/******/
84-
/******/ // mini-css-extract-plugin CSS loading
84+
/******/ // extract-css-chunks-webpack-plugin CSS loading
8585
/******/ var cssChunks = {"1":1};
8686
/******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);
8787
/******/ else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {

test/helpers/compile.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export default (compiler) =>
2-
new Promise((resolve, reject) => {
1+
export default (compiler) => {
2+
return new Promise((resolve, reject) => {
33
compiler.run((error, stats) => {
44
if (error) {
55
return reject(error);
@@ -8,3 +8,4 @@ export default (compiler) =>
88
return resolve(stats);
99
});
1010
});
11+
};

test/helpers/getCompiler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'path';
33
import webpack from 'webpack';
44
import { createFsFromVolume, Volume } from 'memfs';
55

6-
import ExtractCssChunks from '../../src';
6+
import MiniCssExtractPlugin from '../../src';
77

88
export default (fixture, loaderOptions = {}, config = {}) => {
99
const fullConfig = {
@@ -22,7 +22,7 @@ export default (fixture, loaderOptions = {}, config = {}) => {
2222
test: /\.css$/i,
2323
rules: [
2424
{
25-
loader: ExtractCssChunks.loader,
25+
loader: MiniCssExtractPlugin.loader,
2626
options: loaderOptions || {},
2727
},
2828
{
@@ -33,7 +33,7 @@ export default (fixture, loaderOptions = {}, config = {}) => {
3333
],
3434
},
3535
plugins: [
36-
new ExtractCssChunks({
36+
new MiniCssExtractPlugin({
3737
// Options similar to the same options in webpackOptions.output
3838
// both options are optional
3939
filename: '[name].css',

test/manual/index.html

Lines changed: 66 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,69 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta charset="utf-8" />
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6-
<title>extract-css-chunks-webpack-plugin testcase</title>
7-
<meta name="viewport" content="width=device-width, initial-scale=1" />
8-
<link rel="stylesheet" type="text/css" href="/dist/preloaded1.css" />
9-
<style>
10-
.test {
11-
background: lightcoral;
12-
}
13-
.errors {
14-
font-weight: bold;
15-
color: darkred;
16-
}
17-
.preloaded-css1 {
18-
background: lightgreen;
19-
}
20-
</style>
21-
<style data-href="preloaded2.css">
22-
.preloaded-css2 {
23-
background: lightgreen;
24-
}
25-
</style>
26-
<link rel="stylesheet" type="text/css" href="/dist/main.css" />
27-
</head>
28-
<body>
29-
<div class="test initial-css">
30-
Initial CSS: Must be green
31-
</div>
32-
<div class="hot-reload">
33-
<p>Hot Module Replacement</p>
34-
<div class="r">RED</div>
35-
<div class="g">GREEN</div>
36-
<div class="b">BLUE</div>
37-
</div>
38-
<div class="hot-reload">
39-
<p>Hot Module Replacement + CSS modules</p>
40-
<div class="rr">RED</div>
41-
<div class="gg">GREEN</div>
42-
<div class="bb">BLUE</div>
43-
</div>
44-
<div class="test lazy-css">
45-
<p>
46-
Lazy CSS: Must be red, but turn green when
47-
<button class="lazy-button">pressing this button</button>.
48-
</p>
49-
<p>
50-
But turn orange, when
51-
<button class="lazy-button2">pressing this button</button>. Additional
52-
clicks have no effect.
53-
</p>
54-
<p>
55-
Refresh and press buttons in reverse order: This should turn green
56-
instead.
57-
</p>
58-
</div>
59-
<div class="test lazy-failure-css">
60-
<p>
61-
Lazy CSS: Turn off the network and
62-
<button class="lazy-failure-button">press this button</button>.
63-
</p>
64-
<p>An error should have appeared.</p>
65-
<p>
66-
Now if you turn the network back on and click it again, it should turn
67-
aqua.
68-
</p>
69-
</div>
70-
<div class="test preloaded-css1">
71-
<p>Preloaded CSS: Must be green.</p>
72-
<p>
73-
<button class="preloaded-button1">Pressing this button</button> displays
74-
an alert and should turn red.
75-
</p>
76-
</div>
77-
<div class="test preloaded-css2">
78-
<p>Preloaded inlined CSS: Must be green.</p>
79-
<p>
80-
<button class="preloaded-button2">Pressing this button</button> displays
81-
an alert and should turn red.
82-
</p>
83-
</div>
84-
<div class="test crossorigin">
85-
<p>CrossOriginLoading Option: Must be red.</p>
86-
<p>
87-
<button>Pressing this button</button> loads chunks with crossorigin
88-
attribute and should turn green.
89-
</p>
90-
</div>
91-
<div class="errors"></div>
92-
<script async defer src="/dist/main.js"></script>
93-
</body>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<title>extract-css-chunks-webpack-plugin testcase</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="stylesheet" type="text/css" href="/dist/preloaded1.css" />
9+
<style>
10+
.test {
11+
background: lightcoral;
12+
}
13+
.errors {
14+
font-weight: bold;
15+
color: darkred;
16+
}
17+
.preloaded-css1 {
18+
background: lightgreen;
19+
}
20+
</style>
21+
<style data-href="preloaded2.css">
22+
.preloaded-css2 {
23+
background: lightgreen;
24+
}
25+
</style>
26+
<link rel="stylesheet" type="text/css" href="/dist/main.css" />
27+
</head>
28+
<body>
29+
<div class="test initial-css">
30+
Initial CSS: Must be green
31+
</div>
32+
<div class="hot-reload">
33+
<p>Hot Module Replacement</p>
34+
<div class="r">RED</div>
35+
<div class="g">GREEN</div>
36+
<div class="b">BLUE</div>
37+
</div>
38+
<div class="hot-reload">
39+
<p>Hot Module Replacement + CSS modules</p>
40+
<div class="rr">RED</div>
41+
<div class="gg">GREEN</div>
42+
<div class="bb">BLUE</div>
43+
</div>
44+
<div class="test lazy-css">
45+
<p>Lazy CSS: Must be red, but turn green when <button class="lazy-button">pressing this button</button>.</p>
46+
<p>But turn orange, when <button class="lazy-button2">pressing this button</button>. Additional clicks have no effect.</p>
47+
<p>Refresh and press buttons in reverse order: This should turn green instead.</p>
48+
</div>
49+
<div class="test lazy-failure-css">
50+
<p>Lazy CSS: Turn off the network and <button class="lazy-failure-button">press this button</button>.</p>
51+
<p>An error should have appeared.</p>
52+
<p>Now if you turn the network back on and click it again, it should turn aqua.</p>
53+
</div>
54+
<div class="test preloaded-css1">
55+
<p>Preloaded CSS: Must be green.</p>
56+
<p><button class="preloaded-button1">Pressing this button</button> displays an alert and should turn red.</p>
57+
</div>
58+
<div class="test preloaded-css2">
59+
<p>Preloaded inlined CSS: Must be green.</p>
60+
<p><button class="preloaded-button2">Pressing this button</button> displays an alert and should turn red.</p>
61+
</div>
62+
<div class="test crossorigin">
63+
<p>CrossOriginLoading Option: Must be red.</p>
64+
<p><button>Pressing this button</button> loads chunks with crossorigin attribute and should turn green.</p>
65+
</div>
66+
<div class="errors"></div>
67+
<script async defer src="/dist/main.js"></script>
68+
</body>
9469
</html>

test/manual/webpack.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
const Self = require('../../');
2-
const HtmlWebpackPlugin = require('html-webpack-plugin');
3-
const https = require('https');
42

53
const ENABLE_HMR =
64
typeof process.env.ENABLE_HMR !== 'undefined'
@@ -63,7 +61,6 @@ module.exports = {
6361
new Self({
6462
filename: '[name].css',
6563
chunkFilename: '[contenthash].css',
66-
insert: 'body',
6764
}),
6865
],
6966
devServer: {

0 commit comments

Comments
 (0)