@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.
Files changed (111) hide show
  1. package/client/client/client.js +49 -35
  2. package/client/constants.js +3 -0
  3. package/compiled/autoprefixer/browserslist/index.d.ts +6 -0
  4. package/compiled/autoprefixer/index.js +3 -3
  5. package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
  6. package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
  7. package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
  8. package/compiled/autoprefixer/postcss/lib/node.d.ts +2 -2
  9. package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
  10. package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
  11. package/compiled/babel-loader/index.js +2 -2
  12. package/compiled/copy-webpack-plugin/939.index.js +1171 -0
  13. package/compiled/copy-webpack-plugin/index.js +16 -10
  14. package/compiled/copy-webpack-plugin/package.json +1 -1
  15. package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
  16. package/compiled/css-minimizer-webpack-plugin/minify.js +25 -11
  17. package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
  18. package/compiled/css-minimizer-webpack-plugin/utils.js +225 -28
  19. package/compiled/cssnano/index.js +12 -11
  20. package/compiled/cssnano/package.json +1 -1
  21. package/compiled/express.d.ts +2 -0
  22. package/compiled/fork-ts-checker-webpack-plugin/index.js +14 -15
  23. package/compiled/http-proxy-middleware/dist/types.d.ts +5 -5
  24. package/compiled/http-proxy-middleware/http-proxy/index.d.ts +1 -1
  25. package/compiled/http-proxy-middleware/index.js +10 -10
  26. package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -8
  27. package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +13 -1
  28. package/compiled/mini-css-extract-plugin/index.js +4523 -4036
  29. package/compiled/mini-css-extract-plugin/loader.js +179 -54
  30. package/compiled/mini-css-extract-plugin/package.json +1 -1
  31. package/compiled/mini-css-extract-plugin/utils.js +79 -23
  32. package/compiled/sass-loader/index.js +1 -1
  33. package/compiled/terser/index.js +1 -1
  34. package/compiled/terser-webpack-plugin/index.js +296 -297
  35. package/compiled/terser-webpack-plugin/minify.js +4 -2
  36. package/compiled/terser-webpack-plugin/package.json +1 -1
  37. package/compiled/terser-webpack-plugin/types/index.d.ts +180 -146
  38. package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
  39. package/compiled/terser-webpack-plugin/types/utils.d.ts +1 -3
  40. package/compiled/terser-webpack-plugin/utils.js +9 -12
  41. package/compiled/webpack/index.js +9855 -4185
  42. package/compiled/webpack-dev-middleware/index.js +7 -7
  43. package/compiled/webpack-dev-middleware/package.json +1 -1
  44. package/compiled/webpack-manifest-plugin/index.js +1 -1
  45. package/compiled/webpack-sources/index.js +1 -1
  46. package/compiled/ws/index.d.ts +1 -2
  47. package/compiled/ws/index.js +1 -1
  48. package/dist/build.d.ts +2 -1
  49. package/dist/build.js +1 -1
  50. package/dist/client/client.js +7 -2
  51. package/dist/config/compressPlugin.js +6 -0
  52. package/dist/config/config.js +4 -3
  53. package/dist/config/cssRules.js +1 -1
  54. package/dist/config/detectDeadCode.d.ts +12 -0
  55. package/dist/config/detectDeadCode.js +120 -0
  56. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  57. package/dist/config/detectDeadCodePlugin.js +75 -0
  58. package/dist/config/javaScriptRules.js +7 -12
  59. package/dist/constants.d.ts +3 -0
  60. package/dist/constants.js +4 -1
  61. package/dist/dev.d.ts +1 -0
  62. package/dist/dev.js +13 -5
  63. package/dist/index.d.ts +4 -1
  64. package/dist/index.js +5 -1
  65. package/dist/loader/swc.js +14 -18
  66. package/dist/plugins/ESBuildCSSMinifyPlugin.js +1 -3
  67. package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +10 -0
  68. package/dist/plugins/ParcelCSSMinifyPlugin.js +75 -0
  69. package/dist/plugins/ProgressPlugin.js +2 -2
  70. package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
  71. package/dist/requireHook.js +1 -1
  72. package/dist/schema.js +10 -6
  73. package/dist/server/server.d.ts +1 -2
  74. package/dist/server/server.js +27 -11
  75. package/dist/server/ws.d.ts +3 -2
  76. package/dist/swcPlugins/autoCSSModules.d.ts +7 -2
  77. package/dist/swcPlugins/autoCSSModules.js +14 -17
  78. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  79. package/dist/swcPlugins/changeImportFromString.js +10 -0
  80. package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
  81. package/dist/swcPlugins/lockCoreJS.js +3 -2
  82. package/dist/types.d.ts +16 -12
  83. package/dist/types.js +1 -0
  84. package/dist/utils/depMatch.js +1 -1
  85. package/dist/utils/server.d.ts +5 -0
  86. package/dist/utils/server.js +93 -0
  87. package/package.json +38 -41
  88. package/compiled/css-loader/LICENSE +0 -20
  89. package/compiled/css-loader/api.js +0 -102
  90. package/compiled/css-loader/getUrl.js +0 -29
  91. package/compiled/css-loader/index.js +0 -2
  92. package/compiled/css-loader/noSourceMaps.js +0 -5
  93. package/compiled/css-loader/package.json +0 -1
  94. package/compiled/css-loader/sourceMaps.js +0 -22
  95. package/compiled/express/LICENSE +0 -24
  96. package/compiled/express/body-parser/index.d.ts +0 -104
  97. package/compiled/express/connect/index.d.ts +0 -93
  98. package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
  99. package/compiled/express/index.d.ts +0 -133
  100. package/compiled/express/index.js +0 -338
  101. package/compiled/express/mime/index.d.ts +0 -35
  102. package/compiled/express/package.json +0 -1
  103. package/compiled/express/qs/index.d.ts +0 -62
  104. package/compiled/express/range-parser/index.d.ts +0 -35
  105. package/compiled/express/serve-static/index.d.ts +0 -108
  106. package/compiled/less/index.js +0 -31
  107. package/compiled/less/package.json +0 -1
  108. package/dist/esbuildHandler/autoCssModules.d.ts +0 -2
  109. package/dist/esbuildHandler/autoCssModules.js +0 -23
  110. package/dist/loader/esbuild.d.ts +0 -5
  111. package/dist/loader/esbuild.js +0 -53
