@umijs/bundler-webpack 4.0.0-beta.8 → 4.0.0-canary-20240513.3

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 (297) hide show
  1. package/client/client/client.js +255 -167
  2. package/client/constants.d.ts +15 -0
  3. package/client/constants.js +30 -12
  4. package/client/utils/formatWebpackMessages.d.ts +12 -0
  5. package/client/utils/formatWebpackMessages.js +87 -86
  6. package/compiled/autoprefixer/browserslist/index.d.ts +33 -7
  7. package/compiled/autoprefixer/index.js +3 -3
  8. package/compiled/autoprefixer/package.json +1 -1
  9. package/compiled/autoprefixer/postcss/lib/at-rule.d.ts +1 -1
  10. package/compiled/autoprefixer/postcss/lib/comment.d.ts +1 -1
  11. package/compiled/autoprefixer/postcss/lib/container.d.ts +2 -2
  12. package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
  13. package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
  14. package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
  15. package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
  16. package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
  17. package/compiled/autoprefixer/postcss/lib/node.d.ts +38 -4
  18. package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
  19. package/compiled/autoprefixer/postcss/lib/processor.d.ts +6 -5
  20. package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
  21. package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
  22. package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
  23. package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
  24. package/compiled/babel-loader/index.js +8 -2
  25. package/compiled/babel-loader/package.json +1 -1
  26. package/compiled/copy-webpack-plugin/939.index.js +1171 -0
  27. package/compiled/copy-webpack-plugin/index.js +16 -10
  28. package/compiled/copy-webpack-plugin/package.json +1 -1
  29. package/compiled/css-minimizer-webpack-plugin/index.js +8 -2
  30. package/compiled/css-minimizer-webpack-plugin/minify.js +23 -22
  31. package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
  32. package/compiled/css-minimizer-webpack-plugin/utils.js +305 -54
  33. package/compiled/cssnano/index.js +12 -11
  34. package/compiled/cssnano/package.json +1 -1
  35. package/compiled/express.d.ts +2 -0
  36. package/compiled/file-loader/index.js +3 -0
  37. package/compiled/file-loader/package.json +1 -0
  38. package/compiled/less-loader/index.js +1 -1
  39. package/compiled/less-loader/package.json +1 -1
  40. package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -46
  41. package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +10 -6
  42. package/compiled/mini-css-extract-plugin/index.js +10669 -10348
  43. package/compiled/mini-css-extract-plugin/loader.js +159 -100
  44. package/compiled/mini-css-extract-plugin/package.json +1 -1
  45. package/compiled/mini-css-extract-plugin/utils.js +88 -44
  46. package/compiled/postcss-loader/index.js +1 -1
  47. package/compiled/postcss-loader/package.json +1 -1
  48. package/compiled/sass-loader/index.js +1 -1
  49. package/compiled/sass-loader/package.json +1 -1
  50. package/compiled/sass-loader/sass.default.dart.js +4 -0
  51. package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
  52. package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
  53. package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
  54. package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
  55. package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
  56. package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
  57. package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
  58. package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
  59. package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
  60. package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
  61. package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
  62. package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
  63. package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
  64. package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
  65. package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
  66. package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
  67. package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
  68. package/compiled/schema-utils/declarations/validate.d.ts +4 -4
  69. package/compiled/schema-utils/index.js +8 -2
  70. package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
  71. package/compiled/style-loader/index.js +1 -1
  72. package/compiled/stylus-loader/LICENSE +20 -0
  73. package/compiled/stylus-loader/index.js +44 -0
  74. package/compiled/stylus-loader/package.json +1 -0
  75. package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
  76. package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
  77. package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
  78. package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
  79. package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  80. package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  81. package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  82. package/compiled/terser/index.js +1 -1
  83. package/compiled/terser/package.json +1 -1
  84. package/compiled/terser/tools/terser.d.ts +6 -3
  85. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
  86. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
  87. package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
  88. package/compiled/terser-webpack-plugin/index.js +1390 -3693
  89. package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
  90. package/compiled/terser-webpack-plugin/minify.js +10 -3
  91. package/compiled/terser-webpack-plugin/package.json +1 -1
  92. package/compiled/terser-webpack-plugin/types/index.d.ts +186 -152
  93. package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
  94. package/compiled/terser-webpack-plugin/types/utils.d.ts +20 -24
  95. package/compiled/terser-webpack-plugin/utils.js +153 -34
  96. package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
  97. package/compiled/webpack/BasicEvaluatedExpression.js +1 -0
  98. package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
  99. package/compiled/webpack/ExternalsPlugin.js +1 -0
  100. package/compiled/webpack/FetchCompileAsyncWasmPlugin.js +1 -0
  101. package/compiled/webpack/FetchCompileWasmPlugin.js +1 -0
  102. package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
  103. package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
  104. package/compiled/webpack/LimitChunkCountPlugin.js +1 -0
  105. package/compiled/webpack/NodeTargetPlugin.js +1 -0
  106. package/compiled/webpack/NodeTemplatePlugin.js +1 -0
  107. package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
  108. package/compiled/webpack/RuleSetCompiler.js +1 -0
  109. package/compiled/webpack/StringXor.js +1 -0
  110. package/compiled/webpack/UseEffectRulePlugin.js +1 -0
  111. package/compiled/webpack/WebWorkerTemplatePlugin.js +1 -0
  112. package/compiled/webpack/deepImports.json +15 -1
  113. package/compiled/webpack/index.js +26404 -10329
  114. package/compiled/webpack/json-schema/index.d.ts +8 -1
  115. package/compiled/webpack/lazy-compilation-node.js +10 -0
  116. package/compiled/webpack/lazy-compilation-web.js +9 -0
  117. package/compiled/webpack/types.d.ts +823 -287
  118. package/compiled/webpack-5-chain/index.js +1 -1
  119. package/compiled/webpack-5-chain/package.json +1 -1
  120. package/compiled/webpack-5-chain/types/index.d.ts +76 -20
  121. package/compiled/webpack-bundle-analyzer/index.js +7 -6
  122. package/compiled/webpack-bundle-analyzer/package.json +1 -1
  123. package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
  124. package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
  125. package/compiled/webpack-dev-middleware/index.js +12 -5
  126. package/compiled/webpack-dev-middleware/package.json +1 -1
  127. package/compiled/{tapable → webpack-manifest-plugin}/LICENSE +2 -2
  128. package/compiled/webpack-manifest-plugin/index.js +1 -0
  129. package/compiled/webpack-manifest-plugin/package.json +1 -0
  130. package/compiled/webpack-sources/index.js +1 -1
  131. package/compiled/{express → webpackbar}/LICENSE +1 -5
  132. package/compiled/webpackbar/dist/index.d.ts +121 -0
  133. package/compiled/webpackbar/index.js +7 -0
  134. package/compiled/webpackbar/package.json +1 -0
  135. package/compiled/ws/LICENSE +13 -12
  136. package/compiled/ws/index.d.ts +74 -35
  137. package/compiled/ws/index.js +1 -1
  138. package/compiled/ws/package.json +1 -1
  139. package/dist/build.d.ts +8 -3
  140. package/dist/build.js +147 -68
  141. package/dist/cli.d.ts +0 -1
  142. package/dist/cli.js +84 -81
  143. package/dist/config/_sampleFeature.js +33 -20
  144. package/dist/config/assetRules.js +46 -55
  145. package/dist/config/bundleAnalyzerPlugin.js +41 -28
  146. package/dist/config/compressPlugin.js +125 -74
  147. package/dist/config/config.d.ts +11 -2
  148. package/dist/config/config.js +235 -172
  149. package/dist/config/copyPlugin.js +61 -47
  150. package/dist/config/cssRules.js +162 -95
  151. package/dist/config/definePlugin.d.ts +2 -0
  152. package/dist/config/definePlugin.js +59 -39
  153. package/dist/config/detectCssModulesInDependence.d.ts +10 -0
  154. package/dist/config/detectCssModulesInDependence.js +151 -0
  155. package/dist/config/detectDeadCode.d.ts +12 -0
  156. package/dist/config/detectDeadCode.js +191 -0
  157. package/dist/config/detectDeadCodePlugin.d.ts +9 -0
  158. package/dist/config/detectDeadCodePlugin.js +82 -0
  159. package/dist/config/fastRefreshPlugin.js +46 -31
  160. package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
  161. package/dist/config/forkTSCheckerPlugin.js +49 -0
  162. package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
  163. package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
  164. package/dist/config/ignorePlugin.js +38 -25
  165. package/dist/config/javaScriptRules.d.ts +2 -0
  166. package/dist/config/javaScriptRules.js +186 -150
  167. package/dist/config/manifestPlugin.d.ts +11 -0
  168. package/dist/config/manifestPlugin.js +40 -0
  169. package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
  170. package/dist/config/miniCSSExtractPlugin.js +52 -31
  171. package/dist/config/nodePolyfill.js +49 -32
  172. package/dist/config/nodePrefixPlugin.d.ts +11 -0
  173. package/dist/config/nodePrefixPlugin.js +38 -0
  174. package/dist/config/progressPlugin.js +50 -24
  175. package/dist/config/purgecssWebpackPlugin.js +41 -30
  176. package/dist/config/speedMeasureWebpackPlugin.js +56 -31
  177. package/dist/config/ssrPlugin.d.ts +11 -0
  178. package/dist/config/ssrPlugin.js +98 -0
  179. package/dist/config/svgRules.d.ts +1 -0
  180. package/dist/config/svgRules.js +68 -54
  181. package/dist/constants.d.ts +4 -0
  182. package/dist/constants.js +59 -15
  183. package/dist/dev.d.ts +23 -3
  184. package/dist/dev.js +198 -81
  185. package/dist/index.d.ts +6 -2
  186. package/dist/index.js +31 -15
  187. package/dist/loader/svgr.d.ts +4 -0
  188. package/dist/loader/svgr.js +84 -0
  189. package/dist/loader/swc.d.ts +4 -0
  190. package/dist/loader/swc.js +149 -0
  191. package/dist/parcelCSS.d.ts +2 -0
  192. package/dist/parcelCSS.js +39 -0
  193. package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
  194. package/dist/plugins/EsbuildMinifyFix.js +136 -0
  195. package/dist/plugins/ProgressPlugin.js +68 -43
  196. package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
  197. package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
  198. package/dist/plugins/_SamplePlugin.d.ts +1 -1
  199. package/dist/plugins/_SamplePlugin.js +37 -14
  200. package/dist/requireHook.js +44 -27
  201. package/dist/schema.d.ts +4 -3
  202. package/dist/schema.js +175 -69
  203. package/dist/server/server.d.ts +4 -3
  204. package/dist/server/server.js +219 -154
  205. package/dist/server/ws.d.ts +8 -3
  206. package/dist/server/ws.js +72 -38
  207. package/dist/swcPlugins/autoCSSModules.d.ts +11 -2
  208. package/dist/swcPlugins/autoCSSModules.js +60 -32
  209. package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
  210. package/dist/swcPlugins/changeImportFromString.js +32 -0
  211. package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
  212. package/dist/swcPlugins/lockCoreJS.js +56 -0
  213. package/dist/types.d.ts +53 -9
  214. package/dist/types.js +61 -29
  215. package/dist/utils/browsersList.js +31 -8
  216. package/dist/utils/depMatch.js +65 -39
  217. package/dist/utils/formatWebpackMessages.js +119 -91
  218. package/dist/utils/getEsBuildTarget.d.ts +7 -0
  219. package/dist/utils/getEsBuildTarget.js +46 -0
  220. package/dist/utils/pkgUpContainsName.d.ts +1 -0
  221. package/dist/utils/pkgUpContainsName.js +50 -0
  222. package/package.json +89 -81
  223. package/compiled/@svgr/webpack/.svgo.yml +0 -75
  224. package/compiled/@svgr/webpack/LICENSE +0 -7
  225. package/compiled/@svgr/webpack/index.js +0 -343
  226. package/compiled/@svgr/webpack/package.json +0 -1
  227. package/compiled/css-loader/api.js +0 -102
  228. package/compiled/css-loader/getUrl.js +0 -29
  229. package/compiled/css-loader/index.js +0 -2
  230. package/compiled/css-loader/noSourceMaps.js +0 -5
  231. package/compiled/css-loader/package.json +0 -1
  232. package/compiled/css-loader/sourceMaps.js +0 -22
  233. package/compiled/express/body-parser/index.d.ts +0 -104
  234. package/compiled/express/connect/index.d.ts +0 -93
  235. package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
  236. package/compiled/express/index.d.ts +0 -133
  237. package/compiled/express/index.js +0 -338
  238. package/compiled/express/mime/index.d.ts +0 -35
  239. package/compiled/express/package.json +0 -1
  240. package/compiled/express/qs/index.d.ts +0 -62
  241. package/compiled/express/range-parser/index.d.ts +0 -35
  242. package/compiled/express/serve-static/index.d.ts +0 -108
  243. package/compiled/http-proxy-middleware/LICENSE +0 -22
  244. package/compiled/http-proxy-middleware/dist/index.d.ts +0 -4
  245. package/compiled/http-proxy-middleware/dist/types.d.ts +0 -54
  246. package/compiled/http-proxy-middleware/http-proxy/index.d.ts +0 -226
  247. package/compiled/http-proxy-middleware/index.js +0 -66
  248. package/compiled/http-proxy-middleware/package.json +0 -1
  249. package/compiled/less/index.js +0 -31
  250. package/compiled/less/package.json +0 -1
  251. package/compiled/react-refresh/index.js +0 -19
  252. package/compiled/swc-loader/LICENSE +0 -25
  253. package/compiled/swc-loader/index.js +0 -1
  254. package/compiled/swc-loader/package.json +0 -1
  255. package/compiled/tapable/index.js +0 -1
  256. package/compiled/tapable/package.json +0 -1
  257. package/compiled/tapable/tapable.d.ts +0 -116
  258. package/dist/build.d.ts.map +0 -1
  259. package/dist/cli.d.ts.map +0 -1
  260. package/dist/client/client.d.ts.map +0 -1
  261. package/dist/client/client.js +0 -239
  262. package/dist/config/_sampleFeature.d.ts.map +0 -1
  263. package/dist/config/assetRules.d.ts.map +0 -1
  264. package/dist/config/bundleAnalyzerPlugin.d.ts.map +0 -1
  265. package/dist/config/compressPlugin.d.ts.map +0 -1
  266. package/dist/config/config.d.ts.map +0 -1
  267. package/dist/config/copyPlugin.d.ts.map +0 -1
  268. package/dist/config/cssRules.d.ts.map +0 -1
  269. package/dist/config/definePlugin.d.ts.map +0 -1
  270. package/dist/config/fastRefreshPlugin.d.ts.map +0 -1
  271. package/dist/config/ignorePlugin.d.ts.map +0 -1
  272. package/dist/config/javaScriptRules.d.ts.map +0 -1
  273. package/dist/config/miniCSSExtractPlugin.d.ts.map +0 -1
  274. package/dist/config/nodePolyfill.d.ts.map +0 -1
  275. package/dist/config/progressPlugin.d.ts.map +0 -1
  276. package/dist/config/purgecssWebpackPlugin.d.ts.map +0 -1
  277. package/dist/config/speedMeasureWebpackPlugin.d.ts.map +0 -1
  278. package/dist/config/svgRules.d.ts.map +0 -1
  279. package/dist/constants.d.ts.map +0 -1
  280. package/dist/dev.d.ts.map +0 -1
  281. package/dist/index.d.ts.map +0 -1
  282. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
  283. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts.map +0 -1
  284. package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
  285. package/dist/plugins/ProgressPlugin.d.ts.map +0 -1
  286. package/dist/plugins/_SamplePlugin.d.ts.map +0 -1
  287. package/dist/requireHook.d.ts.map +0 -1
  288. package/dist/schema.d.ts.map +0 -1
  289. package/dist/server/server.d.ts.map +0 -1
  290. package/dist/server/ws.d.ts.map +0 -1
  291. package/dist/swcPlugins/autoCSSModules.d.ts.map +0 -1
  292. package/dist/types.d.ts.map +0 -1
  293. package/dist/utils/browsersList.d.ts.map +0 -1
  294. package/dist/utils/depMatch.d.ts.map +0 -1
  295. package/dist/utils/formatWebpackMessages.d.ts.map +0 -1
  296. /package/{dist → client}/client/client.d.ts +0 -0
  297. /package/compiled/{css-loader → file-loader}/LICENSE +0 -0
