@umijs/core 4.0.51 → 4.0.53
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/config/config.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -33,6 +33,12 @@ function defineRoutes(callback) {
|
|
|
33
33
|
const parentAbsPath = parentRoute == null ? void 0 : parentRoute.absPath;
|
|
34
34
|
const absPath = [parentAbsPath, opts.path].join("/");
|
|
35
35
|
const route = {
|
|
36
|
+
// 1. root index route path: '/'
|
|
37
|
+
// 2. nested children route path
|
|
38
|
+
// - dir
|
|
39
|
+
// - some.ts -> 'some'
|
|
40
|
+
// - index.ts -> ''
|
|
41
|
+
// - dir.tsx -> '/dir'
|
|
36
42
|
path: absPath === "/" ? "/" : opts.path,
|
|
37
43
|
id: (0, import_utils.createRouteId)(opts.file),
|
|
38
44
|
parentId,
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/service/hook.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
package/dist/service/plugin.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -125,8 +129,15 @@ var Plugin = class {
|
|
|
125
129
|
function get(type) {
|
|
126
130
|
const types = `${type}s`;
|
|
127
131
|
return [
|
|
132
|
+
// opts
|
|
128
133
|
...opts[types] || [],
|
|
134
|
+
// env
|
|
129
135
|
...(process.env[`${opts.prefix}_${types}`.toUpperCase()] || "").split(",").filter(Boolean),
|
|
136
|
+
// dependencies
|
|
137
|
+
// ...Object.keys(opts.pkg.devDependencies || {})
|
|
138
|
+
// .concat(Object.keys(opts.pkg.dependencies || {}))
|
|
139
|
+
// .filter(Plugin.isPluginOrPreset.bind(null, type)),
|
|
140
|
+
// user config
|
|
130
141
|
...opts.userConfig[types] || []
|
|
131
142
|
].map((path) => {
|
|
132
143
|
(0, import_assert.default)(
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -135,7 +139,9 @@ var PluginAPI = class {
|
|
|
135
139
|
);
|
|
136
140
|
this.service.pluginMethods[opts.name] = {
|
|
137
141
|
plugin: this.plugin,
|
|
138
|
-
fn: opts.fn || function
|
|
142
|
+
fn: opts.fn || // 这里不能用 arrow function,this 需指向执行此方法的 PluginAPI
|
|
143
|
+
// 否则 pluginId 会不会,导致不能正确 skip plugin
|
|
144
|
+
function(fn) {
|
|
139
145
|
this.register({
|
|
140
146
|
key: opts.name,
|
|
141
147
|
...import_utils.lodash.isPlainObject(fn) ? fn : { fn }
|
package/dist/service/service.js
CHANGED
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -53,6 +57,7 @@ var Service = class {
|
|
|
53
57
|
this.hooks = {};
|
|
54
58
|
this.name = "";
|
|
55
59
|
this.paths = {};
|
|
60
|
+
// preset is plugin with different type
|
|
56
61
|
this.plugins = {};
|
|
57
62
|
this.keyToPluginMap = {};
|
|
58
63
|
this.pluginMethods = {};
|
|
@@ -257,16 +262,16 @@ var Service = class {
|
|
|
257
262
|
throw Error(`Invalid command ${import_utils.chalk.red(name)}, it's not registered.`);
|
|
258
263
|
}
|
|
259
264
|
for (const id of Object.keys(this.plugins)) {
|
|
260
|
-
const { config
|
|
261
|
-
if (
|
|
262
|
-
this.configSchemas[key] =
|
|
263
|
-
if (
|
|
264
|
-
this.configDefaults[key] =
|
|
265
|
+
const { config, key } = this.plugins[id];
|
|
266
|
+
if (config.schema)
|
|
267
|
+
this.configSchemas[key] = config.schema;
|
|
268
|
+
if (config.default !== void 0) {
|
|
269
|
+
this.configDefaults[key] = config.default;
|
|
265
270
|
}
|
|
266
|
-
this.configOnChanges[key] =
|
|
271
|
+
this.configOnChanges[key] = config.onChange || import_types.ConfigChangeType.reload;
|
|
267
272
|
}
|
|
268
273
|
this.stage = import_types.ServiceStage.resolveConfig;
|
|
269
|
-
const {
|
|
274
|
+
const { defaultConfig } = await this.resolveConfig();
|
|
270
275
|
if (this.config.outputPath) {
|
|
271
276
|
this.paths.absOutputPath = (0, import_path.isAbsolute)(this.config.outputPath) ? this.config.outputPath : (0, import_path.join)(this.cwd, this.config.outputPath);
|
|
272
277
|
}
|
|
@@ -278,17 +283,30 @@ var Service = class {
|
|
|
278
283
|
this.appData = await this.applyPlugins({
|
|
279
284
|
key: "modifyAppData",
|
|
280
285
|
initialValue: {
|
|
286
|
+
// base
|
|
281
287
|
cwd: this.cwd,
|
|
282
288
|
pkg,
|
|
283
289
|
pkgPath,
|
|
284
|
-
plugins,
|
|
290
|
+
plugins: this.plugins,
|
|
285
291
|
presets,
|
|
286
292
|
name,
|
|
287
293
|
args,
|
|
294
|
+
// config
|
|
288
295
|
userConfig: this.userConfig,
|
|
289
296
|
mainConfigFile: configManager.mainConfigFile,
|
|
290
|
-
config,
|
|
297
|
+
config: this.config,
|
|
291
298
|
defaultConfig
|
|
299
|
+
// TODO
|
|
300
|
+
// moduleGraph,
|
|
301
|
+
// routes,
|
|
302
|
+
// npmClient,
|
|
303
|
+
// nodeVersion,
|
|
304
|
+
// gitInfo,
|
|
305
|
+
// gitBranch,
|
|
306
|
+
// debugger info,
|
|
307
|
+
// devPort,
|
|
308
|
+
// devHost,
|
|
309
|
+
// env
|
|
292
310
|
}
|
|
293
311
|
});
|
|
294
312
|
this.stage = import_types.ServiceStage.onCheck;
|
|
@@ -320,6 +338,9 @@ var Service = class {
|
|
|
320
338
|
const resolveMode = this.commands[this.name].configResolveMode;
|
|
321
339
|
const config = await this.applyPlugins({
|
|
322
340
|
key: "modifyConfig",
|
|
341
|
+
// why clone deep?
|
|
342
|
+
// user may change the config in modifyConfig
|
|
343
|
+
// e.g. memo.alias = xxx
|
|
323
344
|
initialValue: import_utils.lodash.cloneDeep(
|
|
324
345
|
resolveMode === "strict" ? this.configManager.getConfig({
|
|
325
346
|
schemas: this.configSchemas
|
|
@@ -329,6 +350,7 @@ var Service = class {
|
|
|
329
350
|
});
|
|
330
351
|
const defaultConfig = await this.applyPlugins({
|
|
331
352
|
key: "modifyDefaultConfig",
|
|
353
|
+
// 避免 modifyDefaultConfig 时修改 this.configDefaults
|
|
332
354
|
initialValue: import_utils.lodash.cloneDeep(this.configDefaults)
|
|
333
355
|
});
|
|
334
356
|
this.config = import_utils.lodash.merge(defaultConfig, config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.53",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/core#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
6
6
|
"repository": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"test": "umi-scripts jest-turbo"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@umijs/bundler-utils": "4.0.
|
|
25
|
-
"@umijs/utils": "4.0.
|
|
24
|
+
"@umijs/bundler-utils": "4.0.53",
|
|
25
|
+
"@umijs/utils": "4.0.53"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"dotenv": "16.0.0",
|