@@ -1,31 +1,64 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = _default;
7
- exports.pitch = pitch;
3
+ const path = require("path");
8
4
 
9
- var _path = _interopRequireDefault(require("path"));
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
- var _utils = require("./utils");
15
+ const schema = require("./loader-options.json");
12
16
 
13
- var _loaderOptions = _interopRequireDefault(require("./loader-options.json"));
17
+ const MiniCssExtractPlugin = require("./index");
18
+ /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
14
19
 
15
- var _index = _interopRequireWildcard(require("./index"));
20
+ /** @typedef {import("webpack").Compiler} Compiler */
16
21
 
17
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
22
+ /** @typedef {import("webpack").Compilation} Compilation */
18
23
 
19
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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(${(0, _utils.stringifyRequest)(context.context, _path.default.join(__dirname, "hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({ ...context.options,
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
- const options = this.getOptions(_loaderOptions.default);
76
+ // @ts-ignore
77
+ const options = this.getOptions(
78
+ /** @type {Schema} */
79
+ schema);
39
80
  const callback = this.async();
40
- const optionsFromPlugin = this[_index.pluginSymbol];
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
- } = this._compiler;
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 (!dependency.identifier || !emit) {
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(dependency.identifier) || 0;
72
-
73
- const CssDependency = _index.default.getCssDependency(webpack);
74
-
75
- this._module.addDependency(lastDep = new CssDependency(dependency, dependency.context, count));
76
-
77
- identifierCountMap.set(dependency.identifier, count + 1);
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 = (0, _utils.findModuleById)(compilation, id);
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
- return callback(e);
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(locals[key])};`).join("") : `\n${esModule ? "export default" : "module.exports ="} ${JSON.stringify(locals)};` : esModule ? `\nexport {};` : "";
145
- let resultSource = `// extracted by ${_index.pluginName}`;
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
- context: this.context,
222
+ loaderContext: this,
148
223
  options,
149
224
  locals
150
225
  }) : result;
151
- return callback(null, resultSource);
226
+ callback(null, resultSource);
152
227
  };
153
228
 
154
229
  let {
155
230
  publicPath
156
- } = this._compilation.outputOptions;
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 = _utils.AUTO_PUBLIC_PATH;
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
- const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
176
- const publicPathForExtract = isAbsolutePublicPath ? publicPath : `${_utils.ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, _utils.SINGLE_DOT_PATH_SEGMENT)}`;
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: publicPathForExtract
180
- }, (error, exports) => {
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 = this._compilation.createChildCompiler(`${_index.pluginName} ${request}`, outputOptions); // The templates are compiled and executed by NodeJS - similar to server side rendering
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(`${_index.pluginName} loader`, compilation => {
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(`${_index.pluginName} loader`, (loaderContext, module) => {
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(_index.pluginName, compilation => {
262
- compilation.hooks.processAssets.tap(_index.pluginName, () => {
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
- return callback(error);
379
+ callback(error);
380
+ return;
275
381
  }
276
382
 
277
- if (compilation.errors.length > 0) {
278
- return callback(compilation.errors[0]);
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 compilation.getAssets()) {
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
- return callback(new Error("Didn't get a result from child compiler"));
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 = (0, _utils.evalModuleCode)(this, source, request);
425
+ originalExports = evalModuleCode(this, source, request);
304
426
  } catch (e) {
305
- return callback(e);
427
+ callback(
428
+ /** @type {Error} */
429
+ e);
430
+ return;
306
431
  }
307
432
 
308
- return handleExports(originalExports, compilation, assets, assetsInfo);
433
+ handleExports(originalExports, compilation, assets, assetsInfo);
309
434
  });
310
- } // eslint-disable-next-line func-names
311
-
435
+ }
312
436
 
313
- function _default(content) {
314
- console.log(content);
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
- Object.defineProperty(exports, "__esModule", {
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
- var _module = _interopRequireDefault(require("module"));
5
+ const path = require("path");
6
+ /** @typedef {import("webpack").Compilation} Compilation */
15
7
 
16
- var _path = _interopRequireDefault(require("path"));
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
- const module = new _module.default(filename, loaderContext);
43
- module.paths = _module.default._nodeModulePaths(loaderContext.context); // eslint-disable-line no-underscore-dangle
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
- exports.ABSOLUTE_PUBLIC_PATH = ABSOLUTE_PUBLIC_PATH;
100
+ const BASE_URI = "webpack://";
79
101
  const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
80
- exports.SINGLE_DOT_PATH_SEGMENT = SINGLE_DOT_PATH_SEGMENT;
102
+ /**
103
+ * @param {string} str
104
+ * @returns {boolean}
105
+ */
81
106
 
82
107
  function isAbsolutePath(str) {
83
- return _path.default.posix.isAbsolute(str) || _path.default.win32.isAbsolute(str);
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 = _path.default.relative(context, 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
+ };