@umijs/bundler-webpack 4.0.0-beta.9 → 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.
- package/client/client/client.js +255 -167
- package/client/constants.d.ts +15 -0
- package/client/constants.js +30 -12
- package/client/utils/formatWebpackMessages.d.ts +12 -0
- package/client/utils/formatWebpackMessages.js +87 -86
- package/compiled/autoprefixer/browserslist/index.d.ts +33 -7
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/package.json +1 -1
- 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/container.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/css-syntax-error.d.ts +55 -8
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +2 -2
- package/compiled/autoprefixer/postcss/lib/input.d.ts +26 -6
- package/compiled/autoprefixer/postcss/lib/lazy-result.d.ts +11 -10
- package/compiled/autoprefixer/postcss/lib/no-work-result.d.ts +37 -0
- package/compiled/autoprefixer/postcss/lib/node.d.ts +38 -4
- package/compiled/autoprefixer/postcss/lib/postcss.d.ts +31 -30
- package/compiled/autoprefixer/postcss/lib/processor.d.ts +6 -5
- package/compiled/autoprefixer/postcss/lib/result.d.ts +3 -2
- package/compiled/autoprefixer/postcss/lib/rule.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/warning.d.ts +37 -3
- package/compiled/autoprefixer/source-map-js/source-map.d.ts +99 -82
- package/compiled/babel-loader/index.js +8 -2
- package/compiled/babel-loader/package.json +1 -1
- 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 +23 -22
- package/compiled/css-minimizer-webpack-plugin/package.json +1 -1
- package/compiled/css-minimizer-webpack-plugin/utils.js +305 -54
- package/compiled/cssnano/index.js +12 -11
- package/compiled/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/file-loader/index.js +3 -0
- package/compiled/file-loader/package.json +1 -0
- package/compiled/less-loader/index.js +1 -1
- package/compiled/less-loader/package.json +1 -1
- package/compiled/mini-css-extract-plugin/hmr/hotModuleReplacement.js +60 -46
- package/compiled/mini-css-extract-plugin/hmr/normalize-url.js +10 -6
- package/compiled/mini-css-extract-plugin/index.js +10669 -10348
- package/compiled/mini-css-extract-plugin/loader.js +159 -100
- package/compiled/mini-css-extract-plugin/package.json +1 -1
- package/compiled/mini-css-extract-plugin/utils.js +88 -44
- package/compiled/postcss-loader/index.js +1 -1
- package/compiled/postcss-loader/package.json +1 -1
- package/compiled/sass-loader/index.js +1 -1
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/sass-loader/sass.default.dart.js +4 -0
- package/compiled/schema-utils/ajv/dist/ajv.d.ts +16 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/code.d.ts +39 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/index.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/codegen/scope.d.ts +79 -0
- package/compiled/schema-utils/ajv/dist/compile/errors.d.ts +13 -0
- package/compiled/schema-utils/ajv/dist/compile/index.d.ts +80 -0
- package/compiled/schema-utils/ajv/dist/compile/ref_error.d.ts +5 -0
- package/compiled/schema-utils/ajv/dist/compile/resolve.d.ts +12 -0
- package/compiled/schema-utils/ajv/dist/compile/rules.d.ts +28 -0
- package/compiled/schema-utils/ajv/dist/compile/util.d.ts +40 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/index.d.ts +42 -0
- package/compiled/schema-utils/ajv/dist/compile/validate/subschema.d.ts +47 -0
- package/compiled/schema-utils/ajv/dist/core.d.ts +171 -0
- package/compiled/schema-utils/ajv/dist/runtime/validation_error.d.ts +7 -0
- package/compiled/schema-utils/ajv/dist/types/index.d.ts +177 -0
- package/compiled/schema-utils/ajv/dist/types/json-schema.d.ts +124 -0
- package/compiled/schema-utils/ajv/dist/types/jtd-schema.d.ts +168 -0
- package/compiled/schema-utils/declarations/validate.d.ts +4 -4
- package/compiled/schema-utils/index.js +8 -2
- package/compiled/schema-utils/uri-js/dist/es5/uri.all.d.ts +59 -0
- package/compiled/style-loader/index.js +1 -1
- package/compiled/stylus-loader/LICENSE +20 -0
- package/compiled/stylus-loader/index.js +44 -0
- package/compiled/stylus-loader/package.json +1 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +90 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/compiled/terser/@jridgewell/gen-mapping/dist/types/types.d.ts +35 -0
- package/compiled/terser/@jridgewell/source-map/dist/types/source-map.d.ts +25 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser/index.js +1 -1
- package/compiled/terser/package.json +1 -1
- package/compiled/terser/tools/terser.d.ts +6 -3
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts +16 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts +74 -0
- package/compiled/terser-webpack-plugin/@jridgewell/trace-mapping/dist/types/types.d.ts +92 -0
- package/compiled/terser-webpack-plugin/index.js +1390 -3693
- package/compiled/terser-webpack-plugin/jest-worker/build/types.d.ts +1 -0
- package/compiled/terser-webpack-plugin/minify.js +10 -3
- package/compiled/terser-webpack-plugin/package.json +1 -1
- package/compiled/terser-webpack-plugin/types/index.d.ts +186 -152
- package/compiled/terser-webpack-plugin/types/minify.d.ts +17 -0
- package/compiled/terser-webpack-plugin/types/utils.d.ts +20 -24
- package/compiled/terser-webpack-plugin/utils.js +153 -34
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicEvaluatedExpression.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/ExternalsPlugin.js +1 -0
- package/compiled/webpack/FetchCompileAsyncWasmPlugin.js +1 -0
- package/compiled/webpack/FetchCompileWasmPlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/LimitChunkCountPlugin.js +1 -0
- package/compiled/webpack/NodeTargetPlugin.js +1 -0
- package/compiled/webpack/NodeTemplatePlugin.js +1 -0
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/StringXor.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/WebWorkerTemplatePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +15 -1
- package/compiled/webpack/index.js +26404 -10329
- package/compiled/webpack/json-schema/index.d.ts +8 -1
- package/compiled/webpack/lazy-compilation-node.js +10 -0
- package/compiled/webpack/lazy-compilation-web.js +9 -0
- package/compiled/webpack/types.d.ts +823 -287
- package/compiled/webpack-5-chain/index.js +1 -1
- package/compiled/webpack-5-chain/package.json +1 -1
- package/compiled/webpack-5-chain/types/index.d.ts +76 -20
- package/compiled/webpack-bundle-analyzer/index.js +7 -6
- package/compiled/webpack-bundle-analyzer/package.json +1 -1
- package/compiled/webpack-bundle-analyzer/public/viewer.js +2 -2
- package/compiled/webpack-bundle-analyzer/public/viewer.js.map +1 -1
- package/compiled/webpack-dev-middleware/index.js +12 -5
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/{tapable → webpack-manifest-plugin}/LICENSE +2 -2
- package/compiled/webpack-manifest-plugin/index.js +1 -0
- package/compiled/webpack-manifest-plugin/package.json +1 -0
- package/compiled/webpack-sources/index.js +1 -1
- package/compiled/{express → webpackbar}/LICENSE +1 -5
- package/compiled/webpackbar/dist/index.d.ts +121 -0
- package/compiled/webpackbar/index.js +7 -0
- package/compiled/webpackbar/package.json +1 -0
- package/compiled/ws/LICENSE +13 -12
- package/compiled/ws/index.d.ts +74 -35
- package/compiled/ws/index.js +1 -1
- package/compiled/ws/package.json +1 -1
- package/dist/build.d.ts +8 -3
- package/dist/build.js +147 -68
- package/dist/cli.js +84 -81
- package/dist/config/_sampleFeature.js +33 -20
- package/dist/config/assetRules.js +46 -67
- package/dist/config/bundleAnalyzerPlugin.js +41 -28
- package/dist/config/compressPlugin.js +125 -74
- package/dist/config/config.d.ts +11 -2
- package/dist/config/config.js +235 -172
- package/dist/config/copyPlugin.js +61 -47
- package/dist/config/cssRules.js +162 -95
- package/dist/config/definePlugin.d.ts +2 -0
- package/dist/config/definePlugin.js +59 -39
- package/dist/config/detectCssModulesInDependence.d.ts +10 -0
- package/dist/config/detectCssModulesInDependence.js +151 -0
- package/dist/config/detectDeadCode.d.ts +12 -0
- package/dist/config/detectDeadCode.js +191 -0
- package/dist/config/detectDeadCodePlugin.d.ts +9 -0
- package/dist/config/detectDeadCodePlugin.js +82 -0
- package/dist/config/fastRefreshPlugin.js +46 -31
- package/dist/config/forkTSCheckerPlugin.d.ts +11 -0
- package/dist/config/forkTSCheckerPlugin.js +49 -0
- package/dist/config/harmonyLinkingErrorPlugin.d.ts +6 -0
- package/dist/config/harmonyLinkingErrorPlugin.js +53 -0
- package/dist/config/ignorePlugin.js +38 -25
- package/dist/config/javaScriptRules.d.ts +2 -0
- package/dist/config/javaScriptRules.js +186 -150
- package/dist/config/manifestPlugin.d.ts +11 -0
- package/dist/config/manifestPlugin.js +40 -0
- package/dist/config/miniCSSExtractPlugin.d.ts +1 -0
- package/dist/config/miniCSSExtractPlugin.js +52 -31
- package/dist/config/nodePolyfill.js +49 -32
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +38 -0
- package/dist/config/progressPlugin.js +50 -24
- package/dist/config/purgecssWebpackPlugin.js +41 -30
- package/dist/config/speedMeasureWebpackPlugin.js +56 -31
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +98 -0
- package/dist/config/svgRules.d.ts +1 -0
- package/dist/config/svgRules.js +68 -41
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +59 -15
- package/dist/dev.d.ts +23 -2
- package/dist/dev.js +198 -81
- package/dist/index.d.ts +6 -1
- package/dist/index.js +31 -15
- package/dist/loader/svgr.d.ts +4 -0
- package/dist/loader/svgr.js +84 -0
- package/dist/loader/swc.d.ts +4 -0
- package/dist/loader/swc.js +149 -0
- package/dist/parcelCSS.d.ts +2 -0
- package/dist/parcelCSS.js +39 -0
- package/dist/plugins/EsbuildMinifyFix.d.ts +8 -0
- package/dist/plugins/EsbuildMinifyFix.js +136 -0
- package/dist/plugins/ProgressPlugin.js +68 -43
- package/dist/plugins/RuntimePublicPathPlugin.d.ts +4 -0
- package/dist/plugins/RuntimePublicPathPlugin.js +45 -0
- package/dist/plugins/_SamplePlugin.d.ts +1 -1
- package/dist/plugins/_SamplePlugin.js +37 -14
- package/dist/requireHook.js +44 -27
- package/dist/schema.d.ts +4 -3
- package/dist/schema.js +175 -69
- package/dist/server/server.d.ts +4 -3
- package/dist/server/server.js +219 -154
- package/dist/server/ws.d.ts +8 -3
- package/dist/server/ws.js +72 -38
- package/dist/swcPlugins/autoCSSModules.d.ts +11 -2
- package/dist/swcPlugins/autoCSSModules.js +60 -32
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +32 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +6 -0
- package/dist/swcPlugins/lockCoreJS.js +56 -0
- package/dist/types.d.ts +53 -9
- package/dist/types.js +61 -29
- package/dist/utils/browsersList.js +31 -8
- package/dist/utils/depMatch.js +65 -39
- package/dist/utils/formatWebpackMessages.js +119 -91
- package/dist/utils/getEsBuildTarget.d.ts +7 -0
- package/dist/utils/getEsBuildTarget.js +46 -0
- package/dist/utils/pkgUpContainsName.d.ts +1 -0
- package/dist/utils/pkgUpContainsName.js +50 -0
- package/package.json +76 -68
- package/compiled/@svgr/webpack/LICENSE +0 -7
- package/compiled/@svgr/webpack/index.js +0 -266
- package/compiled/@svgr/webpack/package.json +0 -1
- 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/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/http-proxy-middleware/LICENSE +0 -22
- package/compiled/http-proxy-middleware/dist/index.d.ts +0 -4
- package/compiled/http-proxy-middleware/dist/types.d.ts +0 -54
- package/compiled/http-proxy-middleware/http-proxy/index.d.ts +0 -226
- package/compiled/http-proxy-middleware/index.js +0 -66
- package/compiled/http-proxy-middleware/package.json +0 -1
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- package/compiled/react-refresh/index.js +0 -19
- package/compiled/swc-loader/LICENSE +0 -25
- package/compiled/swc-loader/index.js +0 -1
- package/compiled/swc-loader/package.json +0 -1
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/dist/client/client.js +0 -239
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -65
- /package/{dist → client}/client/client.d.ts +0 -0
- /package/compiled/{css-loader → file-loader}/LICENSE +0 -0
|
@@ -1,31 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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(${
|
|
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
|
-
|
|
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[
|
|
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
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
identifierCountMap.set(
|
|
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 =
|
|
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 =
|
|
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)) :
|
|
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
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
188
|
+
callback(null, resultSource);
|
|
152
189
|
};
|
|
153
|
-
|
|
154
190
|
let {
|
|
155
191
|
publicPath
|
|
156
|
-
} =
|
|
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 =
|
|
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
|
-
|
|
176
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 = {
|
|
249
|
+
childCompiler.options.module.parser = {
|
|
250
|
+
...childCompiler.options.module.parser
|
|
207
251
|
};
|
|
208
|
-
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(`${
|
|
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(`${
|
|
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
|
-
|
|
331
|
+
callback(error);
|
|
332
|
+
return;
|
|
275
333
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return
|
|
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
|
-
|
|
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 =
|
|
363
|
+
originalExports = evalModuleCode(this, source, request);
|
|
304
364
|
} catch (e) {
|
|
305
|
-
|
|
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
|
-
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
4
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
43
|
-
module
|
|
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
|
-
|
|
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
|
|
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 =
|
|
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 = "";
|
|
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
|
-
|
|
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
|
+
};
|