@umijs/preset-umi 4.0.13 → 4.0.16
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/dist/commands/build.js +23 -17
- package/dist/commands/dev/depBuildWorker/depBuildWorker.d.ts +1 -0
- package/dist/commands/dev/depBuildWorker/depBuildWorker.js +107 -0
- package/dist/commands/dev/depBuildWorker/depBuilder.d.ts +37 -0
- package/dist/commands/dev/depBuildWorker/depBuilder.js +210 -0
- package/dist/commands/dev/depBuildWorker/dev-config.d.ts +3 -0
- package/dist/commands/dev/depBuildWorker/dev-config.js +124 -0
- package/dist/commands/dev/depBuildWorker/getConfig.d.ts +1 -0
- package/dist/commands/dev/depBuildWorker/getConfig.js +42 -0
- package/dist/commands/dev/depBuildWorker/workerPreset.d.ts +4 -0
- package/dist/commands/dev/depBuildWorker/workerPreset.js +34 -0
- package/dist/commands/dev/dev.js +31 -6
- package/dist/commands/generators/jest.js +10 -7
- package/dist/features/404/404.d.ts +5 -0
- package/dist/features/404/404.js +48 -0
- package/dist/features/apiRoute/request.js +1 -1
- package/dist/features/appData/appData.js +2 -1
- package/dist/features/legacy/legacy.d.ts +3 -0
- package/dist/features/legacy/legacy.js +133 -0
- package/dist/features/mpa/extractExports.d.ts +4 -0
- package/dist/features/mpa/extractExports.js +112 -0
- package/dist/features/mpa/mpa.d.ts +3 -0
- package/dist/features/mpa/mpa.js +207 -0
- package/dist/index.js +6 -1
- package/dist/registerMethods.js +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +14 -10
package/dist/commands/build.js
CHANGED
|
@@ -117,12 +117,16 @@ umi build --clean
|
|
|
117
117
|
args
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
|
+
const entry = await api.applyPlugins({
|
|
121
|
+
key: "modifyEntry",
|
|
122
|
+
initialValue: {
|
|
123
|
+
umi: (0, import_path.join)(api.paths.absTmpPath, "umi.ts")
|
|
124
|
+
}
|
|
125
|
+
});
|
|
120
126
|
const opts = __spreadProps(__spreadValues({
|
|
121
127
|
config: api.config,
|
|
122
128
|
cwd: api.cwd,
|
|
123
|
-
entry
|
|
124
|
-
umi: (0, import_path.join)(api.paths.absTmpPath, "umi.ts")
|
|
125
|
-
}
|
|
129
|
+
entry
|
|
126
130
|
}, api.config.vite ? { modifyViteConfig } : { babelPreset, chainWebpack, modifyWebpackConfig }), {
|
|
127
131
|
beforeBabelPlugins,
|
|
128
132
|
beforeBabelPresets,
|
|
@@ -143,20 +147,22 @@ umi build --clean
|
|
|
143
147
|
} else {
|
|
144
148
|
stats = await bundlerWebpack.build(opts);
|
|
145
149
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
150
|
+
if (!api.config.mpa) {
|
|
151
|
+
const assetsMap = api.config.vite ? {} : (0, import_getAssetsMap.getAssetsMap)({
|
|
152
|
+
stats,
|
|
153
|
+
publicPath: api.config.publicPath
|
|
154
|
+
});
|
|
155
|
+
const { vite } = api.args;
|
|
156
|
+
const markupArgs = await (0, import_getMarkupArgs.getMarkupArgs)({ api });
|
|
157
|
+
const markup = await (0, import_server.getMarkup)(__spreadProps(__spreadValues({}, markupArgs), {
|
|
158
|
+
styles: markupArgs.styles.concat(api.config.vite ? [] : assetsMap["umi.css"] || []),
|
|
159
|
+
scripts: (api.config.vite ? [] : assetsMap["umi.js"] || []).concat(markupArgs.scripts),
|
|
160
|
+
esmScript: !!opts.config.esm || vite,
|
|
161
|
+
path: "/"
|
|
162
|
+
}));
|
|
163
|
+
(0, import_fs.writeFileSync)((0, import_path.join)(api.paths.absOutputPath, "index.html"), markup, "utf-8");
|
|
164
|
+
import_utils.logger.event("Build index.html");
|
|
165
|
+
}
|
|
160
166
|
await api.applyPlugins({
|
|
161
167
|
key: "onBuildHtmlComplete",
|
|
162
168
|
args: opts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
16
|
+
|
|
17
|
+
// src/commands/dev/depBuildWorker/depBuildWorker.ts
|
|
18
|
+
var import_bundler_webpack = require("@umijs/bundler-webpack");
|
|
19
|
+
var import_constants = require("@umijs/bundler-webpack/dist/constants");
|
|
20
|
+
var import_types = require("@umijs/bundler-webpack/dist/types");
|
|
21
|
+
var import_mfsu = require("@umijs/mfsu");
|
|
22
|
+
var import_utils = require("@umijs/utils");
|
|
23
|
+
var import_path = require("path");
|
|
24
|
+
var import_worker_threads = require("worker_threads");
|
|
25
|
+
var import_depBuilder = require("./depBuilder");
|
|
26
|
+
var import_getConfig = require("./getConfig");
|
|
27
|
+
if (import_worker_threads.isMainThread) {
|
|
28
|
+
throw Error("MFSU-eager builder can only be called in a worker thread");
|
|
29
|
+
}
|
|
30
|
+
var bundlerWebpackPath = (0, import_path.dirname)(require.resolve("@umijs/bundler-webpack"));
|
|
31
|
+
var bufferedRequest = [];
|
|
32
|
+
async function start() {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
|
+
let builder = null;
|
|
35
|
+
function build(deps) {
|
|
36
|
+
import_utils.logger.info("[MFSU][eager] build worker start to build");
|
|
37
|
+
return builder.build({ deps }).catch((e) => {
|
|
38
|
+
import_utils.logger.error("[MFSU][eager] build worker failed", e);
|
|
39
|
+
import_worker_threads.parentPort.postMessage({ error: e });
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function scheduleBuild() {
|
|
43
|
+
if (builder && !builder.isBuilding) {
|
|
44
|
+
const buildReq = bufferedRequest.shift();
|
|
45
|
+
if (buildReq) {
|
|
46
|
+
build(buildReq).finally(() => {
|
|
47
|
+
scheduleBuild();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
import_worker_threads.parentPort.on("message", (buildReq) => {
|
|
53
|
+
bufferedRequest.push(buildReq);
|
|
54
|
+
scheduleBuild();
|
|
55
|
+
});
|
|
56
|
+
const start2 = Date.now();
|
|
57
|
+
const opts = await (0, import_getConfig.getDevConfig)();
|
|
58
|
+
const cacheDirectoryPath = (0, import_path.resolve)(opts.rootDir || opts.cwd, opts.config.cacheDirectoryPath || "node_modules/.cache");
|
|
59
|
+
const depConfig = await (0, import_bundler_webpack.getConfig)({
|
|
60
|
+
cwd: opts.cwd,
|
|
61
|
+
rootDir: opts.rootDir,
|
|
62
|
+
env: import_types.Env.development,
|
|
63
|
+
entry: opts.entry,
|
|
64
|
+
userConfig: opts.config,
|
|
65
|
+
hash: true,
|
|
66
|
+
staticPathPrefix: import_mfsu.MF_DEP_PREFIX,
|
|
67
|
+
name: import_constants.MFSU_NAME,
|
|
68
|
+
chainWebpack: (_a = opts.config.mfsu) == null ? void 0 : _a.chainWebpack,
|
|
69
|
+
extraBabelIncludes: opts.config.extraBabelIncludes,
|
|
70
|
+
cache: {
|
|
71
|
+
buildDependencies: (_b = opts.cache) == null ? void 0 : _b.buildDependencies,
|
|
72
|
+
cacheDirectory: (0, import_path.join)(cacheDirectoryPath, "mfsu-deps")
|
|
73
|
+
},
|
|
74
|
+
pkg: opts.pkg
|
|
75
|
+
});
|
|
76
|
+
(_c = depConfig.resolve).alias || (_c.alias = {});
|
|
77
|
+
["@umijs/utils/compiled/strip-ansi", "react-error-overlay"].forEach((dep) => {
|
|
78
|
+
depConfig.resolve.alias[dep] = require.resolve(dep, {
|
|
79
|
+
paths: [bundlerWebpackPath]
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
const depEsBuildConfig = {
|
|
83
|
+
extraPostCSSPlugins: ((_d = opts.config) == null ? void 0 : _d.extraPostCSSPlugins) || []
|
|
84
|
+
};
|
|
85
|
+
const tmpBase = ((_e = opts.config.mfsu) == null ? void 0 : _e.cacheDirectory) || (0, import_path.join)(cacheDirectoryPath, "mfsu");
|
|
86
|
+
const externals = makeArray(opts.config.externals || []);
|
|
87
|
+
builder = new import_depBuilder.DepBuilderInWorker({
|
|
88
|
+
depConfig,
|
|
89
|
+
cwd: opts.cwd,
|
|
90
|
+
tmpBase,
|
|
91
|
+
mfName: ((_f = opts.config.mfsu) == null ? void 0 : _f.mfName) || import_mfsu.DEFAULT_MF_NAME,
|
|
92
|
+
shared: ((_g = opts.config.mfsu) == null ? void 0 : _g.shared) || {},
|
|
93
|
+
buildDepWithESBuild: false,
|
|
94
|
+
depEsBuildConfig,
|
|
95
|
+
externals
|
|
96
|
+
});
|
|
97
|
+
import_utils.logger.info("[MFSU][eager] worker init, takes", Date.now() - start2);
|
|
98
|
+
scheduleBuild();
|
|
99
|
+
}
|
|
100
|
+
start().catch((e) => {
|
|
101
|
+
import_utils.logger.error("[MFSU][eager] build worker start failed", e);
|
|
102
|
+
});
|
|
103
|
+
function makeArray(a) {
|
|
104
|
+
if (Array.isArray(a))
|
|
105
|
+
return a;
|
|
106
|
+
return [a];
|
|
107
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import webpack from '@umijs/bundler-webpack/compiled/webpack';
|
|
2
|
+
import { Dep } from '@umijs/mfsu/dist/dep/dep';
|
|
3
|
+
declare type IOpts = {
|
|
4
|
+
depConfig: webpack.Configuration;
|
|
5
|
+
cwd: string;
|
|
6
|
+
tmpBase: string;
|
|
7
|
+
mfName: string;
|
|
8
|
+
shared: any;
|
|
9
|
+
buildDepWithESBuild: boolean;
|
|
10
|
+
depEsBuildConfig: any;
|
|
11
|
+
externals: any[];
|
|
12
|
+
};
|
|
13
|
+
export declare class DepBuilderInWorker {
|
|
14
|
+
completeFns: Function[];
|
|
15
|
+
isBuilding: boolean;
|
|
16
|
+
opts: IOpts;
|
|
17
|
+
constructor(opts: IOpts);
|
|
18
|
+
buildWithWebpack(opts: {
|
|
19
|
+
onBuildComplete: Function;
|
|
20
|
+
deps: Dep[];
|
|
21
|
+
}): Promise<unknown>;
|
|
22
|
+
buildWithESBuild(opts: {
|
|
23
|
+
onBuildComplete: Function;
|
|
24
|
+
deps: Dep[];
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
build(opts: {
|
|
27
|
+
deps: Dep[];
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
onBuildComplete(fn: Function): void;
|
|
30
|
+
writeMFFiles(opts: {
|
|
31
|
+
deps: Dep[];
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
getWebpackConfig(opts: {
|
|
34
|
+
deps: Dep[];
|
|
35
|
+
}): webpack.Configuration;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
|
|
39
|
+
// src/commands/dev/depBuildWorker/depBuilder.ts
|
|
40
|
+
var depBuilder_exports = {};
|
|
41
|
+
__export(depBuilder_exports, {
|
|
42
|
+
DepBuilderInWorker: () => DepBuilderInWorker
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(depBuilder_exports);
|
|
45
|
+
var import_bundler_esbuild = require("@umijs/bundler-esbuild");
|
|
46
|
+
var import_webpack = __toESM(require("@umijs/bundler-webpack/compiled/webpack"));
|
|
47
|
+
var import_mfsu = require("@umijs/mfsu");
|
|
48
|
+
var import_dep = require("@umijs/mfsu/dist/dep/dep");
|
|
49
|
+
var import_getESBuildEntry = require("@umijs/mfsu/dist/depBuilder/getESBuildEntry");
|
|
50
|
+
var import_depChunkIdPrefixPlugin = require("@umijs/mfsu/dist/webpackPlugins/depChunkIdPrefixPlugin");
|
|
51
|
+
var import_stripSourceMapUrlPlugin = require("@umijs/mfsu/dist/webpackPlugins/stripSourceMapUrlPlugin");
|
|
52
|
+
var import_utils = require("@umijs/utils");
|
|
53
|
+
var import_fs = require("fs");
|
|
54
|
+
var import_path = require("path");
|
|
55
|
+
var import_worker_threads = require("worker_threads");
|
|
56
|
+
var DepBuilderInWorker = class {
|
|
57
|
+
constructor(opts) {
|
|
58
|
+
this.completeFns = [];
|
|
59
|
+
this.isBuilding = false;
|
|
60
|
+
this.opts = opts;
|
|
61
|
+
}
|
|
62
|
+
async buildWithWebpack(opts) {
|
|
63
|
+
const config = this.getWebpackConfig({ deps: opts.deps });
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
const compiler = (0, import_webpack.default)(config);
|
|
66
|
+
compiler.run((err, stats) => {
|
|
67
|
+
opts.onBuildComplete();
|
|
68
|
+
if (err || (stats == null ? void 0 : stats.hasErrors())) {
|
|
69
|
+
if (err) {
|
|
70
|
+
reject(err);
|
|
71
|
+
}
|
|
72
|
+
if (stats) {
|
|
73
|
+
const errorMsg = stats.toString("errors-only");
|
|
74
|
+
reject(new Error(errorMsg));
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
resolve(stats);
|
|
78
|
+
}
|
|
79
|
+
compiler.close(() => {
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async buildWithESBuild(opts) {
|
|
85
|
+
var _a;
|
|
86
|
+
const alias = __spreadValues({}, (_a = this.opts.depConfig.resolve) == null ? void 0 : _a.alias);
|
|
87
|
+
const externals = this.opts.depConfig.externals;
|
|
88
|
+
const entryContent = (0, import_getESBuildEntry.getESBuildEntry)({ deps: opts.deps });
|
|
89
|
+
const ENTRY_FILE = "esbuild-entry.js";
|
|
90
|
+
const tmpDir = this.opts.tmpBase;
|
|
91
|
+
const entryPath = (0, import_path.join)(tmpDir, ENTRY_FILE);
|
|
92
|
+
(0, import_fs.writeFileSync)(entryPath, entryContent, "utf-8");
|
|
93
|
+
const date = new Date().getTime();
|
|
94
|
+
await (0, import_bundler_esbuild.build)({
|
|
95
|
+
cwd: this.opts.cwd,
|
|
96
|
+
entry: {
|
|
97
|
+
[`${import_mfsu.MF_VA_PREFIX}remoteEntry`]: entryPath
|
|
98
|
+
},
|
|
99
|
+
config: __spreadProps(__spreadValues({}, this.opts.depEsBuildConfig), {
|
|
100
|
+
outputPath: tmpDir,
|
|
101
|
+
alias,
|
|
102
|
+
externals
|
|
103
|
+
}),
|
|
104
|
+
inlineStyle: true
|
|
105
|
+
});
|
|
106
|
+
import_utils.logger.event(`[mfsu] compiled with esbuild successfully in ${+new Date() - date} ms`);
|
|
107
|
+
opts.onBuildComplete();
|
|
108
|
+
}
|
|
109
|
+
async build(opts) {
|
|
110
|
+
this.isBuilding = true;
|
|
111
|
+
const onBuildComplete = () => {
|
|
112
|
+
this.isBuilding = false;
|
|
113
|
+
import_worker_threads.parentPort.postMessage({
|
|
114
|
+
done: true
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
try {
|
|
118
|
+
await this.writeMFFiles({ deps: opts.deps.map((d) => new import_dep.Dep(d)) });
|
|
119
|
+
const newOpts = __spreadProps(__spreadValues({}, opts), {
|
|
120
|
+
onBuildComplete
|
|
121
|
+
});
|
|
122
|
+
if (this.opts.buildDepWithESBuild) {
|
|
123
|
+
await this.buildWithESBuild(newOpts);
|
|
124
|
+
} else {
|
|
125
|
+
await this.buildWithWebpack(newOpts);
|
|
126
|
+
}
|
|
127
|
+
} catch (e) {
|
|
128
|
+
onBuildComplete();
|
|
129
|
+
import_worker_threads.parentPort.postMessage({
|
|
130
|
+
error: e
|
|
131
|
+
});
|
|
132
|
+
throw e;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
onBuildComplete(fn) {
|
|
136
|
+
if (this.isBuilding) {
|
|
137
|
+
this.completeFns.push(fn);
|
|
138
|
+
} else {
|
|
139
|
+
fn();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async writeMFFiles(opts) {
|
|
143
|
+
const tmpBase = this.opts.tmpBase;
|
|
144
|
+
import_utils.fsExtra.mkdirpSync(tmpBase);
|
|
145
|
+
for (const dep of opts.deps) {
|
|
146
|
+
const content = await dep.buildExposeContent();
|
|
147
|
+
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, dep.filePath), content, "utf-8");
|
|
148
|
+
}
|
|
149
|
+
(0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, "index.js"), '"\u{1F61B}"', "utf-8");
|
|
150
|
+
}
|
|
151
|
+
getWebpackConfig(opts) {
|
|
152
|
+
var _a, _b;
|
|
153
|
+
const mfName = this.opts.mfName;
|
|
154
|
+
const depConfig = import_utils.lodash.cloneDeep(this.opts.depConfig);
|
|
155
|
+
depConfig.entry = (0, import_path.join)(this.opts.tmpBase, "index.js");
|
|
156
|
+
depConfig.output.path = this.opts.tmpBase;
|
|
157
|
+
depConfig.output.publicPath = "auto";
|
|
158
|
+
depConfig.devtool = false;
|
|
159
|
+
if ((_a = depConfig.output) == null ? void 0 : _a.library)
|
|
160
|
+
delete depConfig.output.library;
|
|
161
|
+
if ((_b = depConfig.output) == null ? void 0 : _b.libraryTarget)
|
|
162
|
+
delete depConfig.output.libraryTarget;
|
|
163
|
+
depConfig.optimization || (depConfig.optimization = {});
|
|
164
|
+
depConfig.optimization.splitChunks = {
|
|
165
|
+
chunks: (chunk) => {
|
|
166
|
+
const hasShared = chunk.getModules().some((m) => {
|
|
167
|
+
return m.type === "consume-shared-module" || m.type === "provide-module" || m.type === "provide-shared-module";
|
|
168
|
+
});
|
|
169
|
+
return !hasShared;
|
|
170
|
+
},
|
|
171
|
+
maxInitialRequests: Infinity,
|
|
172
|
+
minSize: 0,
|
|
173
|
+
cacheGroups: {
|
|
174
|
+
vendor: {
|
|
175
|
+
test: /.+/,
|
|
176
|
+
name(_module, _chunks, cacheGroupKey) {
|
|
177
|
+
return `${import_mfsu.MF_DEP_PREFIX}___${cacheGroupKey}`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
depConfig.plugins = depConfig.plugins || [];
|
|
183
|
+
depConfig.plugins.push(new import_depChunkIdPrefixPlugin.DepChunkIdPrefixPlugin());
|
|
184
|
+
depConfig.plugins.push(new import_stripSourceMapUrlPlugin.StripSourceMapUrlPlugin({
|
|
185
|
+
webpack: import_webpack.default
|
|
186
|
+
}));
|
|
187
|
+
depConfig.plugins.push(new import_webpack.default.ProgressPlugin((percent, msg) => {
|
|
188
|
+
import_worker_threads.parentPort.postMessage({ progress: { percent, status: msg } });
|
|
189
|
+
}));
|
|
190
|
+
const exposes = opts.deps.reduce((memo, dep) => {
|
|
191
|
+
memo[`./${dep.file}`] = (0, import_path.join)(this.opts.tmpBase, dep.filePath);
|
|
192
|
+
return memo;
|
|
193
|
+
}, {});
|
|
194
|
+
depConfig.plugins.push(new import_webpack.default.container.ModuleFederationPlugin({
|
|
195
|
+
library: {
|
|
196
|
+
type: "global",
|
|
197
|
+
name: mfName
|
|
198
|
+
},
|
|
199
|
+
name: mfName,
|
|
200
|
+
filename: import_mfsu.REMOTE_FILE_FULL,
|
|
201
|
+
exposes,
|
|
202
|
+
shared: this.opts.shared || {}
|
|
203
|
+
}));
|
|
204
|
+
return depConfig;
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
208
|
+
0 && (module.exports = {
|
|
209
|
+
DepBuilderInWorker
|
|
210
|
+
});
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// src/commands/dev/depBuildWorker/dev-config.ts
|
|
37
|
+
var dev_config_exports = {};
|
|
38
|
+
__export(dev_config_exports, {
|
|
39
|
+
default: () => dev_config_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(dev_config_exports);
|
|
42
|
+
var import_utils = require("@umijs/utils");
|
|
43
|
+
var import_path = require("path");
|
|
44
|
+
var import_getBabelOpts = require("../getBabelOpts");
|
|
45
|
+
var MFSU_EAGER_DEFAULT_INCLUDE = [
|
|
46
|
+
"react",
|
|
47
|
+
"react-error-overlay",
|
|
48
|
+
"react/jsx-dev-runtime",
|
|
49
|
+
"@umijs/utils/compiled/strip-ansi"
|
|
50
|
+
];
|
|
51
|
+
var dev_config_default = (api) => {
|
|
52
|
+
api.describe({
|
|
53
|
+
enableBy() {
|
|
54
|
+
return api.name === "dev-config";
|
|
55
|
+
},
|
|
56
|
+
key: "dev-config"
|
|
57
|
+
});
|
|
58
|
+
api.registerCommand({
|
|
59
|
+
name: "dev-config",
|
|
60
|
+
description: "dev server for development",
|
|
61
|
+
details: ``,
|
|
62
|
+
async fn() {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
const {
|
|
65
|
+
babelPreset,
|
|
66
|
+
beforeBabelPlugins,
|
|
67
|
+
beforeBabelPresets,
|
|
68
|
+
extraBabelPlugins,
|
|
69
|
+
extraBabelPresets
|
|
70
|
+
} = await (0, import_getBabelOpts.getBabelOpts)({ api });
|
|
71
|
+
const chainWebpack = async (memo, args) => {
|
|
72
|
+
await api.applyPlugins({
|
|
73
|
+
key: "chainWebpack",
|
|
74
|
+
type: api.ApplyPluginsType.modify,
|
|
75
|
+
initialValue: memo,
|
|
76
|
+
args
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const modifyWebpackConfig = async (memo, args) => {
|
|
80
|
+
return await api.applyPlugins({
|
|
81
|
+
key: "modifyWebpackConfig",
|
|
82
|
+
initialValue: memo,
|
|
83
|
+
args
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const entry = await api.applyPlugins({
|
|
87
|
+
key: "modifyEntry",
|
|
88
|
+
initialValue: {
|
|
89
|
+
umi: (0, import_path.join)(api.paths.absTmpPath, "umi.ts")
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const opts = __spreadProps(__spreadValues({
|
|
93
|
+
config: api.config,
|
|
94
|
+
pkg: api.pkg,
|
|
95
|
+
cwd: api.cwd,
|
|
96
|
+
rootDir: process.cwd(),
|
|
97
|
+
entry,
|
|
98
|
+
port: api.appData.port,
|
|
99
|
+
host: api.appData.host,
|
|
100
|
+
ip: api.appData.ip
|
|
101
|
+
}, { babelPreset, chainWebpack, modifyWebpackConfig }), {
|
|
102
|
+
beforeBabelPlugins,
|
|
103
|
+
beforeBabelPresets,
|
|
104
|
+
extraBabelPlugins,
|
|
105
|
+
extraBabelPresets,
|
|
106
|
+
mfsuWithESBuild: (_a = api.config.mfsu) == null ? void 0 : _a.esbuild,
|
|
107
|
+
mfsuStrategy: (_b = api.config.mfsu) == null ? void 0 : _b.strategy,
|
|
108
|
+
cache: {
|
|
109
|
+
buildDependencies: [
|
|
110
|
+
api.pkgPath,
|
|
111
|
+
api.service.configManager.mainConfigFile || ""
|
|
112
|
+
].filter(Boolean)
|
|
113
|
+
},
|
|
114
|
+
mfsuInclude: import_utils.lodash.union([
|
|
115
|
+
...MFSU_EAGER_DEFAULT_INCLUDE,
|
|
116
|
+
...((_c = api.config.mfsu) == null ? void 0 : _c.include) || []
|
|
117
|
+
])
|
|
118
|
+
});
|
|
119
|
+
return opts;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDevConfig(): Promise<any>;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
};
|
|
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;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/commands/dev/depBuildWorker/getConfig.ts
|
|
23
|
+
var getConfig_exports = {};
|
|
24
|
+
__export(getConfig_exports, {
|
|
25
|
+
getDevConfig: () => getDevConfig
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(getConfig_exports);
|
|
28
|
+
var import_service = require("umi/dist/service/service");
|
|
29
|
+
async function getDevConfig() {
|
|
30
|
+
const service = new import_service.Service({
|
|
31
|
+
presets: [require.resolve("./workerPreset")]
|
|
32
|
+
});
|
|
33
|
+
const opts = await service.run({
|
|
34
|
+
name: "dev-config",
|
|
35
|
+
args: []
|
|
36
|
+
});
|
|
37
|
+
return opts;
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
getDevConfig
|
|
42
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
};
|
|
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;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/commands/dev/depBuildWorker/workerPreset.ts
|
|
23
|
+
var workerPreset_exports = {};
|
|
24
|
+
__export(workerPreset_exports, {
|
|
25
|
+
default: () => workerPreset_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(workerPreset_exports);
|
|
28
|
+
var workerPreset_default = () => {
|
|
29
|
+
return {
|
|
30
|
+
plugins: [require.resolve("./dev-config")]
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {});
|