@umijs/bundler-webpack 4.0.0-rc.1 → 4.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/client/client.js +49 -35
- package/client/constants.js +3 -0
- package/compiled/autoprefixer/browserslist/index.d.ts +6 -0
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/node.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
- package/compiled/babel-loader/index.js +2 -2
- package/compiled/copy-webpack-plugin/939.index.js +1171 -0
- package/compiled/copy-webpack-plugin/index.js +16 -10
- package/compiled/copy-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
- package/compiled/css-minimizer-webpack-plugin/minify.js +25 -11
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +225 -28
- package/compiled/cssnano/index.js +12 -11
- package/compiled/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +14 -15
- package/compiled/http-proxy-middleware/dist/types.d.ts +5 -5
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +1 -1
- package/compiled/http-proxy-middleware/index.js +10 -10
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -8
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +13 -1
- package/compiled/mini-css-extract-plugin/index.js +4523 -4036
- package/compiled/mini-css-extract-plugin/loader.js +179 -54
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +79 -23
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/terser/index.js +1 -1
- package/compiled/terser-webpack-plugin/index.js +296 -297
- package/compiled/terser-webpack-plugin/minify.js +4 -2
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +180 -146
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +1 -3
- package/compiled/terser-webpack-plugin/utils.js +9 -12
- package/compiled/webpack/index.js +9855 -4185
- package/compiled/webpack-dev-middleware/index.js +7 -7
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/webpack-manifest-plugin/index.js +1 -1
- package/compiled/webpack-sources/index.js +1 -1
- package/compiled/ws/index.d.ts +1 -2
- package/compiled/ws/index.js +1 -1
- package/dist/build.d.ts +2 -1
- package/dist/build.js +1 -1
- package/dist/client/client.js +7 -2
- package/dist/config/compressPlugin.js +6 -0
- package/dist/config/config.js +4 -3
- package/dist/config/cssRules.js +1 -1
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +120 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +75 -0
- package/dist/config/javaScriptRules.js +7 -12
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +4 -1
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +13 -5
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -1
- package/dist/loader/swc.js +14 -18
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +1 -3
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
- package/dist/plugins/ParcelCSSMinifyPlugin.js +75 -0
- package/dist/plugins/ProgressPlugin.js +2 -2
- package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
- package/dist/requireHook.js +1 -1
- package/dist/schema.js +10 -6
- package/dist/server/server.d.ts +1 -2
- package/dist/server/server.js +27 -11
- package/dist/server/ws.d.ts +3 -2
- package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +14 -17
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +10 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
- package/dist/swcPlugins/lockCoreJS.js +3 -2
- package/dist/types.d.ts +16 -12
- package/dist/types.js +1 -0
- package/dist/utils/depMatch.js +1 -1
- package/dist/utils/server.d.ts +5 -0
- package/dist/utils/server.js +93 -0
- package/package.json +38 -41
- package/compiled/css-loader/LICENSE +0 -20
- package/compiled/css-loader/api.js +0 -102
- package/compiled/css-loader/getUrl.js +0 -29
- package/compiled/css-loader/index.js +0 -2
- package/compiled/css-loader/noSourceMaps.js +0 -5
- package/compiled/css-loader/package.json +0 -1
- package/compiled/css-loader/sourceMaps.js +0 -22
- package/compiled/express/LICENSE +0 -24
- package/compiled/express/body-parser/index.d.ts +0 -104
- package/compiled/express/connect/index.d.ts +0 -93
- package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
- package/compiled/express/index.d.ts +0 -133
- package/compiled/express/index.js +0 -338
- package/compiled/express/mime/index.d.ts +0 -35
- package/compiled/express/package.json +0 -1
- package/compiled/express/qs/index.d.ts +0 -62
- package/compiled/express/range-parser/index.d.ts +0 -35
- package/compiled/express/serve-static/index.d.ts +0 -108
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- package/dist/esbuildHandler/autoCssModules.d.ts +0 -2
- package/dist/esbuildHandler/autoCssModules.js +0 -23
- package/dist/loader/esbuild.d.ts +0 -5
- package/dist/loader/esbuild.js +0 -53
|
@@ -1,31 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
exports.pitch = pitch;
|
|
3
|
+
const path = require("path");
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
const {
|
|
6
|
+
findModuleById,
|
|
7
|
+
evalModuleCode,
|
|
8
|
+
AUTO_PUBLIC_PATH,
|
|
9
|
+
ABSOLUTE_PUBLIC_PATH,
|
|
10
|
+
BASE_URI,
|
|
11
|
+
SINGLE_DOT_PATH_SEGMENT,
|
|
12
|
+
stringifyRequest
|
|
13
|
+
} = require("./utils");
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
const schema = require("./loader-options.json");
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
const MiniCssExtractPlugin = require("./index");
|
|
18
|
+
/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
/** @typedef {import("webpack").Compiler} Compiler */
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
/** @typedef {import("webpack").Compilation} Compilation */
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
/** @typedef {import("webpack").Chunk} Chunk */
|
|
25
|
+
|
|
26
|
+
/** @typedef {import("webpack").Module} Module */
|
|
27
|
+
|
|
28
|
+
/** @typedef {import("webpack").sources.Source} Source */
|
|
29
|
+
|
|
30
|
+
/** @typedef {import("webpack").AssetInfo} AssetInfo */
|
|
31
|
+
|
|
32
|
+
/** @typedef {import("webpack").NormalModule} NormalModule */
|
|
33
|
+
|
|
34
|
+
/** @typedef {import("./index.js").LoaderOptions} LoaderOptions */
|
|
35
|
+
|
|
36
|
+
/** @typedef {any} TODO */
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {Object} Dependency
|
|
40
|
+
* @property {string} identifier
|
|
41
|
+
* @property {string | null} context
|
|
42
|
+
* @property {Buffer} content
|
|
43
|
+
* @property {string} media
|
|
44
|
+
* @property {string} [supports]
|
|
45
|
+
* @property {string} [layer]
|
|
46
|
+
* @property {Buffer} [sourceMap]
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} content
|
|
51
|
+
* @param {{ loaderContext: import("webpack").LoaderContext<LoaderOptions>, options: LoaderOptions, locals: {[key: string]: string } | undefined }} context
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
20
54
|
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
55
|
|
|
23
56
|
function hotLoader(content, context) {
|
|
24
57
|
const accept = context.locals ? "" : "module.hot.accept(undefined, cssReload);";
|
|
25
58
|
return `${content}
|
|
26
59
|
if(module.hot) {
|
|
27
60
|
// ${Date.now()}
|
|
28
|
-
var cssReload = require(${
|
|
61
|
+
var cssReload = require(${stringifyRequest(context.loaderContext, path.join(__dirname, "hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({ ...context.options,
|
|
29
62
|
locals: !!context.locals
|
|
30
63
|
})});
|
|
31
64
|
module.hot.dispose(cssReload);
|
|
@@ -33,11 +66,21 @@ function hotLoader(content, context) {
|
|
|
33
66
|
}
|
|
34
67
|
`;
|
|
35
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* @this {import("webpack").LoaderContext<LoaderOptions>}
|
|
71
|
+
* @param {string} request
|
|
72
|
+
*/
|
|
73
|
+
|
|
36
74
|
|
|
37
75
|
function pitch(request) {
|
|
38
|
-
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
const options = this.getOptions(
|
|
78
|
+
/** @type {Schema} */
|
|
79
|
+
schema);
|
|
39
80
|
const callback = this.async();
|
|
40
|
-
const optionsFromPlugin =
|
|
81
|
+
const optionsFromPlugin =
|
|
82
|
+
/** @type {TODO} */
|
|
83
|
+
this[MiniCssExtractPlugin.pluginSymbol];
|
|
41
84
|
|
|
42
85
|
if (!optionsFromPlugin) {
|
|
43
86
|
callback(new Error("You forgot to add 'mini-css-extract-plugin' plugin (i.e. `{ plugins: [new MiniCssExtractPlugin()] }`), please read https://github.com/webpack-contrib/mini-css-extract-plugin#getting-started"));
|
|
@@ -46,12 +89,25 @@ function pitch(request) {
|
|
|
46
89
|
|
|
47
90
|
const {
|
|
48
91
|
webpack
|
|
49
|
-
} =
|
|
92
|
+
} =
|
|
93
|
+
/** @type {Compiler} */
|
|
94
|
+
this._compiler;
|
|
95
|
+
/**
|
|
96
|
+
* @param {TODO} originalExports
|
|
97
|
+
* @param {Compilation} [compilation]
|
|
98
|
+
* @param {{ [name: string]: Source }} [assets]
|
|
99
|
+
* @param {Map<string, AssetInfo>} [assetsInfo]
|
|
100
|
+
* @returns {void}
|
|
101
|
+
*/
|
|
50
102
|
|
|
51
103
|
const handleExports = (originalExports, compilation, assets, assetsInfo) => {
|
|
104
|
+
/** @type {{[key: string]: string } | undefined} */
|
|
52
105
|
let locals;
|
|
53
106
|
let namedExport;
|
|
54
107
|
const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
|
|
108
|
+
/**
|
|
109
|
+
* @param {Dependency[] | [null, object][]} dependencies
|
|
110
|
+
*/
|
|
55
111
|
|
|
56
112
|
const addDependencies = dependencies => {
|
|
57
113
|
if (!Array.isArray(dependencies) && dependencies != null) {
|
|
@@ -63,18 +119,28 @@ function pitch(request) {
|
|
|
63
119
|
let lastDep;
|
|
64
120
|
|
|
65
121
|
for (const dependency of dependencies) {
|
|
66
|
-
if (!
|
|
122
|
+
if (!
|
|
123
|
+
/** @type {Dependency} */
|
|
124
|
+
dependency.identifier || !emit) {
|
|
67
125
|
// eslint-disable-next-line no-continue
|
|
68
126
|
continue;
|
|
69
127
|
}
|
|
70
128
|
|
|
71
|
-
const count = identifierCountMap.get(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
129
|
+
const count = identifierCountMap.get(
|
|
130
|
+
/** @type {Dependency} */
|
|
131
|
+
dependency.identifier) || 0;
|
|
132
|
+
const CssDependency = MiniCssExtractPlugin.getCssDependency(webpack);
|
|
133
|
+
/** @type {NormalModule} */
|
|
134
|
+
|
|
135
|
+
this._module.addDependency(lastDep = new CssDependency(
|
|
136
|
+
/** @type {Dependency} */
|
|
137
|
+
dependency,
|
|
138
|
+
/** @type {Dependency} */
|
|
139
|
+
dependency.context, count));
|
|
140
|
+
|
|
141
|
+
identifierCountMap.set(
|
|
142
|
+
/** @type {Dependency} */
|
|
143
|
+
dependency.identifier, count + 1);
|
|
78
144
|
}
|
|
79
145
|
|
|
80
146
|
if (lastDep && assets) {
|
|
@@ -102,6 +168,8 @@ function pitch(request) {
|
|
|
102
168
|
} else {
|
|
103
169
|
locals = exports && exports.locals;
|
|
104
170
|
}
|
|
171
|
+
/** @type {Dependency[] | [null, object][]} */
|
|
172
|
+
|
|
105
173
|
|
|
106
174
|
let dependencies;
|
|
107
175
|
|
|
@@ -113,7 +181,9 @@ function pitch(request) {
|
|
|
113
181
|
let context;
|
|
114
182
|
|
|
115
183
|
if (compilation) {
|
|
116
|
-
const module =
|
|
184
|
+
const module =
|
|
185
|
+
/** @type {Module} */
|
|
186
|
+
findModuleById(compilation, id);
|
|
117
187
|
identifier = module.identifier();
|
|
118
188
|
({
|
|
119
189
|
context
|
|
@@ -138,22 +208,29 @@ function pitch(request) {
|
|
|
138
208
|
|
|
139
209
|
addDependencies(dependencies);
|
|
140
210
|
} catch (e) {
|
|
141
|
-
|
|
211
|
+
callback(
|
|
212
|
+
/** @type {Error} */
|
|
213
|
+
e);
|
|
214
|
+
return;
|
|
142
215
|
}
|
|
143
216
|
|
|
144
|
-
const result = locals ? namedExport ? Object.keys(locals).map(key => `\nexport var ${key} = ${JSON.stringify(
|
|
145
|
-
|
|
217
|
+
const result = locals ? namedExport ? Object.keys(locals).map(key => `\nexport var ${key} = ${JSON.stringify(
|
|
218
|
+
/** @type {{[key: string]: string }} */
|
|
219
|
+
locals[key])};`).join("") : `\n${esModule ? "export default" : "module.exports ="} ${JSON.stringify(locals)};` : esModule ? `\nexport {};` : "";
|
|
220
|
+
let resultSource = `// extracted by ${MiniCssExtractPlugin.pluginName}`;
|
|
146
221
|
resultSource += this.hot ? hotLoader(result, {
|
|
147
|
-
|
|
222
|
+
loaderContext: this,
|
|
148
223
|
options,
|
|
149
224
|
locals
|
|
150
225
|
}) : result;
|
|
151
|
-
|
|
226
|
+
callback(null, resultSource);
|
|
152
227
|
};
|
|
153
228
|
|
|
154
229
|
let {
|
|
155
230
|
publicPath
|
|
156
|
-
} =
|
|
231
|
+
} =
|
|
232
|
+
/** @type {Compilation} */
|
|
233
|
+
this._compilation.outputOptions;
|
|
157
234
|
|
|
158
235
|
if (typeof options.publicPath === "string") {
|
|
159
236
|
// eslint-disable-next-line prefer-destructuring
|
|
@@ -163,7 +240,7 @@ function pitch(request) {
|
|
|
163
240
|
}
|
|
164
241
|
|
|
165
242
|
if (publicPath === "auto") {
|
|
166
|
-
publicPath =
|
|
243
|
+
publicPath = AUTO_PUBLIC_PATH;
|
|
167
244
|
}
|
|
168
245
|
|
|
169
246
|
if (typeof optionsFromPlugin.experimentalUseImportModule === "undefined" && typeof this.importModule === "function" || optionsFromPlugin.experimentalUseImportModule) {
|
|
@@ -172,12 +249,27 @@ function pitch(request) {
|
|
|
172
249
|
return;
|
|
173
250
|
}
|
|
174
251
|
|
|
175
|
-
|
|
176
|
-
|
|
252
|
+
let publicPathForExtract;
|
|
253
|
+
|
|
254
|
+
if (typeof publicPath === "string") {
|
|
255
|
+
const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
|
|
256
|
+
publicPathForExtract = isAbsolutePublicPath ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}`;
|
|
257
|
+
} else {
|
|
258
|
+
publicPathForExtract = publicPath;
|
|
259
|
+
}
|
|
260
|
+
|
|
177
261
|
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
178
262
|
layer: options.layer,
|
|
179
|
-
publicPath:
|
|
180
|
-
|
|
263
|
+
publicPath:
|
|
264
|
+
/** @type {string} */
|
|
265
|
+
publicPathForExtract,
|
|
266
|
+
baseUri: `${BASE_URI}/`
|
|
267
|
+
},
|
|
268
|
+
/**
|
|
269
|
+
* @param {Error | null | undefined} error
|
|
270
|
+
* @param {object} exports
|
|
271
|
+
*/
|
|
272
|
+
(error, exports) => {
|
|
181
273
|
if (error) {
|
|
182
274
|
callback(error);
|
|
183
275
|
return;
|
|
@@ -196,7 +288,9 @@ function pitch(request) {
|
|
|
196
288
|
publicPath
|
|
197
289
|
};
|
|
198
290
|
|
|
199
|
-
const childCompiler =
|
|
291
|
+
const childCompiler =
|
|
292
|
+
/** @type {Compilation} */
|
|
293
|
+
this._compilation.createChildCompiler(`${MiniCssExtractPlugin.pluginName} ${request}`, outputOptions); // The templates are compiled and executed by NodeJS - similar to server side rendering
|
|
200
294
|
// Unfortunately this causes issues as some loaders require an absolute URL to support ES Modules
|
|
201
295
|
// The following config enables relative URL support for the child compiler
|
|
202
296
|
|
|
@@ -242,13 +336,18 @@ function pitch(request) {
|
|
|
242
336
|
const {
|
|
243
337
|
NormalModule
|
|
244
338
|
} = webpack;
|
|
245
|
-
childCompiler.hooks.thisCompilation.tap(`${
|
|
339
|
+
childCompiler.hooks.thisCompilation.tap(`${MiniCssExtractPlugin.pluginName} loader`,
|
|
340
|
+
/**
|
|
341
|
+
* @param {Compilation} compilation
|
|
342
|
+
*/
|
|
343
|
+
compilation => {
|
|
246
344
|
const normalModuleHook = NormalModule.getCompilationHooks(compilation).loader;
|
|
247
|
-
normalModuleHook.tap(`${
|
|
345
|
+
normalModuleHook.tap(`${MiniCssExtractPlugin.pluginName} loader`, (loaderContext, module) => {
|
|
248
346
|
if (module.request === request) {
|
|
249
347
|
// eslint-disable-next-line no-param-reassign
|
|
250
348
|
module.loaders = loaders.map(loader => {
|
|
251
349
|
return {
|
|
350
|
+
type: null,
|
|
252
351
|
loader: loader.path,
|
|
253
352
|
options: loader.options,
|
|
254
353
|
ident: loader.ident
|
|
@@ -257,9 +356,15 @@ function pitch(request) {
|
|
|
257
356
|
}
|
|
258
357
|
});
|
|
259
358
|
});
|
|
359
|
+
/** @type {string | Buffer} */
|
|
360
|
+
|
|
260
361
|
let source;
|
|
261
|
-
childCompiler.hooks.compilation.tap(
|
|
262
|
-
|
|
362
|
+
childCompiler.hooks.compilation.tap(MiniCssExtractPlugin.pluginName,
|
|
363
|
+
/**
|
|
364
|
+
* @param {Compilation} compilation
|
|
365
|
+
*/
|
|
366
|
+
compilation => {
|
|
367
|
+
compilation.hooks.processAssets.tap(MiniCssExtractPlugin.pluginName, () => {
|
|
263
368
|
source = compilation.assets[childFilename] && compilation.assets[childFilename].source(); // Remove all chunk assets
|
|
264
369
|
|
|
265
370
|
compilation.chunks.forEach(chunk => {
|
|
@@ -271,45 +376,65 @@ function pitch(request) {
|
|
|
271
376
|
});
|
|
272
377
|
childCompiler.runAsChild((error, entries, compilation) => {
|
|
273
378
|
if (error) {
|
|
274
|
-
|
|
379
|
+
callback(error);
|
|
380
|
+
return;
|
|
275
381
|
}
|
|
276
382
|
|
|
277
|
-
if (
|
|
278
|
-
|
|
383
|
+
if (
|
|
384
|
+
/** @type {Compilation} */
|
|
385
|
+
compilation.errors.length > 0) {
|
|
386
|
+
callback(
|
|
387
|
+
/** @type {Compilation} */
|
|
388
|
+
compilation.errors[0]);
|
|
389
|
+
return;
|
|
279
390
|
}
|
|
391
|
+
/** @type {{ [name: string]: Source }} */
|
|
392
|
+
|
|
280
393
|
|
|
281
394
|
const assets = Object.create(null);
|
|
395
|
+
/** @type {Map<string, AssetInfo>} */
|
|
396
|
+
|
|
282
397
|
const assetsInfo = new Map();
|
|
283
398
|
|
|
284
|
-
for (const asset of
|
|
399
|
+
for (const asset of
|
|
400
|
+
/** @type {Compilation} */
|
|
401
|
+
compilation.getAssets()) {
|
|
285
402
|
assets[asset.name] = asset.source;
|
|
286
403
|
assetsInfo.set(asset.name, asset.info);
|
|
287
404
|
}
|
|
405
|
+
/** @type {Compilation} */
|
|
406
|
+
|
|
288
407
|
|
|
289
408
|
compilation.fileDependencies.forEach(dep => {
|
|
290
409
|
this.addDependency(dep);
|
|
291
410
|
}, this);
|
|
411
|
+
/** @type {Compilation} */
|
|
412
|
+
|
|
292
413
|
compilation.contextDependencies.forEach(dep => {
|
|
293
414
|
this.addContextDependency(dep);
|
|
294
415
|
}, this);
|
|
295
416
|
|
|
296
417
|
if (!source) {
|
|
297
|
-
|
|
418
|
+
callback(new Error("Didn't get a result from child compiler"));
|
|
419
|
+
return;
|
|
298
420
|
}
|
|
299
421
|
|
|
300
422
|
let originalExports;
|
|
301
423
|
|
|
302
424
|
try {
|
|
303
|
-
originalExports =
|
|
425
|
+
originalExports = evalModuleCode(this, source, request);
|
|
304
426
|
} catch (e) {
|
|
305
|
-
|
|
427
|
+
callback(
|
|
428
|
+
/** @type {Error} */
|
|
429
|
+
e);
|
|
430
|
+
return;
|
|
306
431
|
}
|
|
307
432
|
|
|
308
|
-
|
|
433
|
+
handleExports(originalExports, compilation, assets, assetsInfo);
|
|
309
434
|
});
|
|
310
|
-
}
|
|
311
|
-
|
|
435
|
+
}
|
|
312
436
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
437
|
+
module.exports = {
|
|
438
|
+
default: function loader() {},
|
|
439
|
+
pitch
|
|
440
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mini-css-extract-plugin","author":"Tobias Koppers @sokra","license":"MIT"}
|
|
1
|
+
{"name":"mini-css-extract-plugin","author":"Tobias Koppers @sokra","license":"MIT","types":"types/index.d.ts"}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.SINGLE_DOT_PATH_SEGMENT = exports.MODULE_TYPE = exports.AUTO_PUBLIC_PATH = exports.ABSOLUTE_PUBLIC_PATH = void 0;
|
|
7
|
-
exports.compareModulesByIdentifier = compareModulesByIdentifier;
|
|
8
|
-
exports.evalModuleCode = evalModuleCode;
|
|
9
|
-
exports.findModuleById = findModuleById;
|
|
10
|
-
exports.getUndoPath = getUndoPath;
|
|
11
|
-
exports.stringifyRequest = stringifyRequest;
|
|
12
|
-
exports.trueFn = trueFn;
|
|
3
|
+
const NativeModule = require("module");
|
|
13
4
|
|
|
14
|
-
|
|
5
|
+
const path = require("path");
|
|
6
|
+
/** @typedef {import("webpack").Compilation} Compilation */
|
|
15
7
|
|
|
16
|
-
|
|
8
|
+
/** @typedef {import("webpack").Module} Module */
|
|
9
|
+
|
|
10
|
+
/** @typedef {import("webpack").LoaderContext<any>} LoaderContext */
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @returns {boolean}
|
|
14
|
+
*/
|
|
17
15
|
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
16
|
|
|
20
17
|
function trueFn() {
|
|
21
18
|
return true;
|
|
22
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* @param {Compilation} compilation
|
|
22
|
+
* @param {string | number} id
|
|
23
|
+
* @returns {null | Module}
|
|
24
|
+
*/
|
|
25
|
+
|
|
23
26
|
|
|
24
27
|
function findModuleById(compilation, id) {
|
|
25
28
|
const {
|
|
@@ -37,18 +40,33 @@ function findModuleById(compilation, id) {
|
|
|
37
40
|
|
|
38
41
|
return null;
|
|
39
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @param {LoaderContext} loaderContext
|
|
45
|
+
* @param {string | Buffer} code
|
|
46
|
+
* @param {string} filename
|
|
47
|
+
* @returns {object}
|
|
48
|
+
*/
|
|
49
|
+
|
|
40
50
|
|
|
41
51
|
function evalModuleCode(loaderContext, code, filename) {
|
|
42
|
-
|
|
43
|
-
module
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
const module = new NativeModule(filename, loaderContext); // @ts-ignore
|
|
54
|
+
|
|
55
|
+
module.paths = NativeModule._nodeModulePaths(loaderContext.context); // eslint-disable-line no-underscore-dangle
|
|
44
56
|
|
|
45
|
-
module.filename = filename;
|
|
57
|
+
module.filename = filename; // @ts-ignore
|
|
46
58
|
|
|
47
59
|
module._compile(code, filename); // eslint-disable-line no-underscore-dangle
|
|
48
60
|
|
|
49
61
|
|
|
50
62
|
return module.exports;
|
|
51
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} a
|
|
66
|
+
* @param {string} b
|
|
67
|
+
* @returns {0 | 1 | -1}
|
|
68
|
+
*/
|
|
69
|
+
|
|
52
70
|
|
|
53
71
|
function compareIds(a, b) {
|
|
54
72
|
if (typeof a !== typeof b) {
|
|
@@ -65,30 +83,47 @@ function compareIds(a, b) {
|
|
|
65
83
|
|
|
66
84
|
return 0;
|
|
67
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* @param {Module} a
|
|
88
|
+
* @param {Module} b
|
|
89
|
+
* @returns {0 | 1 | -1}
|
|
90
|
+
*/
|
|
91
|
+
|
|
68
92
|
|
|
69
93
|
function compareModulesByIdentifier(a, b) {
|
|
70
94
|
return compareIds(a.identifier(), b.identifier());
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
const MODULE_TYPE = "css/mini-extract";
|
|
74
|
-
exports.MODULE_TYPE = MODULE_TYPE;
|
|
75
98
|
const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
76
|
-
exports.AUTO_PUBLIC_PATH = AUTO_PUBLIC_PATH;
|
|
77
99
|
const ABSOLUTE_PUBLIC_PATH = "webpack:///mini-css-extract-plugin/";
|
|
78
|
-
|
|
100
|
+
const BASE_URI = "webpack://";
|
|
79
101
|
const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
|
|
80
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} str
|
|
104
|
+
* @returns {boolean}
|
|
105
|
+
*/
|
|
81
106
|
|
|
82
107
|
function isAbsolutePath(str) {
|
|
83
|
-
return
|
|
108
|
+
return path.posix.isAbsolute(str) || path.win32.isAbsolute(str);
|
|
84
109
|
}
|
|
85
110
|
|
|
86
111
|
const RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/;
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} str
|
|
114
|
+
* @returns {boolean}
|
|
115
|
+
*/
|
|
87
116
|
|
|
88
117
|
function isRelativePath(str) {
|
|
89
118
|
return RELATIVE_PATH_REGEXP.test(str);
|
|
90
119
|
} // TODO simplify for the next major release
|
|
91
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @param {LoaderContext} loaderContext
|
|
123
|
+
* @param {string} request
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
|
|
92
127
|
|
|
93
128
|
function stringifyRequest(loaderContext, request) {
|
|
94
129
|
if (typeof loaderContext.utils !== "undefined" && typeof loaderContext.utils.contextify === "function") {
|
|
@@ -106,7 +141,7 @@ function stringifyRequest(loaderContext, request) {
|
|
|
106
141
|
let singlePath = splittedPart ? splittedPart[1] : part;
|
|
107
142
|
|
|
108
143
|
if (isAbsolutePath(singlePath) && context) {
|
|
109
|
-
singlePath =
|
|
144
|
+
singlePath = path.relative(context, singlePath);
|
|
110
145
|
|
|
111
146
|
if (isAbsolutePath(singlePath)) {
|
|
112
147
|
// If singlePath still matches an absolute path, singlePath was on a different drive than context.
|
|
@@ -124,6 +159,13 @@ function stringifyRequest(loaderContext, request) {
|
|
|
124
159
|
return singlePath.replace(/\\/g, "/") + query;
|
|
125
160
|
}).join("!"));
|
|
126
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* @param {string} filename
|
|
164
|
+
* @param {string} outputPath
|
|
165
|
+
* @param {boolean} enforceRelative
|
|
166
|
+
* @returns {string}
|
|
167
|
+
*/
|
|
168
|
+
|
|
127
169
|
|
|
128
170
|
function getUndoPath(filename, outputPath, enforceRelative) {
|
|
129
171
|
let depth = -1;
|
|
@@ -156,4 +198,18 @@ function getUndoPath(filename, outputPath, enforceRelative) {
|
|
|
156
198
|
}
|
|
157
199
|
|
|
158
200
|
return depth > 0 ? `${"../".repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
|
|
159
|
-
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
module.exports = {
|
|
204
|
+
trueFn,
|
|
205
|
+
findModuleById,
|
|
206
|
+
evalModuleCode,
|
|
207
|
+
compareModulesByIdentifier,
|
|
208
|
+
MODULE_TYPE,
|
|
209
|
+
AUTO_PUBLIC_PATH,
|
|
210
|
+
ABSOLUTE_PUBLIC_PATH,
|
|
211
|
+
BASE_URI,
|
|
212
|
+
SINGLE_DOT_PATH_SEGMENT,
|
|
213
|
+
stringifyRequest,
|
|
214
|
+
getUndoPath
|
|
215
|
+
};
|