@@ -1,31 +1,55 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.pitch = pitch;
7
- exports.default = _default;
8
-
9
- var _path = _interopRequireDefault(require("path"));
10
-
11
- var _utils = require("./utils");
12
-
13
- var _loaderOptions = _interopRequireDefault(require("./loader-options.json"));
14
-
15
- var _index = _interopRequireWildcard(require("./index"));
16
-
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); }
18
-
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; }
20
-
21
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
-
3
+ const path = require("path");
4
+ const {
5
+ findModuleById,
6
+ evalModuleCode,
7
+ AUTO_PUBLIC_PATH,
8
+ ABSOLUTE_PUBLIC_PATH,
9
+ BASE_URI,
10
+ SINGLE_DOT_PATH_SEGMENT,
11
+ stringifyRequest,
12
+ stringifyLocal
13
+ } = require("./utils");
14
+ const schema = require("./loader-options.json");
15
+ const MiniCssExtractPlugin = require("./index");
16
+
17
+ /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
18
+ /** @typedef {import("webpack").Compiler} Compiler */
19
+ /** @typedef {import("webpack").Compilation} Compilation */
20
+ /** @typedef {import("webpack").Chunk} Chunk */
21
+ /** @typedef {import("webpack").Module} Module */
22
+ /** @typedef {import("webpack").sources.Source} Source */
23
+ /** @typedef {import("webpack").AssetInfo} AssetInfo */
24
+ /** @typedef {import("webpack").NormalModule} NormalModule */
25
+ /** @typedef {import("./index.js").LoaderOptions} LoaderOptions */
26
+ /** @typedef {{ [key: string]: string | function }} Locals */
27
+
28
+ /** @typedef {any} TODO */
29
+
30
+ /**
31
+ * @typedef {Object} Dependency
32
+ * @property {string} identifier
33
+ * @property {string | null} context
34
+ * @property {Buffer} content
35
+ * @property {string} media
36
+ * @property {string} [supports]
37
+ * @property {string} [layer]
38
+ * @property {Buffer} [sourceMap]
39
+ */
40
+
41
+ /**
42
+ * @param {string} content
43
+ * @param {{ loaderContext: import("webpack").LoaderContext<LoaderOptions>, options: LoaderOptions, locals: Locals | undefined }} context
44
+ * @returns {string}
45
+ */
23
46
  function hotLoader(content, context) {
24
47
  const accept = context.locals ? "" : "module.hot.accept(undefined, cssReload);";
25
48
  return `${content}
26
49
  if(module.hot) {
27
50
  // ${Date.now()}
28
- var cssReload = require(${(0, _utils.stringifyRequest)(context.context, _path.default.join(__dirname, "hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({ ...context.options,
51
+ var cssReload = require(${stringifyRequest(context.loaderContext, path.join(__dirname, "hmr/hotModuleReplacement.js"))})(module.id, ${JSON.stringify({
52
+ ...context.options,
29
53
  locals: !!context.locals
30
54
  })});
31
55
  module.hot.dispose(cssReload);
@@ -34,61 +58,72 @@ function hotLoader(content, context) {
34
58
  `;
35
59
  }
