@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
package/dist/config/config.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Configuration } from '../../compiled/webpack';
|
|
2
2
|
import { Env, IConfig } from '../types';
|
|
3
|
-
interface IOpts {
|
|
3
|
+
export interface IOpts {
|
|
4
4
|
cwd: string;
|
|
5
|
+
rootDir?: string;
|
|
5
6
|
env: Env;
|
|
6
7
|
entry: Record<string, string>;
|
|
7
8
|
extraBabelPresets?: any[];
|
|
8
9
|
extraBabelPlugins?: any[];
|
|
10
|
+
extraBabelIncludes?: Array<string | RegExp>;
|
|
11
|
+
extraEsbuildLoaderHandler?: any[];
|
|
9
12
|
babelPreset?: any;
|
|
10
13
|
chainWebpack?: Function;
|
|
11
14
|
modifyWebpackConfig?: Function;
|
|
@@ -15,6 +18,12 @@ interface IOpts {
|
|
|
15
18
|
userConfig: IConfig;
|
|
16
19
|
analyze?: any;
|
|
17
20
|
name?: string;
|
|
21
|
+
cache?: {
|
|
22
|
+
absNodeModulesPath?: string;
|
|
23
|
+
buildDependencies?: string[];
|
|
24
|
+
cacheDirectory?: string;
|
|
25
|
+
};
|
|
26
|
+
pkg?: Record<string, any>;
|
|
27
|
+
disableCopy?: boolean;
|
|
18
28
|
}
|
|
19
29
|
export declare function getConfig(opts: IOpts): Promise<Configuration>;
|
|
20
|
-
export {};
|
package/dist/config/config.js
CHANGED
|
@@ -1,178 +1,241 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
13
18
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/config/config.ts
|
|
30
|
+
var config_exports = {};
|
|
31
|
+
__export(config_exports, {
|
|
32
|
+
getConfig: () => getConfig
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(config_exports);
|
|
35
|
+
var import_case_sensitive_paths_webpack_plugin = __toESM(require("@umijs/case-sensitive-paths-webpack-plugin"));
|
|
36
|
+
var import_utils = require("@umijs/utils");
|
|
37
|
+
var import_path = require("path");
|
|
38
|
+
var import_webpack = __toESM(require("../../compiled/webpack"));
|
|
39
|
+
var import_webpack_5_chain = __toESM(require("../../compiled/webpack-5-chain"));
|
|
40
|
+
var import_constants = require("../constants");
|
|
41
|
+
var import_RuntimePublicPathPlugin = require("../plugins/RuntimePublicPathPlugin");
|
|
42
|
+
var import_types = require("../types");
|
|
43
|
+
var import_browsersList = require("../utils/browsersList");
|
|
44
|
+
var import_assetRules = require("./assetRules");
|
|
45
|
+
var import_bundleAnalyzerPlugin = require("./bundleAnalyzerPlugin");
|
|
46
|
+
var import_compressPlugin = require("./compressPlugin");
|
|
47
|
+
var import_copyPlugin = require("./copyPlugin");
|
|
48
|
+
var import_cssRules = require("./cssRules");
|
|
49
|
+
var import_definePlugin = require("./definePlugin");
|
|
50
|
+
var import_detectCssModulesInDependence = require("./detectCssModulesInDependence");
|
|
51
|
+
var import_detectDeadCodePlugin = require("./detectDeadCodePlugin");
|
|
52
|
+
var import_fastRefreshPlugin = require("./fastRefreshPlugin");
|
|
53
|
+
var import_forkTSCheckerPlugin = require("./forkTSCheckerPlugin");
|
|
54
|
+
var import_harmonyLinkingErrorPlugin = require("./harmonyLinkingErrorPlugin");
|
|
55
|
+
var import_ignorePlugin = require("./ignorePlugin");
|
|
56
|
+
var import_javaScriptRules = require("./javaScriptRules");
|
|
57
|
+
var import_manifestPlugin = require("./manifestPlugin");
|
|
58
|
+
var import_miniCSSExtractPlugin = require("./miniCSSExtractPlugin");
|
|
59
|
+
var import_nodePolyfill = require("./nodePolyfill");
|
|
60
|
+
var import_progressPlugin = require("./progressPlugin");
|
|
61
|
+
var import_speedMeasureWebpackPlugin = require("./speedMeasureWebpackPlugin");
|
|
62
|
+
var import_ssrPlugin = __toESM(require("./ssrPlugin"));
|
|
63
|
+
var import_svgRules = require("./svgRules");
|
|
64
|
+
async function getConfig(opts) {
|
|
65
|
+
var _a, _b, _c;
|
|
66
|
+
const { userConfig } = opts;
|
|
67
|
+
const isDev = opts.env === import_types.Env.development;
|
|
68
|
+
const config = new import_webpack_5_chain.default();
|
|
69
|
+
userConfig.targets || (userConfig.targets = import_constants.DEFAULT_BROWSER_TARGETS);
|
|
70
|
+
userConfig.inlineLimit = parseInt(userConfig.inlineLimit || "10000", 10);
|
|
71
|
+
const useHash = !!(opts.hash || userConfig.hash && !isDev);
|
|
72
|
+
const applyOpts = {
|
|
73
|
+
name: opts.name,
|
|
74
|
+
config,
|
|
75
|
+
userConfig,
|
|
76
|
+
cwd: opts.cwd,
|
|
77
|
+
env: opts.env,
|
|
78
|
+
babelPreset: opts.babelPreset,
|
|
79
|
+
extraBabelPlugins: opts.extraBabelPlugins || [],
|
|
80
|
+
extraBabelPresets: opts.extraBabelPresets || [],
|
|
81
|
+
extraBabelIncludes: opts.extraBabelIncludes || [],
|
|
82
|
+
extraEsbuildLoaderHandler: opts.extraEsbuildLoaderHandler || [],
|
|
83
|
+
browsers: (0, import_browsersList.getBrowsersList)({
|
|
84
|
+
targets: userConfig.targets
|
|
85
|
+
}),
|
|
86
|
+
useHash,
|
|
87
|
+
staticPathPrefix: opts.staticPathPrefix !== void 0 ? opts.staticPathPrefix : "static/"
|
|
88
|
+
};
|
|
89
|
+
config.name(opts.name);
|
|
90
|
+
config.mode(opts.env);
|
|
91
|
+
config.stats("none");
|
|
92
|
+
Object.keys(opts.entry).forEach((key) => {
|
|
93
|
+
const entry = config.entry(key);
|
|
94
|
+
if (isDev && opts.hmr) {
|
|
95
|
+
entry.add(require.resolve("../../client/client/client"));
|
|
96
|
+
}
|
|
97
|
+
entry.add(opts.entry[key]);
|
|
98
|
+
});
|
|
99
|
+
config.devtool(
|
|
100
|
+
isDev ? userConfig.devtool === false ? false : userConfig.devtool || import_constants.DEFAULT_DEVTOOL : userConfig.devtool
|
|
101
|
+
);
|
|
102
|
+
const absOutputPath = (0, import_path.resolve)(
|
|
103
|
+
opts.cwd,
|
|
104
|
+
userConfig.outputPath || import_constants.DEFAULT_OUTPUT_PATH
|
|
105
|
+
);
|
|
106
|
+
const disableCompress = process.env.COMPRESS === "none";
|
|
107
|
+
config.output.path(absOutputPath).filename(useHash ? `[name].[contenthash:8].js` : `[name].js`).chunkFilename(
|
|
108
|
+
useHash ? `[name].[contenthash:8].async.js` : `[name].async.js`
|
|
109
|
+
).publicPath(userConfig.publicPath || "auto").pathinfo(isDev || disableCompress).set(
|
|
110
|
+
"assetModuleFilename",
|
|
111
|
+
`${applyOpts.staticPathPrefix}[name].[hash:8][ext]`
|
|
112
|
+
).set("hashFunction", "xxhash64");
|
|
113
|
+
config.resolve.set("symlinks", true).modules.add("node_modules").end().alias.merge(userConfig.alias || {}).end().extensions.merge([
|
|
114
|
+
".ts",
|
|
115
|
+
".tsx",
|
|
116
|
+
".js",
|
|
117
|
+
".jsx",
|
|
118
|
+
".mjs",
|
|
119
|
+
".cjs",
|
|
120
|
+
".json",
|
|
121
|
+
".wasm"
|
|
122
|
+
]).end();
|
|
123
|
+
config.externals(userConfig.externals || []);
|
|
124
|
+
config.target(["web", "es5"]);
|
|
125
|
+
config.experiments({
|
|
126
|
+
topLevelAwait: true,
|
|
127
|
+
outputModule: !!userConfig.esm
|
|
128
|
+
});
|
|
129
|
+
await (0, import_nodePolyfill.addNodePolyfill)(applyOpts);
|
|
130
|
+
await (0, import_javaScriptRules.addJavaScriptRules)(applyOpts);
|
|
131
|
+
await (0, import_cssRules.addCSSRules)(applyOpts);
|
|
132
|
+
await (0, import_assetRules.addAssetRules)(applyOpts);
|
|
133
|
+
await (0, import_svgRules.addSVGRules)(applyOpts);
|
|
134
|
+
await (0, import_miniCSSExtractPlugin.addMiniCSSExtractPlugin)(applyOpts);
|
|
135
|
+
await (0, import_ignorePlugin.addIgnorePlugin)(applyOpts);
|
|
136
|
+
await (0, import_definePlugin.addDefinePlugin)(applyOpts);
|
|
137
|
+
await (0, import_fastRefreshPlugin.addFastRefreshPlugin)(applyOpts);
|
|
138
|
+
await (0, import_progressPlugin.addProgressPlugin)(applyOpts);
|
|
139
|
+
await (0, import_detectDeadCodePlugin.addDetectDeadCodePlugin)(applyOpts);
|
|
140
|
+
await (0, import_forkTSCheckerPlugin.addForkTSCheckerPlugin)(applyOpts);
|
|
141
|
+
if (!opts.disableCopy) {
|
|
142
|
+
await (0, import_copyPlugin.addCopyPlugin)(applyOpts);
|
|
143
|
+
}
|
|
144
|
+
await (0, import_manifestPlugin.addManifestPlugin)(applyOpts);
|
|
145
|
+
if (isDev && opts.hmr) {
|
|
146
|
+
config.plugin("hmr").use(import_webpack.default.HotModuleReplacementPlugin);
|
|
147
|
+
}
|
|
148
|
+
await (0, import_ssrPlugin.default)(applyOpts);
|
|
149
|
+
await (0, import_compressPlugin.addCompressPlugin)(applyOpts);
|
|
150
|
+
await (0, import_harmonyLinkingErrorPlugin.addHarmonyLinkingErrorPlugin)(applyOpts);
|
|
151
|
+
await (0, import_detectCssModulesInDependence.addDependenceCssModulesDetector)(applyOpts);
|
|
152
|
+
if (userConfig.runtimePublicPath) {
|
|
153
|
+
config.plugin("runtimePublicPath").use(import_RuntimePublicPathPlugin.RuntimePublicPathPlugin);
|
|
154
|
+
}
|
|
155
|
+
config.plugin("case-sensitive-paths").use(import_case_sensitive_paths_webpack_plugin.default);
|
|
156
|
+
if (opts.cache) {
|
|
157
|
+
config.cache({
|
|
158
|
+
type: "filesystem",
|
|
159
|
+
version: require("../../package.json").version,
|
|
160
|
+
buildDependencies: {
|
|
161
|
+
config: opts.cache.buildDependencies || []
|
|
162
|
+
},
|
|
163
|
+
cacheDirectory: opts.cache.cacheDirectory || // 使用 rootDir 是在有 APP_ROOT 时,把 cache 目录放在根目录下
|
|
164
|
+
(0, import_path.join)(
|
|
165
|
+
opts.rootDir || opts.cwd,
|
|
166
|
+
"node_modules",
|
|
167
|
+
".cache",
|
|
168
|
+
"bundler-webpack"
|
|
169
|
+
)
|
|
170
|
+
});
|
|
171
|
+
if (require.resolve("@umijs/utils/package").includes("_@umijs_utils@")) {
|
|
172
|
+
const nodeModulesPath = opts.cache.absNodeModulesPath || (0, import_path.join)(opts.rootDir || opts.cwd, "node_modules");
|
|
173
|
+
const localLinkedNodeModules = Object.keys(
|
|
174
|
+
Object.assign(
|
|
175
|
+
{},
|
|
176
|
+
(_a = opts.pkg) == null ? void 0 : _a.dependencies,
|
|
177
|
+
(_b = opts.pkg) == null ? void 0 : _b.peerDependencies,
|
|
178
|
+
(_c = opts.pkg) == null ? void 0 : _c.devDependencies
|
|
179
|
+
)
|
|
180
|
+
).map((pkg) => {
|
|
181
|
+
try {
|
|
182
|
+
return (0, import_path.resolve)(
|
|
183
|
+
import_utils.resolve.sync(`${pkg}/package.json`, {
|
|
184
|
+
basedir: opts.rootDir || opts.cwd,
|
|
185
|
+
preserveSymlinks: false
|
|
55
186
|
}),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
config.stats('none');
|
|
61
|
-
// entry
|
|
62
|
-
Object.keys(opts.entry).forEach((key) => {
|
|
63
|
-
const entry = config.entry(key);
|
|
64
|
-
// TODO: runtimePublicPath
|
|
65
|
-
if (isDev && opts.hmr) {
|
|
66
|
-
entry.add(require.resolve('../../client/client/client'));
|
|
67
|
-
}
|
|
68
|
-
entry.add(opts.entry[key]);
|
|
69
|
-
});
|
|
70
|
-
// devtool
|
|
71
|
-
config.devtool(isDev
|
|
72
|
-
? userConfig.devtool === false
|
|
73
|
-
? false
|
|
74
|
-
: userConfig.devtool || constants_1.DEFAULT_DEVTOOL
|
|
75
|
-
: userConfig.devtool);
|
|
76
|
-
// output
|
|
77
|
-
const absOutputPath = (0, path_1.join)(opts.cwd, userConfig.outputPath || constants_1.DEFAULT_OUTPUT_PATH);
|
|
78
|
-
const useHash = opts.hash || (userConfig.hash && !isDev);
|
|
79
|
-
const disableCompress = process.env.COMPRESS === 'none';
|
|
80
|
-
config.output
|
|
81
|
-
.path(absOutputPath)
|
|
82
|
-
.filename(useHash ? `[name].[contenthash:8].js` : `[name].js`)
|
|
83
|
-
.chunkFilename(useHash ? `[name].[contenthash:8].async.js` : `[name].js`)
|
|
84
|
-
.publicPath(userConfig.publicPath || 'auto')
|
|
85
|
-
.pathinfo(isDev || disableCompress);
|
|
86
|
-
// resolve
|
|
87
|
-
// prettier-ignore
|
|
88
|
-
config.resolve
|
|
89
|
-
.set('symlinks', true)
|
|
90
|
-
.modules
|
|
91
|
-
.add('node_modules')
|
|
92
|
-
.end()
|
|
93
|
-
.alias
|
|
94
|
-
.merge(userConfig.alias || {})
|
|
95
|
-
.end()
|
|
96
|
-
.extensions
|
|
97
|
-
.merge([
|
|
98
|
-
'.wasm',
|
|
99
|
-
'.mjs',
|
|
100
|
-
'.js',
|
|
101
|
-
'.jsx',
|
|
102
|
-
'.ts',
|
|
103
|
-
'.tsx',
|
|
104
|
-
'.json'
|
|
105
|
-
])
|
|
106
|
-
.end();
|
|
107
|
-
// externals
|
|
108
|
-
config.externals(userConfig.externals || []);
|
|
109
|
-
// target
|
|
110
|
-
config.target(['web', 'es5']);
|
|
111
|
-
// experiments
|
|
112
|
-
config.experiments({
|
|
113
|
-
topLevelAwait: true,
|
|
114
|
-
outputModule: !!userConfig.esm,
|
|
115
|
-
});
|
|
116
|
-
// node polyfill
|
|
117
|
-
yield (0, nodePolyfill_1.addNodePolyfill)(applyOpts);
|
|
118
|
-
// rules
|
|
119
|
-
yield (0, javaScriptRules_1.addJavaScriptRules)(applyOpts);
|
|
120
|
-
yield (0, cssRules_1.addCSSRules)(applyOpts);
|
|
121
|
-
yield (0, assetRules_1.addAssetRules)(applyOpts);
|
|
122
|
-
yield (0, svgRules_1.addSVGRules)(applyOpts);
|
|
123
|
-
// plugins
|
|
124
|
-
// mini-css-extract-plugin
|
|
125
|
-
yield (0, miniCSSExtractPlugin_1.addMiniCSSExtractPlugin)(applyOpts);
|
|
126
|
-
// ignoreMomentLocale
|
|
127
|
-
yield (0, ignorePlugin_1.addIgnorePlugin)(applyOpts);
|
|
128
|
-
// define
|
|
129
|
-
yield (0, definePlugin_1.addDefinePlugin)(applyOpts);
|
|
130
|
-
// fast refresh
|
|
131
|
-
yield (0, fastRefreshPlugin_1.addFastRefreshPlugin)(applyOpts);
|
|
132
|
-
// progress
|
|
133
|
-
yield (0, progressPlugin_1.addProgressPlugin)(applyOpts);
|
|
134
|
-
// copy
|
|
135
|
-
yield (0, copyPlugin_1.addCopyPlugin)(applyOpts);
|
|
136
|
-
// TODO: friendly-error
|
|
137
|
-
// TODO: manifest
|
|
138
|
-
// hmr
|
|
139
|
-
if (isDev && opts.hmr) {
|
|
140
|
-
config.plugin('hmr').use(webpack_1.default.HotModuleReplacementPlugin);
|
|
141
|
-
}
|
|
142
|
-
// compress
|
|
143
|
-
yield (0, compressPlugin_1.addCompressPlugin)(applyOpts);
|
|
144
|
-
// purgecss
|
|
145
|
-
// await applyPurgeCSSWebpackPlugin(applyOpts);
|
|
146
|
-
// analyzer
|
|
147
|
-
if (opts.analyze) {
|
|
148
|
-
yield (0, bundleAnalyzerPlugin_1.addBundleAnalyzerPlugin)(applyOpts);
|
|
149
|
-
}
|
|
150
|
-
// chain webpack
|
|
151
|
-
if (opts.chainWebpack) {
|
|
152
|
-
yield opts.chainWebpack(config, {
|
|
153
|
-
env: opts.env,
|
|
154
|
-
webpack: webpack_1.default,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
if (userConfig.chainWebpack) {
|
|
158
|
-
yield userConfig.chainWebpack(config, {
|
|
159
|
-
env: opts.env,
|
|
160
|
-
webpack: webpack_1.default,
|
|
161
|
-
});
|
|
187
|
+
"../node_modules"
|
|
188
|
+
);
|
|
189
|
+
} catch {
|
|
190
|
+
return opts.rootDir || opts.cwd;
|
|
162
191
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
192
|
+
}).filter((pkg) => !pkg.startsWith(opts.rootDir || opts.cwd));
|
|
193
|
+
if (localLinkedNodeModules.length) {
|
|
194
|
+
import_utils.logger.info(
|
|
195
|
+
`Detected local linked tnpm node_modules, to avoid oom, they will be treated as immutablePaths & managedPaths in webpack snapshot:`
|
|
196
|
+
);
|
|
197
|
+
localLinkedNodeModules.forEach((p) => import_utils.logger.info(` ${p}`));
|
|
198
|
+
}
|
|
199
|
+
config.snapshot({
|
|
200
|
+
immutablePaths: [nodeModulesPath, ...localLinkedNodeModules],
|
|
201
|
+
managedPaths: [nodeModulesPath, ...localLinkedNodeModules]
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
config.infrastructureLogging({
|
|
205
|
+
level: "error",
|
|
206
|
+
...process.env.WEBPACK_FS_CACHE_DEBUG ? {
|
|
207
|
+
debug: /webpack\.cache/
|
|
208
|
+
} : {}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if (opts.analyze) {
|
|
212
|
+
await (0, import_bundleAnalyzerPlugin.addBundleAnalyzerPlugin)(applyOpts);
|
|
213
|
+
}
|
|
214
|
+
if (opts.chainWebpack) {
|
|
215
|
+
await opts.chainWebpack(config, {
|
|
216
|
+
env: opts.env,
|
|
217
|
+
webpack: import_webpack.default
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (userConfig.chainWebpack) {
|
|
221
|
+
await userConfig.chainWebpack(config, {
|
|
222
|
+
env: opts.env,
|
|
223
|
+
webpack: import_webpack.default
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
let webpackConfig = config.toConfig();
|
|
227
|
+
webpackConfig = await (0, import_speedMeasureWebpackPlugin.addSpeedMeasureWebpackPlugin)({
|
|
228
|
+
webpackConfig
|
|
229
|
+
});
|
|
230
|
+
if (opts.modifyWebpackConfig) {
|
|
231
|
+
webpackConfig = await opts.modifyWebpackConfig(webpackConfig, {
|
|
232
|
+
env: opts.env,
|
|
233
|
+
webpack: import_webpack.default
|
|
176
234
|
});
|
|
235
|
+
}
|
|
236
|
+
return webpackConfig;
|
|
177
237
|
}
|
|
178
|
-
|
|
238
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
239
|
+
0 && (module.exports = {
|
|
240
|
+
getConfig
|
|
241
|
+
});
|
|
@@ -1,49 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/config/copyPlugin.ts
|
|
20
|
+
var copyPlugin_exports = {};
|
|
21
|
+
__export(copyPlugin_exports, {
|
|
22
|
+
addCopyPlugin: () => addCopyPlugin
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(copyPlugin_exports);
|
|
25
|
+
var import_fs = require("fs");
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
async function addCopyPlugin(opts) {
|
|
28
|
+
var _a;
|
|
29
|
+
const { config, userConfig, cwd } = opts;
|
|
30
|
+
const publicDir = (0, import_path.join)(cwd, "public");
|
|
31
|
+
const copyPatterns = [
|
|
32
|
+
(0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length && {
|
|
33
|
+
from: publicDir,
|
|
34
|
+
// ref: https://github.com/webpack-contrib/copy-webpack-plugin#info
|
|
35
|
+
// Set minimized so terser will not do minimize
|
|
36
|
+
info: { minimized: true }
|
|
37
|
+
},
|
|
38
|
+
...userConfig.copy ? (_a = userConfig.copy) == null ? void 0 : _a.map((pattern) => {
|
|
39
|
+
if (typeof pattern === "string") {
|
|
40
|
+
return {
|
|
41
|
+
from: (0, import_path.resolve)(cwd, pattern),
|
|
42
|
+
info: { minimized: true }
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
from: (0, import_path.resolve)(cwd, pattern.from),
|
|
47
|
+
to: (0, import_path.resolve)(cwd, pattern.to),
|
|
48
|
+
info: { minimized: true }
|
|
49
|
+
};
|
|
50
|
+
}) : []
|
|
51
|
+
].filter(Boolean);
|
|
52
|
+
if (copyPatterns.length) {
|
|
53
|
+
config.plugin("copy").use(require("@umijs/bundler-webpack/compiled/copy-webpack-plugin"), [
|
|
54
|
+
{
|
|
55
|
+
patterns: copyPatterns
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
48
59
|
}
|
|
49
|
-
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
addCopyPlugin
|
|
63
|
+
});
|