@umijs/bundler-webpack 4.0.0-rc.8 → 4.0.1
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
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const webpack_1 = require("@umijs/bundler-webpack/compiled/webpack");
|
|
4
|
+
const utils_1 = require("@umijs/utils");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const PLUGIN_NAME = 'SSR_PLUGIN';
|
|
9
|
+
class SSRPlugin {
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
this.opts = opts;
|
|
12
|
+
this.manifest = new Map();
|
|
13
|
+
}
|
|
14
|
+
apply(compiler) {
|
|
15
|
+
// ref: https://github.com/webdeveric/webpack-assets-manifest
|
|
16
|
+
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
|
|
17
|
+
compilation.hooks.processAssets.tap(PLUGIN_NAME, () => {
|
|
18
|
+
const publicPath = compiler.options.output.publicPath || '/';
|
|
19
|
+
const assets = compilation.getAssets().filter((asset) => {
|
|
20
|
+
if (asset.info.hotModuleReplacement) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
assets.forEach((asset) => {
|
|
26
|
+
if (asset.info.sourceFilename) {
|
|
27
|
+
this.manifest.set(asset.info.sourceFilename, publicPath + asset.name);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const stats = compilation.getStats().toJson({
|
|
31
|
+
all: false,
|
|
32
|
+
assets: true,
|
|
33
|
+
cachedAssets: true,
|
|
34
|
+
cachedModules: true,
|
|
35
|
+
});
|
|
36
|
+
const { assetsByChunkName } = stats;
|
|
37
|
+
Object.keys(assetsByChunkName).forEach((chunkName) => {
|
|
38
|
+
assetsByChunkName[chunkName].forEach((filename) => {
|
|
39
|
+
const ext = (0, path_1.extname)(filename.split(/[?#]/)[0]);
|
|
40
|
+
if (!filename.includes('.hot-update.')) {
|
|
41
|
+
this.manifest.set(chunkName + ext, publicPath + filename);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
const assetsSource = JSON.stringify({
|
|
46
|
+
assets: Object.fromEntries(this.manifest),
|
|
47
|
+
}, null, 2);
|
|
48
|
+
if (process.env.NODE_ENV === 'production' ||
|
|
49
|
+
this.opts.userConfig.writeToDisk) {
|
|
50
|
+
compilation.emitAsset('build-manifest.json', new webpack_1.sources.RawSource(assetsSource, false));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const outputPath = compiler.options.output.path;
|
|
54
|
+
utils_1.fsExtra.mkdirpSync(outputPath);
|
|
55
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(outputPath, 'build-manifest.json'), assetsSource, 'utf-8');
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function addSSRPlugin(opts) {
|
|
62
|
+
if (opts.userConfig.ssr && opts.name !== constants_1.MFSU_NAME) {
|
|
63
|
+
opts.config.plugin('ssr-plugin').use(SSRPlugin, [opts]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = addSSRPlugin;
|
package/dist/config/svgRules.js
CHANGED
|
@@ -1,57 +1,54 @@
|
|
|
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.addSVGRules = void 0;
|
|
13
|
-
function addSVGRules(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
async function addSVGRules(opts) {
|
|
5
|
+
const { config, userConfig } = opts;
|
|
6
|
+
const { svgr, svgo = {} } = userConfig;
|
|
7
|
+
if (svgr) {
|
|
8
|
+
const svgrRule = config.module.rule('svgr');
|
|
9
|
+
svgrRule
|
|
10
|
+
.test(/\.svg$/)
|
|
11
|
+
.issuer(/\.[jt]sx?$/)
|
|
12
|
+
.type('javascript/auto')
|
|
13
|
+
.use('svgr-loader')
|
|
14
|
+
.loader(require.resolve('../loader/svgr'))
|
|
15
|
+
.options({
|
|
16
|
+
svgoConfig: {
|
|
17
|
+
plugins: [
|
|
18
|
+
{
|
|
19
|
+
name: 'preset-default',
|
|
20
|
+
params: {
|
|
21
|
+
overrides: {
|
|
22
|
+
removeTitle: false,
|
|
32
23
|
},
|
|
33
24
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
},
|
|
26
|
+
'prefixIds',
|
|
27
|
+
],
|
|
28
|
+
...svgo,
|
|
29
|
+
},
|
|
30
|
+
...svgr,
|
|
31
|
+
svgo: !!svgo,
|
|
32
|
+
})
|
|
33
|
+
.end()
|
|
34
|
+
.use('url-loader')
|
|
35
|
+
.loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'))
|
|
36
|
+
.end();
|
|
37
|
+
}
|
|
38
|
+
if (svgo === false) {
|
|
48
39
|
const svgRule = config.module.rule('svg');
|
|
49
40
|
svgRule
|
|
50
41
|
.test(/\.svg$/)
|
|
51
|
-
.use('
|
|
52
|
-
.loader(require.resolve('@umijs/bundler-webpack/compiled/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
.use('url-loader')
|
|
43
|
+
.loader(require.resolve('@umijs/bundler-webpack/compiled/url-loader'));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const svgRule = config.module.rule('svg');
|
|
47
|
+
svgRule
|
|
48
|
+
.test(/\.svg$/)
|
|
49
|
+
.use('svgo-loader')
|
|
50
|
+
.loader(require.resolve('@umijs/bundler-webpack/compiled/svgo-loader'))
|
|
51
|
+
.options({ configFile: false, ...svgo })
|
|
52
|
+
.end();
|
|
56
53
|
}
|
|
57
54
|
exports.addSVGRules = addSVGRules;
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_BROWSER_TARGETS = exports.MESSAGE_TYPE = exports.MFSU_NAME = exports.DEFAULT_OUTPUT_PATH = exports.DEFAULT_DEVTOOL = void 0;
|
|
3
|
+
exports.DEFAULT_ESBUILD_TARGET_KEYS = exports.DEFAULT_BROWSER_TARGETS = exports.MESSAGE_TYPE = exports.MFSU_NAME = exports.DEFAULT_OUTPUT_PATH = exports.DEFAULT_DEVTOOL = void 0;
|
|
4
4
|
exports.DEFAULT_DEVTOOL = 'cheap-module-source-map';
|
|
5
5
|
exports.DEFAULT_OUTPUT_PATH = 'dist';
|
|
6
6
|
exports.MFSU_NAME = 'MFSU';
|
|
@@ -16,3 +16,9 @@ var MESSAGE_TYPE;
|
|
|
16
16
|
exports.DEFAULT_BROWSER_TARGETS = {
|
|
17
17
|
chrome: 80,
|
|
18
18
|
};
|
|
19
|
+
exports.DEFAULT_ESBUILD_TARGET_KEYS = [
|
|
20
|
+
'chrome',
|
|
21
|
+
'firefox',
|
|
22
|
+
'edge',
|
|
23
|
+
'safari',
|
|
24
|
+
];
|
package/dist/dev.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ declare type IOpts = {
|
|
|
4
4
|
afterMiddlewares?: any[];
|
|
5
5
|
beforeMiddlewares?: any[];
|
|
6
6
|
onDevCompileDone?: Function;
|
|
7
|
+
onProgress?: Function;
|
|
8
|
+
onMFSUProgress?: Function;
|
|
7
9
|
port?: number;
|
|
8
10
|
host?: string;
|
|
9
11
|
babelPreset?: any;
|
|
@@ -14,8 +16,10 @@ declare type IOpts = {
|
|
|
14
16
|
extraBabelPlugins?: any[];
|
|
15
17
|
extraBabelPresets?: any[];
|
|
16
18
|
cwd: string;
|
|
19
|
+
rootDir?: string;
|
|
17
20
|
config: IConfig;
|
|
18
21
|
entry: Record<string, string>;
|
|
19
22
|
} & Pick<IConfigOpts, 'cache'>;
|
|
23
|
+
export declare function stripUndefined(obj: any): any;
|
|
20
24
|
export declare function dev(opts: IOpts): Promise<void>;
|
|
21
25
|
export {};
|
package/dist/dev.js
CHANGED
|
@@ -1,113 +1,134 @@
|
|
|
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
|
-
exports.dev = void 0;
|
|
6
|
+
exports.dev = exports.stripUndefined = void 0;
|
|
16
7
|
const mfsu_1 = require("@umijs/mfsu");
|
|
17
8
|
const utils_1 = require("@umijs/utils");
|
|
9
|
+
const fs_1 = require("fs");
|
|
18
10
|
const path_1 = require("path");
|
|
19
11
|
const webpack_1 = __importDefault(require("../compiled/webpack"));
|
|
20
12
|
const config_1 = require("./config/config");
|
|
21
13
|
const constants_1 = require("./constants");
|
|
22
14
|
const server_1 = require("./server/server");
|
|
23
15
|
const types_1 = require("./types");
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const enableMFSU = opts.config.mfsu !== false;
|
|
29
|
-
let mfsu = null;
|
|
30
|
-
if (enableMFSU) {
|
|
31
|
-
if (opts.config.srcTranspiler === types_1.Transpiler.swc) {
|
|
32
|
-
utils_1.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
33
|
-
}
|
|
34
|
-
mfsu = new mfsu_1.MFSU({
|
|
35
|
-
implementor: webpack_1.default,
|
|
36
|
-
buildDepWithESBuild: (_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild,
|
|
37
|
-
depBuildConfig: {
|
|
38
|
-
extraPostCSSPlugins: ((_b = opts.config) === null || _b === void 0 ? void 0 : _b.extraPostCSSPlugins) || [],
|
|
39
|
-
},
|
|
40
|
-
mfName: (_c = opts.config.mfsu) === null || _c === void 0 ? void 0 : _c.mfName,
|
|
41
|
-
runtimePublicPath: opts.config.runtimePublicPath,
|
|
42
|
-
tmpBase: ((_d = opts.config.mfsu) === null || _d === void 0 ? void 0 : _d.cacheDirectory) ||
|
|
43
|
-
(0, path_1.join)(opts.cwd, 'node_modules/.cache/mfsu'),
|
|
44
|
-
getCacheDependency() {
|
|
45
|
-
var _a;
|
|
46
|
-
return {
|
|
47
|
-
version: require('../package.json').version,
|
|
48
|
-
esbuildMode: !!((_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild),
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
});
|
|
16
|
+
function stripUndefined(obj) {
|
|
17
|
+
Object.keys(obj).forEach((key) => {
|
|
18
|
+
if (obj[key] === undefined) {
|
|
19
|
+
delete obj[key];
|
|
52
20
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
21
|
+
});
|
|
22
|
+
return obj;
|
|
23
|
+
}
|
|
24
|
+
exports.stripUndefined = stripUndefined;
|
|
25
|
+
async function dev(opts) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
|
+
var _g;
|
|
28
|
+
const enableMFSU = opts.config.mfsu !== false;
|
|
29
|
+
let mfsu = null;
|
|
30
|
+
if (enableMFSU) {
|
|
31
|
+
if (opts.config.srcTranspiler === types_1.Transpiler.swc) {
|
|
32
|
+
utils_1.logger.warn(`Swc currently not supported for use with mfsu, recommended you use srcTranspiler: 'esbuild' in dev.`);
|
|
33
|
+
}
|
|
34
|
+
mfsu = new mfsu_1.MFSU({
|
|
35
|
+
implementor: webpack_1.default,
|
|
36
|
+
buildDepWithESBuild: (_a = opts.config.mfsu) === null || _a === void 0 ? void 0 : _a.esbuild,
|
|
37
|
+
depBuildConfig: {
|
|
38
|
+
extraPostCSSPlugins: ((_b = opts.config) === null || _b === void 0 ? void 0 : _b.extraPostCSSPlugins) || [],
|
|
39
|
+
},
|
|
40
|
+
mfName: (_c = opts.config.mfsu) === null || _c === void 0 ? void 0 : _c.mfName,
|
|
41
|
+
runtimePublicPath: opts.config.runtimePublicPath,
|
|
42
|
+
tmpBase: ((_d = opts.config.mfsu) === null || _d === void 0 ? void 0 : _d.cacheDirectory) ||
|
|
43
|
+
(0, path_1.join)(opts.rootDir || opts.cwd, 'node_modules/.cache/mfsu'),
|
|
44
|
+
onMFSUProgress: opts.onMFSUProgress,
|
|
45
|
+
getCacheDependency() {
|
|
46
|
+
return stripUndefined({
|
|
47
|
+
version: require('../package.json').version,
|
|
48
|
+
mfsu: opts.config.mfsu,
|
|
49
|
+
alias: opts.config.alias,
|
|
50
|
+
externals: opts.config.externals,
|
|
51
|
+
theme: opts.config.theme,
|
|
52
|
+
runtimePublicPath: opts.config.runtimePublicPath,
|
|
53
|
+
publicPath: opts.config.publicPath,
|
|
54
|
+
});
|
|
86
55
|
},
|
|
87
56
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
57
|
+
}
|
|
58
|
+
const webpackConfig = await (0, config_1.getConfig)({
|
|
59
|
+
cwd: opts.cwd,
|
|
60
|
+
rootDir: opts.rootDir,
|
|
61
|
+
env: types_1.Env.development,
|
|
62
|
+
entry: opts.entry,
|
|
63
|
+
userConfig: opts.config,
|
|
64
|
+
babelPreset: opts.babelPreset,
|
|
65
|
+
extraBabelPlugins: [
|
|
66
|
+
...(opts.beforeBabelPlugins || []),
|
|
67
|
+
...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getBabelPlugins()) || []),
|
|
68
|
+
...(opts.extraBabelPlugins || []),
|
|
69
|
+
],
|
|
70
|
+
extraBabelPresets: [
|
|
71
|
+
...(opts.beforeBabelPresets || []),
|
|
72
|
+
...(opts.extraBabelPresets || []),
|
|
73
|
+
],
|
|
74
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
75
|
+
extraEsbuildLoaderHandler: (mfsu === null || mfsu === void 0 ? void 0 : mfsu.getEsbuildLoaderHandler()) || [],
|
|
76
|
+
chainWebpack: opts.chainWebpack,
|
|
77
|
+
modifyWebpackConfig: opts.modifyWebpackConfig,
|
|
78
|
+
hmr: true,
|
|
79
|
+
analyze: process.env.ANALYZE,
|
|
80
|
+
cache: opts.cache,
|
|
81
|
+
});
|
|
82
|
+
const depConfig = await (0, config_1.getConfig)({
|
|
83
|
+
cwd: opts.cwd,
|
|
84
|
+
rootDir: opts.rootDir,
|
|
85
|
+
env: types_1.Env.development,
|
|
86
|
+
entry: opts.entry,
|
|
87
|
+
userConfig: opts.config,
|
|
88
|
+
hash: true,
|
|
89
|
+
staticPathPrefix: mfsu_1.MF_DEP_PREFIX,
|
|
90
|
+
name: constants_1.MFSU_NAME,
|
|
91
|
+
chainWebpack: (_e = opts.config.mfsu) === null || _e === void 0 ? void 0 : _e.chainWebpack,
|
|
92
|
+
cache: {
|
|
93
|
+
buildDependencies: (_f = opts.cache) === null || _f === void 0 ? void 0 : _f.buildDependencies,
|
|
94
|
+
cacheDirectory: (0, path_1.join)(opts.rootDir || opts.cwd, 'node_modules', '.cache', 'mfsu-deps'),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
(_g = webpackConfig.resolve).alias || (_g.alias = {});
|
|
98
|
+
// TODO: REMOVE ME
|
|
99
|
+
['@umijs/utils/compiled/strip-ansi', 'react-error-overlay'].forEach((dep) => {
|
|
100
|
+
// @ts-ignore
|
|
101
|
+
webpackConfig.resolve.alias[dep] = require.resolve(dep);
|
|
102
|
+
});
|
|
103
|
+
await (mfsu === null || mfsu === void 0 ? void 0 : mfsu.setWebpackConfig({
|
|
104
|
+
config: webpackConfig,
|
|
105
|
+
depConfig: depConfig,
|
|
106
|
+
}));
|
|
107
|
+
if (mfsu &&
|
|
108
|
+
webpackConfig.cache &&
|
|
109
|
+
typeof webpackConfig.cache === 'object' &&
|
|
110
|
+
webpackConfig.cache.type === 'filesystem') {
|
|
111
|
+
const webpackCachePath = (0, path_1.join)(webpackConfig.cache.cacheDirectory, `default-development`, 'index.pack');
|
|
112
|
+
const mfsuCacheExists = (0, fs_1.existsSync)(mfsu.depInfo.cacheFilePath);
|
|
113
|
+
const webpackCacheExists = (0, fs_1.existsSync)(webpackCachePath);
|
|
114
|
+
if (webpackCacheExists && !mfsuCacheExists) {
|
|
115
|
+
utils_1.logger.warn(`Invalidate webpack cache since mfsu cache is missing`);
|
|
116
|
+
utils_1.rimraf.sync(webpackConfig.cache.cacheDirectory);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
await (0, server_1.createServer)({
|
|
120
|
+
webpackConfig,
|
|
121
|
+
userConfig: opts.config,
|
|
122
|
+
cwd: opts.cwd,
|
|
123
|
+
beforeMiddlewares: [
|
|
124
|
+
...((mfsu === null || mfsu === void 0 ? void 0 : mfsu.getMiddlewares()) || []),
|
|
125
|
+
...(opts.beforeMiddlewares || []),
|
|
126
|
+
],
|
|
127
|
+
port: opts.port,
|
|
128
|
+
host: opts.host,
|
|
129
|
+
afterMiddlewares: [...(opts.afterMiddlewares || [])],
|
|
130
|
+
onDevCompileDone: opts.onDevCompileDone,
|
|
131
|
+
onProgress: opts.onProgress,
|
|
111
132
|
});
|
|
112
133
|
}
|
|
113
134
|
exports.dev = dev;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import * as parcelCSS from '@parcel/css';
|
|
1
2
|
import type webpack from '../compiled/webpack';
|
|
3
|
+
import './requireHook';
|
|
2
4
|
export type { RequestHandler } from '@umijs/bundler-utils/compiled/express';
|
|
3
5
|
export type { Compiler, Stats } from '../compiled/webpack';
|
|
4
6
|
export * from './build';
|
|
5
7
|
export * from './config/config';
|
|
6
8
|
export * from './dev';
|
|
7
9
|
export * from './schema';
|
|
10
|
+
export { parcelCSS };
|
|
8
11
|
export { webpack };
|
package/dist/index.js
CHANGED
|
@@ -10,10 +10,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.parcelCSS = void 0;
|
|
30
|
+
const parcelCSS = __importStar(require("@parcel/css"));
|
|
31
|
+
exports.parcelCSS = parcelCSS;
|
|
32
|
+
require("./requireHook");
|
|
17
33
|
__exportStar(require("./build"), exports);
|
|
18
34
|
__exportStar(require("./config/config"), exports);
|
|
19
35
|
__exportStar(require("./dev"), exports);
|
package/dist/loader/svgr.js
CHANGED
|
@@ -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
|
};
|
|
@@ -22,9 +13,9 @@ const plugin_svgo_1 = __importDefault(require("@svgr/plugin-svgo"));
|
|
|
22
13
|
const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
|
|
23
14
|
const path_1 = require("path");
|
|
24
15
|
const util_1 = require("util");
|
|
25
|
-
const tranformSvg = (0, util_1.callbackify)((contents, options, state) =>
|
|
26
|
-
const jsCode =
|
|
27
|
-
const result =
|
|
16
|
+
const tranformSvg = (0, util_1.callbackify)(async (contents, options, state) => {
|
|
17
|
+
const jsCode = await (0, core_1.transform)(contents, options, state);
|
|
18
|
+
const result = await (0, esbuild_1.transform)(jsCode, {
|
|
28
19
|
loader: 'tsx',
|
|
29
20
|
target: 'es2015',
|
|
30
21
|
});
|
|
@@ -32,7 +23,7 @@ const tranformSvg = (0, util_1.callbackify)((contents, options, state) => __awai
|
|
|
32
23
|
throw new Error(`Error while transforming using Esbuild`);
|
|
33
24
|
}
|
|
34
25
|
return result.code;
|
|
35
|
-
})
|
|
26
|
+
});
|
|
36
27
|
function svgrLoader(contents) {
|
|
37
28
|
this.cacheable && this.cacheable();
|
|
38
29
|
const callback = this.async();
|
package/dist/loader/swc.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
const core_1 = require("@swc/core");
|
|
15
4
|
const types_1 = require("../types");
|
|
@@ -54,11 +43,17 @@ function swcLoader(contents) {
|
|
|
54
43
|
// 启用异步模式
|
|
55
44
|
const callback = this.async();
|
|
56
45
|
const loaderOpts = this.getOptions();
|
|
57
|
-
const { sync = false, parseMap = false
|
|
46
|
+
const { sync = false, parseMap = false, ...otherOpts } = loaderOpts;
|
|
58
47
|
const filename = this.resourcePath;
|
|
59
|
-
const swcOpts =
|
|
48
|
+
const swcOpts = {
|
|
49
|
+
...getBaseOpts({
|
|
50
|
+
filename,
|
|
51
|
+
}),
|
|
60
52
|
filename,
|
|
61
|
-
|
|
53
|
+
sourceMaps: this.sourceMap,
|
|
54
|
+
sourceFileName: filename,
|
|
55
|
+
...otherOpts,
|
|
56
|
+
};
|
|
62
57
|
try {
|
|
63
58
|
if (sync) {
|
|
64
59
|
const output = (0, core_1.transformSync)(contents, swcOpts);
|
|
@@ -12,8 +12,9 @@ class UmiProgressPlugin extends webpack_1.ProgressPlugin {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
apply(compiler) {
|
|
15
|
+
const prefix = this.options.name ? `[${this.options.name}]` : '[Webpack]';
|
|
15
16
|
compiler.hooks.invalid.tap(PLUGIN_NAME, () => {
|
|
16
|
-
utils_1.logger.wait(
|
|
17
|
+
utils_1.logger.wait(`${prefix} Compiling...`);
|
|
17
18
|
});
|
|
18
19
|
compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
|
|
19
20
|
const { errors, warnings } = stats.toJson({
|
|
@@ -32,8 +33,7 @@ class UmiProgressPlugin extends webpack_1.ProgressPlugin {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
|
-
|
|
36
|
-
utils_1.logger.event(`${prefix}Compiled successfully in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
|
|
36
|
+
utils_1.logger.event(`${prefix} Compiled in ${stats.endTime - stats.startTime} ms (${stats.compilation.modules.size} modules)`);
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -10,8 +10,11 @@ class RuntimePublicPathPlugin {
|
|
|
10
10
|
// The hook to get the public path ('__webpack_require__.p')
|
|
11
11
|
// https://github.com/webpack/webpack/blob/master/lib/runtime/PublicPathRuntimeModule.js
|
|
12
12
|
if (module.constructor.name === 'PublicPathRuntimeModule') {
|
|
13
|
+
// If current public path is handled by mini-css-extract-plugin, skip it
|
|
14
|
+
if (module.getGeneratedCode().includes('webpack:///mini-css-extract-plugin'))
|
|
15
|
+
return;
|
|
13
16
|
// @ts-ignore
|
|
14
|
-
module._cachedGeneratedCode = `__webpack_require__.p = (globalThis || window).publicPath;`;
|
|
17
|
+
module._cachedGeneratedCode = `__webpack_require__.p = (globalThis || window).publicPath || '/';`;
|
|
15
18
|
}
|
|
16
19
|
});
|
|
17
20
|
});
|