36
60
 
61
+ /**
62
+ * @this {import("webpack").LoaderContext<LoaderOptions>}
63
+ * @param {string} request
64
+ */
37
65
  function pitch(request) {
38
- const options = this.getOptions(_loaderOptions.default);
66
+ // @ts-ignore
67
+ const options = this.getOptions( /** @type {Schema} */schema);
68
+ const emit = typeof options.emit !== "undefined" ? options.emit : true;
39
69
  const callback = this.async();
40
- const optionsFromPlugin = this[_index.pluginSymbol];
41
-
70
+ const optionsFromPlugin = /** @type {TODO} */this[MiniCssExtractPlugin.pluginSymbol];
42
71
  if (!optionsFromPlugin) {
43
72
  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"));
44
73
  return;
45
74
  }
46
-
47
75
  const {
48
76
  webpack
49
- } = this._compiler;
50
-
77
+ } = /** @type {Compiler} */this._compiler;
78
+
79
+ /**
80
+ * @param {TODO} originalExports
81
+ * @param {Compilation} [compilation]
82
+ * @param {{ [name: string]: Source }} [assets]
83
+ * @param {Map<string, AssetInfo>} [assetsInfo]
84
+ * @returns {void}
85
+ */
51
86
  const handleExports = (originalExports, compilation, assets, assetsInfo) => {
87
+ /** @type {Locals | undefined} */
52
88
  let locals;
53
89
  let namedExport;
54
90
  const esModule = typeof options.esModule !== "undefined" ? options.esModule : true;
55
91
 
92
+ /**
93
+ * @param {Dependency[] | [null, object][]} dependencies
94
+ */
56
95
  const addDependencies = dependencies => {
57
96
  if (!Array.isArray(dependencies) && dependencies != null) {
58
97
  throw new Error(`Exported value was not extracted as an array: ${JSON.stringify(dependencies)}`);
59
98
  }
60
-
61
99
  const identifierCountMap = new Map();
62
- const emit = typeof options.emit !== "undefined" ? options.emit : true;
63
100
  let lastDep;
64
-
65
101
  for (const dependency of dependencies) {
66
- if (!dependency.identifier || !emit) {
102
+ if (! /** @type {Dependency} */dependency.identifier || !emit) {
67
103
  // eslint-disable-next-line no-continue
68
104
  continue;
69
105
  }
70
-
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);
106
+ const count = identifierCountMap.get( /** @type {Dependency} */dependency.identifier) || 0;
107
+ const CssDependency = MiniCssExtractPlugin.getCssDependency(webpack);
108
+
109
+ /** @type {NormalModule} */
110
+ this._module.addDependency(lastDep = new CssDependency( /** @type {Dependency} */
111
+ dependency, /** @type {Dependency} */
112
+ dependency.context, count));
113
+ identifierCountMap.set( /** @type {Dependency} */
114
+ dependency.identifier, count + 1);
78
115
  }
79
-
80
116
  if (lastDep && assets) {
81
117
  lastDep.assets = assets;
82
118
  lastDep.assetsInfo = assetsInfo;
83
119
  }
84
120
  };
85
-
86
121
  try {
87
122
  // eslint-disable-next-line no-underscore-dangle
88
123
  const exports = originalExports.__esModule ? originalExports.default : originalExports;
89
- namedExport = // eslint-disable-next-line no-underscore-dangle
124
+ namedExport =
125
+ // eslint-disable-next-line no-underscore-dangle
90
126
  originalExports.__esModule && (!originalExports.default || !("locals" in originalExports.default));
91
-
92
127
  if (namedExport) {
93
128
  Object.keys(originalExports).forEach(key => {
94
129
  if (key !== "default") {
@@ -96,6 +131,7 @@ function pitch(request) {
96
131
  locals = {};
97
132
  }
98
133
 
134
+ /** @type {Locals} */
99
135
  locals[key] = originalExports[key];
100
136
  }
101
137
  });
@@ -103,17 +139,17 @@ function pitch(request) {
103
139
  locals = exports && exports.locals;
104
140
  }
105
141
 
142
+ /** @type {Dependency[] | [null, object][]} */
106
143
  let dependencies;
107
-
108
144
  if (!Array.isArray(exports)) {
109
145
  dependencies = [[null, exports]];
110
146
  } else {
111
147
  dependencies = exports.map(([id, content, media, sourceMap, supports, layer]) => {
112
148
  let identifier = id;
113
149
  let context;
114
-
115
150
  if (compilation) {
116
- const module = (0, _utils.findModuleById)(compilation, id);
151
+ const module = /** @type {Module} */
152
+ findModuleById(compilation, id);
117
153
  identifier = module.identifier();
118
154
  ({
119
155
  context
@@ -122,7 +158,6 @@ function pitch(request) {
122
158
  // TODO check if this context is used somewhere
123
159
  context = this.rootContext;
124
160
  }
125
-
126
161
  return {
127
162
  identifier,
128
163
  context,
@@ -130,64 +165,71 @@ function pitch(request) {
130
165
  media,
131
166
  supports,
132
167
  layer,
133
- sourceMap: sourceMap ? Buffer.from(JSON.stringify(sourceMap)) : // eslint-disable-next-line no-undefined
168
+ sourceMap: sourceMap ? Buffer.from(JSON.stringify(sourceMap)) :
169
+ // eslint-disable-next-line no-undefined
134
170
  undefined
135
171
  };
136
172
  });
137
173
  }
138
-
139
174
  addDependencies(dependencies);
140
175
  } catch (e) {
141
- return callback(e);
176
+ callback( /** @type {Error} */e);
177
+ return;
142
178
  }
179
+ const result = locals ? namedExport ? Object.keys(locals).map(key => `\nexport var ${key} = ${stringifyLocal( /** @type {Locals} */locals[key])};`).join("") : `\n${esModule ? "export default" : "module.exports ="} ${JSON.stringify(locals)};` : esModule ? `\nexport {};` : "";
180
+ let resultSource = `// extracted by ${MiniCssExtractPlugin.pluginName}`;
143
181
 
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}`;
146
- resultSource += this.hot ? hotLoader(result, {
147
- context: this.context,
182
+ // only attempt hotreloading if the css is actually used for something other than hash values
183
+ resultSource += this.hot && emit ? hotLoader(result, {
184
+ loaderContext: this,
148
185
  options,
149
186
  locals
150
187
  }) : result;
151
- return callback(null, resultSource);
188
+ callback(null, resultSource);
152
189
  };
153
-
154
190
  let {
155
191
  publicPath
156
- } = this._compilation.outputOptions;
157
-
192
+ } = /** @type {Compilation} */
193
+ this._compilation.outputOptions;
158
194
  if (typeof options.publicPath === "string") {
159
195
  // eslint-disable-next-line prefer-destructuring
160
196
  publicPath = options.publicPath;
161
197
  } else if (typeof options.publicPath === "function") {
162
198
  publicPath = options.publicPath(this.resourcePath, this.rootContext);
163
199
  }
164
-
165
200
  if (publicPath === "auto") {
166
- publicPath = _utils.AUTO_PUBLIC_PATH;
201
+ publicPath = AUTO_PUBLIC_PATH;
167
202
  }
168
-
169
203
  if (typeof optionsFromPlugin.experimentalUseImportModule === "undefined" && typeof this.importModule === "function" || optionsFromPlugin.experimentalUseImportModule) {
170
204
  if (!this.importModule) {
171
205
  callback(new Error("You are using 'experimentalUseImportModule' but 'this.importModule' is not available in loader context. You need to have at least webpack 5.33.2."));
172
206
  return;
173
207
  }
174
-
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)}`;
208
+ let publicPathForExtract;
209
+ if (typeof publicPath === "string") {
210
+ const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
211
+ publicPathForExtract = isAbsolutePublicPath ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}`;
212
+ } else {
213
+ publicPathForExtract = publicPath;
214
+ }
177
215
  this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
178
216
  layer: options.layer,
179
- publicPath: publicPathForExtract
180
- }, (error, exports) => {
217
+ publicPath: /** @type {string} */publicPathForExtract,
218
+ baseUri: `${BASE_URI}/`
219
+ },
220
+ /**
221
+ * @param {Error | null | undefined} error
222
+ * @param {object} exports
223
+ */
224
+ (error, exports) => {
181
225
  if (error) {
182
226
  callback(error);
183
227
  return;
184
228
  }
185
-
186
229
  handleExports(exports);
187
230
  });
188
231
  return;
189
232
  }
190
-
191
233
  const loaders = this.loaders.slice(this.loaderIndex + 1);
192
234
  this.addDependency(this.resourcePath);
193
235
  const childFilename = "*";
@@ -195,17 +237,20 @@ function pitch(request) {
195
237
  filename: childFilename,
196
238
  publicPath
197
239
  };
240
+ const childCompiler = /** @type {Compilation} */
241
+ this._compilation.createChildCompiler(`${MiniCssExtractPlugin.pluginName} ${request}`, outputOptions);
198
242
 
199
- const childCompiler = this._compilation.createChildCompiler(`${_index.pluginName} ${request}`, outputOptions); // The templates are compiled and executed by NodeJS - similar to server side rendering
243
+ // The templates are compiled and executed by NodeJS - similar to server side rendering
200
244
  // Unfortunately this causes issues as some loaders require an absolute URL to support ES Modules
201
245
  // The following config enables relative URL support for the child compiler
202
-
203
-
204
- childCompiler.options.module = { ...childCompiler.options.module
246
+ childCompiler.options.module = {
247
+ ...childCompiler.options.module
205
248
  };
206
- childCompiler.options.module.parser = { ...childCompiler.options.module.parser
249
+ childCompiler.options.module.parser = {
250
+ ...childCompiler.options.module.parser
207
251
  };
208
- childCompiler.options.module.parser.javascript = { ...childCompiler.options.module.parser.javascript,
252
+ childCompiler.options.module.parser.javascript = {
253
+ ...childCompiler.options.module.parser.javascript,
209
254
  url: "relative"
210
255
  };
211
256
  const {
@@ -242,13 +287,18 @@ function pitch(request) {
242
287
  const {
243
288
  NormalModule
244
289
  } = webpack;
245
- childCompiler.hooks.thisCompilation.tap(`${_index.pluginName} loader`, compilation => {
290
+ childCompiler.hooks.thisCompilation.tap(`${MiniCssExtractPlugin.pluginName} loader`,
291
+ /**
292
+ * @param {Compilation} compilation
293
+ */
294
+ compilation => {
246
295
  const normalModuleHook = NormalModule.getCompilationHooks(compilation).loader;
247
- normalModuleHook.tap(`${_index.pluginName} loader`, (loaderContext, module) => {
296
+ normalModuleHook.tap(`${MiniCssExtractPlugin.pluginName} loader`, (loaderContext, module) => {
248
297
  if (module.request === request) {
249
298
  // eslint-disable-next-line no-param-reassign
250
299
  module.loaders = loaders.map(loader => {
251
300
  return {
301
+ type: null,
252
302
  loader: loader.path,
253
303
  options: loader.options,
254
304
  ident: loader.ident
@@ -257,11 +307,18 @@ function pitch(request) {
257
307
  }
258
308
  });
259
309
  });
260
- let source;
261
- childCompiler.hooks.compilation.tap(_index.pluginName, compilation => {
262
- compilation.hooks.processAssets.tap(_index.pluginName, () => {
263
- source = compilation.assets[childFilename] && compilation.assets[childFilename].source(); // Remove all chunk assets
264
310
 
311
+ /** @type {string | Buffer} */
312
+ let source;
313
+ childCompiler.hooks.compilation.tap(MiniCssExtractPlugin.pluginName,
314
+ /**
315
+ * @param {Compilation} compilation
316
+ */
317
+ compilation => {
318
+ compilation.hooks.processAssets.tap(MiniCssExtractPlugin.pluginName, () => {
319
+ source = compilation.assets[childFilename] && compilation.assets[childFilename].source();
320
+
321
+ // Remove all chunk assets
265
322
  compilation.chunks.forEach(chunk => {
266
323
  chunk.files.forEach(file => {
267
324
  compilation.deleteAsset(file);
@@ -271,45 +328,47 @@ function pitch(request) {
271
328
  });
272
329
  childCompiler.runAsChild((error, entries, compilation) => {
273
330
  if (error) {
274
- return callback(error);
331
+ callback(error);
332
+ return;
275
333
  }
276
-
277
- if (compilation.errors.length > 0) {
278
- return callback(compilation.errors[0]);
334
+ if ( /** @type {Compilation} */compilation.errors.length > 0) {
335
+ callback( /** @type {Compilation} */compilation.errors[0]);
336
+ return;
279
337
  }
280
338
 
339
+ /** @type {{ [name: string]: Source }} */
281
340
  const assets = Object.create(null);
341
+ /** @type {Map<string, AssetInfo>} */
282
342
  const assetsInfo = new Map();
283
-
284
- for (const asset of compilation.getAssets()) {
343
+ for (const asset of /** @type {Compilation} */compilation.getAssets()) {
285
344
  assets[asset.name] = asset.source;
286
345
  assetsInfo.set(asset.name, asset.info);
287
346
  }
288
347
 
348
+ /** @type {Compilation} */
289
349
  compilation.fileDependencies.forEach(dep => {
290
350
  this.addDependency(dep);
291
351
  }, this);
352
+
353
+ /** @type {Compilation} */
292
354
  compilation.contextDependencies.forEach(dep => {
293
355
  this.addContextDependency(dep);
294
356
  }, this);
295
-
296
357
  if (!source) {
297
- return callback(new Error("Didn't get a result from child compiler"));
358
+ callback(new Error("Didn't get a result from child compiler"));
359
+ return;
298
360
  }
299
-
300
361
  let originalExports;
301
-
302
362
  try {
303
- originalExports = (0, _utils.evalModuleCode)(this, source, request);
363
+ originalExports = evalModuleCode(this, source, request);
304
364
  } catch (e) {
305
- return callback(e);
365
+ callback( /** @type {Error} */e);
366
+ return;
306
367
  }
307
-
308
- return handleExports(originalExports, compilation, assets, assetsInfo);
368
+ handleExports(originalExports, compilation, assets, assetsInfo);
309
369
  });
310
- } // eslint-disable-next-line func-names
311
-
312
-
313
- function _default(content) {
314
- console.log(content);
315
- }
370
+ }
371
+ module.exports = {
372
+ default: function loader() {},
373
+ pitch
374
+ };
@@ -1 +1 @@
1
- {"name":"mini-css-extract-plugin","author":"Tobias Koppers @sokra","license":"MIT"}
1
+ {"name":"mini-css-extract-plugin","version":"2.7.2","author":"Tobias Koppers @sokra","license":"MIT","types":"types/index.d.ts"}
@@ -1,95 +1,116 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.trueFn = trueFn;
7
- exports.findModuleById = findModuleById;
8
- exports.evalModuleCode = evalModuleCode;
9
- exports.compareModulesByIdentifier = compareModulesByIdentifier;
10
- exports.stringifyRequest = stringifyRequest;
11
- exports.getUndoPath = getUndoPath;
12
- exports.SINGLE_DOT_PATH_SEGMENT = exports.ABSOLUTE_PUBLIC_PATH = exports.AUTO_PUBLIC_PATH = exports.MODULE_TYPE = void 0;
3
+ const NativeModule = require("module");
4
+ const path = require("path");
13
5
 
14
- var _module = _interopRequireDefault(require("module"));
15
-
16
- var _path = _interopRequireDefault(require("path"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+ /** @typedef {import("webpack").Compilation} Compilation */
7
+ /** @typedef {import("webpack").Module} Module */
8
+ /** @typedef {import("webpack").LoaderContext<any>} LoaderContext */
19
9
 
10
+ /**
11
+ * @returns {boolean}
12
+ */
20
13
  function trueFn() {
21
14
  return true;
22
15
  }
23
16
 
17
+ /**
18
+ * @param {Compilation} compilation
19
+ * @param {string | number} id
20
+ * @returns {null | Module}
21
+ */
24
22
  function findModuleById(compilation, id) {
25
23
  const {
26
24
  modules,
27
25
  chunkGraph
28
26
  } = compilation;
29
-
30
27
  for (const module of modules) {
31
28
  const moduleId = typeof chunkGraph !== "undefined" ? chunkGraph.getModuleId(module) : module.id;
32
-
33
29
  if (moduleId === id) {
34
30
  return module;
35
31
  }
36
32
  }
37
-
38
33
  return null;
39
34
  }
40
35
 
36
+ /**
37
+ * @param {LoaderContext} loaderContext
38
+ * @param {string | Buffer} code
39
+ * @param {string} filename
40
+ * @returns {object}
41
+ */
41
42
  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
43
+ // @ts-ignore
44
+ const module = new NativeModule(filename, loaderContext);
44
45
 
46
+ // @ts-ignore
47
+ module.paths = NativeModule._nodeModulePaths(loaderContext.context); // eslint-disable-line no-underscore-dangle
45
48
  module.filename = filename;
46
-
49
+ // @ts-ignore
47
50
  module._compile(code, filename); // eslint-disable-line no-underscore-dangle
48
51
 
49
-
50
52
  return module.exports;
51
53
  }
52
54
 
55
+ /**
56
+ * @param {string} a
57
+ * @param {string} b
58
+ * @returns {0 | 1 | -1}
59
+ */
53
60
  function compareIds(a, b) {
54
61
  if (typeof a !== typeof b) {
55
62
  return typeof a < typeof b ? -1 : 1;
56
63
  }
57
-
58
64
  if (a < b) {
59
65
  return -1;
60
66
  }
61
-
62
67
  if (a > b) {
63
68
  return 1;
64
69
  }
65
-
66
70
  return 0;
67
71
  }
68
72
 
73
+ /**
74
+ * @param {Module} a
75
+ * @param {Module} b
76
+ * @returns {0 | 1 | -1}
77
+ */
69
78
  function compareModulesByIdentifier(a, b) {
70
79
  return compareIds(a.identifier(), b.identifier());
71
80
  }
72
-
73
81
  const MODULE_TYPE = "css/mini-extract";
74
- exports.MODULE_TYPE = MODULE_TYPE;
75
82
  const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
76
- exports.AUTO_PUBLIC_PATH = AUTO_PUBLIC_PATH;
77
83
  const ABSOLUTE_PUBLIC_PATH = "webpack:///mini-css-extract-plugin/";
78
- exports.ABSOLUTE_PUBLIC_PATH = ABSOLUTE_PUBLIC_PATH;
84
+ const BASE_URI = "webpack://";
79
85
  const SINGLE_DOT_PATH_SEGMENT = "__mini_css_extract_plugin_single_dot_path_segment__";
80
- exports.SINGLE_DOT_PATH_SEGMENT = SINGLE_DOT_PATH_SEGMENT;
81
86
 
87
+ /**
88
+ * @param {string} str
89
+ * @returns {boolean}
90
+ */
82
91
  function isAbsolutePath(str) {
83
- return _path.default.posix.isAbsolute(str) || _path.default.win32.isAbsolute(str);
92
+ return path.posix.isAbsolute(str) || path.win32.isAbsolute(str);
84
93
  }
85
-
86
94
  const RELATIVE_PATH_REGEXP = /^\.\.?[/\\]/;
87
95
 
96
+ /**
97
+ * @param {string} str
98
+ * @returns {boolean}
99
+ */
88
100
  function isRelativePath(str) {
89
101
  return RELATIVE_PATH_REGEXP.test(str);
90
102
  }
91
103
 
104
+ // TODO simplify for the next major release
105
+ /**
106
+ * @param {LoaderContext} loaderContext
107
+ * @param {string} request
108
+ * @returns {string}
109
+ */
92
110
  function stringifyRequest(loaderContext, request) {
111
+ if (typeof loaderContext.utils !== "undefined" && typeof loaderContext.utils.contextify === "function") {
112
+ return JSON.stringify(loaderContext.utils.contextify(loaderContext.context || loaderContext.rootContext, request));
113
+ }
93
114
  const splitted = request.split("!");
94
115
  const {
95
116
  context
@@ -99,33 +120,35 @@ function stringifyRequest(loaderContext, request) {
99
120
  const splittedPart = part.match(/^(.*?)(\?.*)/);
100
121
  const query = splittedPart ? splittedPart[2] : "";
101
122
  let singlePath = splittedPart ? splittedPart[1] : part;
102
-
103
123
  if (isAbsolutePath(singlePath) && context) {
104
- singlePath = _path.default.relative(context, singlePath);
105
-
124
+ singlePath = path.relative(context, singlePath);
106
125
  if (isAbsolutePath(singlePath)) {
107
126
  // If singlePath still matches an absolute path, singlePath was on a different drive than context.
108
127
  // In this case, we leave the path platform-specific without replacing any separators.
109
128
  // @see https://github.com/webpack/loader-utils/pull/14
110
129
  return singlePath + query;
111
130
  }
112
-
113
131
  if (isRelativePath(singlePath) === false) {
114
132
  // Ensure that the relative path starts at least with ./ otherwise it would be a request into the modules directory (like node_modules).
115
133
  singlePath = `./${singlePath}`;
116
134
  }
117
135
  }
118
-
119
136
  return singlePath.replace(/\\/g, "/") + query;
120
137
  }).join("!"));
121
138
  }
122
139
 
140
+ /**
141
+ * @param {string} filename
142
+ * @param {string} outputPath
143
+ * @param {boolean} enforceRelative
144
+ * @returns {string}
145
+ */
123
146
  function getUndoPath(filename, outputPath, enforceRelative) {
124
147
  let depth = -1;
125
- let append = ""; // eslint-disable-next-line no-param-reassign
148
+ let append = "";
126
149
 
150
+ // eslint-disable-next-line no-param-reassign
127
151
  outputPath = outputPath.replace(/[\\/]$/, "");
128
-
129
152
  for (const part of filename.split(/[/\\]+/)) {
130
153
  if (part === "..") {
131
154
  if (depth > -1) {
@@ -135,13 +158,12 @@ function getUndoPath(filename, outputPath, enforceRelative) {
135
158
  const i = outputPath.lastIndexOf("/");
136
159
  const j = outputPath.lastIndexOf("\\");
137
160
  const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
138
-
139
161
  if (pos < 0) {
140
162
  return `${outputPath}/`;
141
163
  }
164
+ append = `${outputPath.slice(pos + 1)}/${append}`;
142
165
 
143
- append = `${outputPath.slice(pos + 1)}/${append}`; // eslint-disable-next-line no-param-reassign
144
-
166
+ // eslint-disable-next-line no-param-reassign
145
167
  outputPath = outputPath.slice(0, pos);
146
168
  }
147
169
  } else if (part !== ".") {
@@ -149,6 +171,28 @@ function getUndoPath(filename, outputPath, enforceRelative) {
149
171
  depth++;
150
172
  }
151
173
  }
152
-
153
174
  return depth > 0 ? `${"../".repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
154
- }
175
+ }
176
+
177
+ /**
178
+ *
179
+ * @param {string | function} value
180
+ * @returns {string}
181
+ */
182
+ function stringifyLocal(value) {
183
+ return typeof value === "function" ? value.toString() : JSON.stringify(value);
184
+ }
185
+ module.exports = {
186
+ trueFn,
187
+ findModuleById,
188
+ evalModuleCode,
189
+ compareModulesByIdentifier,
190
+ MODULE_TYPE,
191
+ AUTO_PUBLIC_PATH,
192
+ ABSOLUTE_PUBLIC_PATH,
193
+ BASE_URI,
194
+ SINGLE_DOT_PATH_SEGMENT,
195
+ stringifyRequest,
196
+ stringifyLocal,
197
+ getUndoPath
198
+ };