@umijs/bundler-webpack 4.0.0-rc.7 → 4.0.0
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 +65 -37
- package/client/constants.js +9 -0
- package/compiled/babel-loader/index.js +2 -2
- package/compiled/copy-webpack-plugin/{576.index.js → 939.index.js} +11 -11
- package/compiled/copy-webpack-plugin/index.js +12 -12
- package/compiled/css-minimizer-webpack-plugin/index.js +7 -7
- package/compiled/cssnano/index.js +6 -6
- package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
- package/compiled/{tapable → react-refresh}/LICENSE +6 -6
- package/compiled/react-refresh/index.js +9 -7
- package/compiled/react-refresh/package.json +1 -0
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +6 -1
- package/compiled/webpack/index.js +3978 -3167
- package/compiled/webpack/types.d.ts +606 -171
- package/compiled/webpack-dev-middleware/index.js +8 -7
- package/compiled/webpack-manifest-plugin/index.js +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.js +49 -56
- package/dist/cli.js +6 -15
- package/dist/client/client.js +52 -50
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +44 -55
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +89 -70
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +181 -179
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +114 -83
- package/dist/config/definePlugin.js +11 -19
- package/dist/config/detectDeadCodePlugin.js +16 -21
- package/dist/config/fastRefreshPlugin.js +11 -22
- package/dist/config/forkTSCheckerPlugin.js +11 -22
- package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
- package/dist/config/ignorePlugin.js +10 -21
- package/dist/config/javaScriptRules.d.ts +1 -0
- package/dist/config/javaScriptRules.js +152 -135
- package/dist/config/manifestPlugin.d.ts +1 -1
- package/dist/config/manifestPlugin.js +10 -18
- package/dist/config/miniCSSExtractPlugin.js +15 -23
- package/dist/config/nodePolyfill.js +14 -20
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +14 -0
- package/dist/config/progressPlugin.js +7 -18
- package/dist/config/purgecssWebpackPlugin.js +15 -26
- package/dist/config/speedMeasureWebpackPlugin.js +12 -23
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +66 -0
- package/dist/config/svgRules.js +44 -47
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +7 -1
- package/dist/dev.d.ts +4 -0
- package/dist/dev.js +115 -94
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -0
- package/dist/loader/svgr.js +4 -13
- package/dist/loader/swc.js +9 -14
- package/dist/plugins/ProgressPlugin.js +3 -3
- package/dist/plugins/RuntimePublicPathPlugin.js +4 -1
- package/dist/schema.js +24 -8
- package/dist/server/server.d.ts +3 -1
- package/dist/server/server.js +165 -150
- package/dist/server/ws.d.ts +7 -2
- package/dist/swcPlugins/autoCSSModules.js +3 -1
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +10 -0
- package/dist/swcPlugins/lockCoreJS.js +3 -2
- package/dist/types.d.ts +3 -0
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +23 -21
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -63
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +0 -10
- package/dist/plugins/ParcelCSSMinifyPlugin.js +0 -75
|
@@ -1,163 +1,180 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addJavaScriptRules = void 0;
|
|
13
4
|
const mfsu_1 = require("@umijs/mfsu");
|
|
14
5
|
const utils_1 = require("@umijs/utils");
|
|
6
|
+
const path_1 = require("path");
|
|
15
7
|
const webpack_1 = require("../../compiled/webpack");
|
|
16
8
|
const constants_1 = require("../constants");
|
|
17
9
|
const types_1 = require("../types");
|
|
18
10
|
const depMatch_1 = require("../utils/depMatch");
|
|
19
|
-
function addJavaScriptRules(opts) {
|
|
11
|
+
async function addJavaScriptRules(opts) {
|
|
20
12
|
var _a, _b;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
13
|
+
const { config, userConfig, cwd, name } = opts;
|
|
14
|
+
const isDev = opts.env === types_1.Env.development;
|
|
15
|
+
const useFastRefresh = isDev && userConfig.fastRefresh !== false && name !== constants_1.MFSU_NAME;
|
|
16
|
+
const depPkgs = Object.assign({}, (0, depMatch_1.es5ImcompatibleVersionsToPkg)());
|
|
17
|
+
const srcRules = [
|
|
18
|
+
config.module
|
|
19
|
+
.rule('src')
|
|
20
|
+
.test(/\.(js|mjs)$/)
|
|
21
|
+
.include.add([
|
|
22
|
+
cwd,
|
|
23
|
+
// import module out of cwd using APP_ROOT
|
|
24
|
+
// issue: https://github.com/umijs/umi/issues/5594
|
|
25
|
+
...(process.env.APP_ROOT ? [process.cwd()] : []),
|
|
26
|
+
])
|
|
27
|
+
.end()
|
|
28
|
+
.exclude.add(/node_modules/)
|
|
29
|
+
.end(),
|
|
30
|
+
config.module.rule('jsx-ts-tsx').test(/\.(jsx|ts|tsx)$/),
|
|
31
|
+
config.module
|
|
32
|
+
.rule('extra-src')
|
|
33
|
+
.test(/\.(js|mjs)$/)
|
|
34
|
+
.include.add([
|
|
35
|
+
// support extraBabelIncludes
|
|
36
|
+
...opts.extraBabelIncludes.map((p) => {
|
|
37
|
+
// handle absolute path
|
|
38
|
+
if ((0, path_1.isAbsolute)(p)) {
|
|
39
|
+
return p;
|
|
40
|
+
}
|
|
41
|
+
// resolve npm package name
|
|
44
42
|
try {
|
|
45
|
-
if (
|
|
46
|
-
return
|
|
47
|
-
|
|
43
|
+
if (p.startsWith('./')) {
|
|
44
|
+
return require.resolve(p, { paths: [cwd] });
|
|
45
|
+
}
|
|
46
|
+
return (0, path_1.dirname)(require.resolve(`${p}/package.json`, { paths: [cwd] }));
|
|
48
47
|
}
|
|
49
48
|
catch (e) {
|
|
50
|
-
|
|
49
|
+
if (e.code === 'MODULE_NOT_FOUND') {
|
|
50
|
+
throw new Error('Cannot resolve extraBabelIncludes: ' + p);
|
|
51
|
+
}
|
|
51
52
|
throw e;
|
|
52
53
|
}
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (userConfig.mdx) {
|
|
57
|
-
srcRules.push(config.module.rule('markdown').test(/\.mdx?$/));
|
|
58
|
-
}
|
|
59
|
-
const depRules = [
|
|
60
|
-
config.module
|
|
61
|
-
.rule('dep')
|
|
62
|
-
.test(/\.(js|mjs)$/)
|
|
63
|
-
.include.add(/node_modules/)
|
|
64
|
-
.end()
|
|
65
|
-
.exclude.add((path) => {
|
|
54
|
+
}),
|
|
55
|
+
// support es5ImcompatibleVersions
|
|
56
|
+
(path) => {
|
|
66
57
|
try {
|
|
58
|
+
// do src transform for bundler-webpack/client/client/client.js
|
|
59
|
+
if (path.includes('client/client/client'))
|
|
60
|
+
return true;
|
|
67
61
|
return (0, depMatch_1.isMatch)({ path, pkgs: depPkgs });
|
|
68
62
|
}
|
|
69
63
|
catch (e) {
|
|
70
64
|
console.error(utils_1.chalk.red(e));
|
|
71
65
|
throw e;
|
|
72
66
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
srcRules.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// process.env.BABEL_CACHE !== 'none'
|
|
90
|
-
// ? join(cwd, `.umi/.cache/babel-loader`)
|
|
91
|
-
// : false,
|
|
92
|
-
targets: userConfig.targets,
|
|
93
|
-
presets: [
|
|
94
|
-
opts.babelPreset || [
|
|
95
|
-
require.resolve('@umijs/babel-preset-umi'),
|
|
96
|
-
{
|
|
97
|
-
presetEnv: {},
|
|
98
|
-
presetReact: {},
|
|
99
|
-
presetTypeScript: {},
|
|
100
|
-
pluginTransformRuntime: {},
|
|
101
|
-
pluginLockCoreJS: {},
|
|
102
|
-
pluginDynamicImportNode: false,
|
|
103
|
-
pluginAutoCSSModules: userConfig.autoCSSModules,
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
...opts.extraBabelPresets,
|
|
107
|
-
...(userConfig.extraBabelPresets || []).filter(Boolean),
|
|
108
|
-
],
|
|
109
|
-
plugins: [
|
|
110
|
-
useFastRefresh && require.resolve('react-refresh/babel'),
|
|
111
|
-
...opts.extraBabelPlugins,
|
|
112
|
-
...(userConfig.extraBabelPlugins || []),
|
|
113
|
-
].filter(Boolean),
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
else if (srcTranspiler === types_1.Transpiler.swc) {
|
|
117
|
-
const AutoCSSModule = require('../swcPlugins/autoCSSModules').default;
|
|
118
|
-
rule
|
|
119
|
-
.use('swc-loader')
|
|
120
|
-
.loader(require.resolve('../loader/swc'))
|
|
121
|
-
.options({
|
|
122
|
-
plugin: (m) => new AutoCSSModule().visitProgram(m),
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
else if (srcTranspiler === types_1.Transpiler.esbuild) {
|
|
126
|
-
rule
|
|
127
|
-
.use('esbuild-loader')
|
|
128
|
-
.loader(mfsu_1.esbuildLoader)
|
|
129
|
-
.options({
|
|
130
|
-
target: isDev ? 'esnext' : 'es2015',
|
|
131
|
-
handler: [mfsu_1.autoCssModulesHandler, ...opts.extraEsbuildLoaderHandler],
|
|
132
|
-
});
|
|
133
|
-
// esbuild loader can not auto import `React`
|
|
134
|
-
config.plugin('react-provide-plugin').use(webpack_1.ProvidePlugin, [
|
|
135
|
-
{
|
|
136
|
-
React: 'react',
|
|
137
|
-
},
|
|
138
|
-
]);
|
|
67
|
+
},
|
|
68
|
+
])
|
|
69
|
+
.end(),
|
|
70
|
+
];
|
|
71
|
+
if (userConfig.mdx) {
|
|
72
|
+
srcRules.push(config.module.rule('markdown').test(/\.mdx?$/));
|
|
73
|
+
}
|
|
74
|
+
const depRules = [
|
|
75
|
+
config.module
|
|
76
|
+
.rule('dep')
|
|
77
|
+
.test(/\.(js|mjs)$/)
|
|
78
|
+
.include.add(/node_modules/)
|
|
79
|
+
.end()
|
|
80
|
+
.exclude.add((path) => {
|
|
81
|
+
try {
|
|
82
|
+
return (0, depMatch_1.isMatch)({ path, pkgs: depPkgs });
|
|
139
83
|
}
|
|
140
|
-
|
|
141
|
-
|
|
84
|
+
catch (e) {
|
|
85
|
+
console.error(utils_1.chalk.red(e));
|
|
86
|
+
throw e;
|
|
142
87
|
}
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
88
|
+
})
|
|
89
|
+
.end(),
|
|
90
|
+
];
|
|
91
|
+
srcRules
|
|
92
|
+
.concat(depRules)
|
|
93
|
+
.forEach((rule) => rule.resolve.set('fullySpecified', false));
|
|
94
|
+
// const prefix = existsSync(join(cwd, 'src')) ? join(cwd, 'src') : cwd;
|
|
95
|
+
const srcTranspiler = userConfig.srcTranspiler || types_1.Transpiler.babel;
|
|
96
|
+
srcRules.forEach((rule) => {
|
|
97
|
+
if (srcTranspiler === types_1.Transpiler.babel) {
|
|
98
|
+
rule
|
|
99
|
+
.use('babel-loader')
|
|
100
|
+
.loader(require.resolve('../../compiled/babel-loader'))
|
|
101
|
+
.options({
|
|
102
|
+
// Tell babel to guess the type, instead assuming all files are modules
|
|
103
|
+
// https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
|
|
104
|
+
sourceType: 'unambiguous',
|
|
105
|
+
babelrc: false,
|
|
106
|
+
cacheDirectory: false,
|
|
107
|
+
// process.env.BABEL_CACHE !== 'none'
|
|
108
|
+
// ? join(cwd, `.umi/.cache/babel-loader`)
|
|
109
|
+
// : false,
|
|
110
|
+
targets: userConfig.targets,
|
|
111
|
+
presets: [
|
|
112
|
+
opts.babelPreset || [
|
|
113
|
+
require.resolve('@umijs/babel-preset-umi'),
|
|
114
|
+
{
|
|
115
|
+
presetEnv: {},
|
|
116
|
+
presetReact: {},
|
|
117
|
+
presetTypeScript: {},
|
|
118
|
+
pluginTransformRuntime: {},
|
|
119
|
+
pluginLockCoreJS: {},
|
|
120
|
+
pluginDynamicImportNode: false,
|
|
121
|
+
pluginAutoCSSModules: userConfig.autoCSSModules,
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
...opts.extraBabelPresets,
|
|
125
|
+
...(userConfig.extraBabelPresets || []).filter(Boolean),
|
|
126
|
+
],
|
|
127
|
+
plugins: [
|
|
128
|
+
useFastRefresh && require.resolve('react-refresh/babel'),
|
|
129
|
+
...opts.extraBabelPlugins,
|
|
130
|
+
...(userConfig.extraBabelPlugins || []),
|
|
131
|
+
].filter(Boolean),
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
else if (srcTranspiler === types_1.Transpiler.swc) {
|
|
135
|
+
const AutoCSSModule = require('../swcPlugins/autoCSSModules').default;
|
|
136
|
+
rule
|
|
137
|
+
.use('swc-loader')
|
|
138
|
+
.loader(require.resolve('../loader/swc'))
|
|
139
|
+
.options({
|
|
140
|
+
plugin: (m) => new AutoCSSModule().visitProgram(m),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
else if (srcTranspiler === types_1.Transpiler.esbuild) {
|
|
144
|
+
rule
|
|
145
|
+
.use('esbuild-loader')
|
|
146
|
+
.loader(mfsu_1.esbuildLoader)
|
|
147
|
+
.options({
|
|
148
|
+
target: isDev ? 'esnext' : 'es2015',
|
|
149
|
+
handler: [mfsu_1.autoCssModulesHandler, ...opts.extraEsbuildLoaderHandler],
|
|
150
|
+
});
|
|
151
|
+
// esbuild loader can not auto import `React`
|
|
152
|
+
config.plugin('react-provide-plugin').use(webpack_1.ProvidePlugin, [
|
|
153
|
+
{
|
|
154
|
+
React: 'react',
|
|
155
|
+
},
|
|
156
|
+
]);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error(`Unsupported srcTranspiler ${srcTranspiler}.`);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
if (userConfig.mdx) {
|
|
163
|
+
config.module
|
|
164
|
+
.rule('mdx')
|
|
165
|
+
.test(/\.mdx?$/)
|
|
166
|
+
.use('mdx-loader')
|
|
167
|
+
.loader((_a = userConfig.mdx) === null || _a === void 0 ? void 0 : _a.loader)
|
|
168
|
+
.options((_b = userConfig.mdx) === null || _b === void 0 ? void 0 : _b.loaderOptions);
|
|
169
|
+
}
|
|
170
|
+
const depTranspiler = userConfig.depTranspiler || types_1.Transpiler.none;
|
|
171
|
+
depRules.forEach((_rule) => {
|
|
172
|
+
if (depTranspiler === types_1.Transpiler.none) {
|
|
173
|
+
// noop
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
throw new Error(`Unsupported depTranspiler ${depTranspiler}.`);
|
|
151
177
|
}
|
|
152
|
-
const depTranspiler = userConfig.depTranspiler || types_1.Transpiler.none;
|
|
153
|
-
depRules.forEach((_rule) => {
|
|
154
|
-
if (depTranspiler === types_1.Transpiler.none) {
|
|
155
|
-
// noop
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
throw new Error(`Unsupported depTranspiler ${depTranspiler}.`);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
178
|
});
|
|
162
179
|
}
|
|
163
180
|
exports.addJavaScriptRules = addJavaScriptRules;
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addManifestPlugin = void 0;
|
|
13
4
|
// @ts-ignore
|
|
14
5
|
const webpack_manifest_plugin_1 = require("@umijs/bundler-webpack/compiled/webpack-manifest-plugin");
|
|
15
|
-
function addManifestPlugin(opts) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
async function addManifestPlugin(opts) {
|
|
7
|
+
const { config, userConfig } = opts;
|
|
8
|
+
if (userConfig.manifest) {
|
|
9
|
+
config.plugin('manifest-plugin').use(webpack_manifest_plugin_1.WebpackManifestPlugin, [
|
|
10
|
+
{
|
|
11
|
+
fileName: 'asset-manifest.json',
|
|
12
|
+
...userConfig.manifest,
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
24
16
|
}
|
|
25
17
|
exports.addManifestPlugin = addManifestPlugin;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,19 +6,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.addMiniCSSExtractPlugin = void 0;
|
|
16
7
|
// @ts-ignore
|
|
17
8
|
const mini_css_extract_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/mini-css-extract-plugin"));
|
|
18
|
-
function addMiniCSSExtractPlugin(opts) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
async function addMiniCSSExtractPlugin(opts) {
|
|
10
|
+
const { config, userConfig, useHash } = opts;
|
|
11
|
+
const hash = useHash ? '.[contenthash:8]' : '';
|
|
12
|
+
if (!userConfig.styleLoader) {
|
|
13
|
+
config.plugin('mini-css-extract-plugin').use(mini_css_extract_plugin_1.default, [
|
|
14
|
+
{
|
|
15
|
+
filename: `[name]${hash}.css`,
|
|
16
|
+
chunkFilename: opts.userConfig.ssr
|
|
17
|
+
? // TODO: FIXME
|
|
18
|
+
`umi${hash}.css`
|
|
19
|
+
: `[name]${hash}.chunk.css`,
|
|
20
|
+
ignoreOrder: true,
|
|
21
|
+
},
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
32
24
|
}
|
|
33
25
|
exports.addMiniCSSExtractPlugin = addMiniCSSExtractPlugin;
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.addNodePolyfill = void 0;
|
|
13
4
|
const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
|
|
14
|
-
function addNodePolyfill(opts) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
5
|
+
async function addNodePolyfill(opts) {
|
|
6
|
+
const { config } = opts;
|
|
7
|
+
const nodeLibs = require('node-libs-browser');
|
|
8
|
+
config.plugin('node-polyfill-provider').use(webpack_1.ProvidePlugin, [
|
|
9
|
+
{
|
|
10
|
+
Buffer: ['buffer', 'Buffer'],
|
|
11
|
+
process: nodeLibs['process'],
|
|
12
|
+
},
|
|
13
|
+
]);
|
|
14
|
+
config.resolve.fallback.merge({
|
|
15
|
+
...Object.keys(nodeLibs).reduce((memo, key) => {
|
|
24
16
|
if (nodeLibs[key]) {
|
|
25
17
|
memo[key] = nodeLibs[key];
|
|
26
18
|
}
|
|
@@ -28,7 +20,9 @@ function addNodePolyfill(opts) {
|
|
|
28
20
|
memo[key] = false;
|
|
29
21
|
}
|
|
30
22
|
return memo;
|
|
31
|
-
}, {})
|
|
23
|
+
}, {}),
|
|
24
|
+
http: false,
|
|
25
|
+
https: false,
|
|
32
26
|
});
|
|
33
27
|
}
|
|
34
28
|
exports.addNodePolyfill = addNodePolyfill;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
|
|
2
|
+
import { Env, IConfig } from '../types';
|
|
3
|
+
interface IOpts {
|
|
4
|
+
name?: string;
|
|
5
|
+
config: Config;
|
|
6
|
+
userConfig: IConfig;
|
|
7
|
+
cwd: string;
|
|
8
|
+
env: Env;
|
|
9
|
+
}
|
|
10
|
+
export declare function addNodePrefixPlugin(opts: IOpts): Promise<void>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addNodePrefixPlugin = void 0;
|
|
4
|
+
const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
|
|
5
|
+
async function addNodePrefixPlugin(opts) {
|
|
6
|
+
const { config } = opts;
|
|
7
|
+
config.plugin('node-prefix-plugin').use(webpack_1.NormalModuleReplacementPlugin, [
|
|
8
|
+
/^node:/,
|
|
9
|
+
(resource) => {
|
|
10
|
+
resource.request = resource.request.replace(/^node:/, '');
|
|
11
|
+
},
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
14
|
+
exports.addNodePrefixPlugin = addNodePrefixPlugin;
|
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.addProgressPlugin = void 0;
|
|
16
7
|
const ProgressPlugin_1 = __importDefault(require("../plugins/ProgressPlugin"));
|
|
17
|
-
function addProgressPlugin(opts) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
8
|
+
async function addProgressPlugin(opts) {
|
|
9
|
+
const { config, name } = opts;
|
|
10
|
+
config.plugin('progress-plugin').use(ProgressPlugin_1.default, [
|
|
11
|
+
{
|
|
12
|
+
name,
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
26
15
|
}
|
|
27
16
|
exports.addProgressPlugin = addProgressPlugin;
|
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.applyPurgeCSSWebpackPlugin = void 0;
|
|
13
4
|
const types_1 = require("../types");
|
|
14
|
-
function applyPurgeCSSWebpackPlugin(opts) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
});
|
|
5
|
+
async function applyPurgeCSSWebpackPlugin(opts) {
|
|
6
|
+
const { config, userConfig, cwd, env } = opts;
|
|
7
|
+
config;
|
|
8
|
+
userConfig;
|
|
9
|
+
cwd;
|
|
10
|
+
env;
|
|
11
|
+
if (userConfig.purgeCSS && env === types_1.Env.production) {
|
|
12
|
+
config
|
|
13
|
+
.plugin('purgecss-webpack-plugin')
|
|
14
|
+
.use(require('@umijs/bundler-webpack/compiled/purgecss-webpack-plugin'), [
|
|
15
|
+
{
|
|
16
|
+
paths: [],
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
31
20
|
}
|
|
32
21
|
exports.applyPurgeCSSWebpackPlugin = applyPurgeCSSWebpackPlugin;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,19 +7,17 @@ exports.addSpeedMeasureWebpackPlugin = void 0;
|
|
|
16
7
|
// @ts-ignore
|
|
17
8
|
const speed_measure_webpack_plugin_1 = __importDefault(require("@umijs/bundler-webpack/compiled/speed-measure-webpack-plugin"));
|
|
18
9
|
const path_1 = require("path");
|
|
19
|
-
function addSpeedMeasureWebpackPlugin(opts) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return webpackConfig;
|
|
32
|
-
});
|
|
10
|
+
async function addSpeedMeasureWebpackPlugin(opts) {
|
|
11
|
+
let webpackConfig = opts.webpackConfig;
|
|
12
|
+
if (process.env.SPEED_MEASURE) {
|
|
13
|
+
const smpOption = process.env.SPEED_MEASURE === 'JSON'
|
|
14
|
+
? {
|
|
15
|
+
outputFormat: 'json',
|
|
16
|
+
outputTarget: (0, path_1.join)(process.cwd(), 'SPEED_MEASURE.json'),
|
|
17
|
+
}
|
|
18
|
+
: { outputFormat: 'human', outputTarget: console.log };
|
|
19
|
+
webpackConfig = new speed_measure_webpack_plugin_1.default(smpOption).wrap(webpackConfig);
|
|
20
|
+
}
|
|
21
|
+
return webpackConfig;
|
|
33
22
|
}
|
|
34
23
|
exports.addSpeedMeasureWebpackPlugin = addSpeedMeasureWebpackPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Config from '../../compiled/webpack-5-chain';
|
|
2
|
+
import { Env, IConfig } from '../types';
|
|
3
|
+
interface IOpts {
|
|
4
|
+
name?: string;
|
|
5
|
+
config: Config;
|
|
6
|
+
userConfig: IConfig;
|
|
7
|
+
cwd: string;
|
|
8
|
+
env: Env;
|
|
9
|
+
}
|
|
10
|
+
export default function addSSRPlugin(opts: IOpts): void;
|
|
11
|
+
export {};
|