@umijs/core 4.0.0-rc.5 → 4.0.0-rc.6
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/service/path.d.ts
CHANGED
package/dist/service/path.js
CHANGED
|
@@ -13,6 +13,7 @@ function getPaths(opts) {
|
|
|
13
13
|
const src = winJoin(cwd, 'src');
|
|
14
14
|
const absSrcPath = (0, fs_1.existsSync)(src) && (0, fs_1.statSync)(src).isDirectory() ? src : cwd;
|
|
15
15
|
const absPagesPath = winJoin(absSrcPath, 'pages');
|
|
16
|
+
const absApiRoutesPath = winJoin(absSrcPath, 'api');
|
|
16
17
|
const tmp = opts.env === types_1.Env.development
|
|
17
18
|
? `.${opts.prefix}`
|
|
18
19
|
: `.${opts.prefix}-${opts.env}`;
|
|
@@ -23,6 +24,7 @@ function getPaths(opts) {
|
|
|
23
24
|
cwd,
|
|
24
25
|
absSrcPath,
|
|
25
26
|
absPagesPath,
|
|
27
|
+
absApiRoutesPath,
|
|
26
28
|
absTmpPath,
|
|
27
29
|
absNodeModulesPath,
|
|
28
30
|
absOutputPath,
|
|
@@ -33,7 +33,7 @@ export declare class PluginAPI {
|
|
|
33
33
|
}): void;
|
|
34
34
|
registerPresets(source: Plugin[], presets: any[]): void;
|
|
35
35
|
registerPlugins(source: Plugin[], plugins: any[]): void;
|
|
36
|
-
skipPlugins(
|
|
36
|
+
skipPlugins(keys: string[]): void;
|
|
37
37
|
static proxyPluginAPI(opts: {
|
|
38
38
|
pluginAPI: PluginAPI;
|
|
39
39
|
service: Service;
|
|
@@ -116,9 +116,11 @@ class PluginAPI {
|
|
|
116
116
|
source.splice(0, 0, ...mappedPlugins);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
skipPlugins(
|
|
120
|
-
|
|
121
|
-
this.
|
|
119
|
+
skipPlugins(keys) {
|
|
120
|
+
keys.forEach((key) => {
|
|
121
|
+
(0, assert_1.default)(!(this.plugin.key === key), `plugin ${key} can't skip itself!`);
|
|
122
|
+
(0, assert_1.default)(this.service.keyToPluginMap[key], `key: ${key} is not be registered by any plugin. You can't skip it!`);
|
|
123
|
+
this.service.skipPluginIds.add(this.service.keyToPluginMap[key].id);
|
|
122
124
|
});
|
|
123
125
|
}
|
|
124
126
|
static proxyPluginAPI(opts) {
|
package/dist/service/service.js
CHANGED
|
@@ -81,7 +81,7 @@ class Service {
|
|
|
81
81
|
if (!this.isPluginEnable(hook))
|
|
82
82
|
continue;
|
|
83
83
|
tAdd.tapPromise({
|
|
84
|
-
name: hook.plugin.
|
|
84
|
+
name: hook.plugin.key,
|
|
85
85
|
stage: hook.stage,
|
|
86
86
|
before: hook.before,
|
|
87
87
|
}, (memo) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -96,7 +96,7 @@ class Service {
|
|
|
96
96
|
if (!this.isPluginEnable(hook))
|
|
97
97
|
continue;
|
|
98
98
|
tModify.tapPromise({
|
|
99
|
-
name: hook.plugin.
|
|
99
|
+
name: hook.plugin.key,
|
|
100
100
|
stage: hook.stage,
|
|
101
101
|
before: hook.before,
|
|
102
102
|
}, (memo) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -110,7 +110,7 @@ class Service {
|
|
|
110
110
|
if (!this.isPluginEnable(hook))
|
|
111
111
|
continue;
|
|
112
112
|
tEvent.tapPromise({
|
|
113
|
-
name: hook.plugin.
|
|
113
|
+
name: hook.plugin.key,
|
|
114
114
|
stage: hook.stage || 0,
|
|
115
115
|
before: hook.before,
|
|
116
116
|
}, () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -187,10 +187,6 @@ class Service {
|
|
|
187
187
|
while (plugins.length) {
|
|
188
188
|
yield this.initPlugin({ plugin: plugins.shift(), plugins });
|
|
189
189
|
}
|
|
190
|
-
// keyToPluginMap
|
|
191
|
-
for (const id of Object.keys(this.plugins)) {
|
|
192
|
-
this.keyToPluginMap[this.plugins[id].key] = this.plugins[id];
|
|
193
|
-
}
|
|
194
190
|
// collect configSchemas and configDefaults
|
|
195
191
|
for (const id of Object.keys(this.plugins)) {
|
|
196
192
|
const { config, key } = this.plugins[id];
|
|
@@ -291,7 +287,7 @@ class Service {
|
|
|
291
287
|
});
|
|
292
288
|
}
|
|
293
289
|
initPlugin(opts) {
|
|
294
|
-
var _a;
|
|
290
|
+
var _a, _b;
|
|
295
291
|
return __awaiter(this, void 0, void 0, function* () {
|
|
296
292
|
// register to this.plugins
|
|
297
293
|
(0, assert_1.default)(!this.plugins[opts.plugin.id], `${opts.plugin.type} ${opts.plugin.id} is already registered by ${(_a = this.plugins[opts.plugin.id]) === null || _a === void 0 ? void 0 : _a.path}, ${opts.plugin.type} from ${opts.plugin.path} register failed.`);
|
|
@@ -335,6 +331,9 @@ class Service {
|
|
|
335
331
|
if (opts.plugin.type === 'plugin') {
|
|
336
332
|
(0, assert_1.default)(!ret, `plugin should return nothing`);
|
|
337
333
|
}
|
|
334
|
+
// key should be unique
|
|
335
|
+
(0, assert_1.default)(!this.keyToPluginMap[opts.plugin.key], `key ${opts.plugin.key} is already registered by ${(_b = this.keyToPluginMap[opts.plugin.key]) === null || _b === void 0 ? void 0 : _b.path}, ${opts.plugin.type} from ${opts.plugin.path} register failed.`);
|
|
336
|
+
this.keyToPluginMap[opts.plugin.key] = opts.plugin;
|
|
338
337
|
if (ret === null || ret === void 0 ? void 0 : ret.presets) {
|
|
339
338
|
ret.presets = ret.presets.map((preset) => new plugin_1.Plugin({
|
|
340
339
|
path: preset,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/core",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.6",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi-next/tree/master/packages/core#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi-next/issues",
|
|
6
6
|
"repository": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"dev": "pnpm build -- --watch"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@umijs/bundler-utils": "4.0.0-rc.
|
|
24
|
-
"@umijs/utils": "4.0.0-rc.
|
|
23
|
+
"@umijs/bundler-utils": "4.0.0-rc.6",
|
|
24
|
+
"@umijs/utils": "4.0.0-rc.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@hapi/joi": "17.1.1",
|