@umijs/core 4.6.62 → 4.6.63

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.
@@ -42,23 +42,20 @@ var import_just_diff = require("../../compiled/just-diff");
42
42
  var import_constants = require("../constants");
43
43
  var import_types = require("../types");
44
44
  var import_utils2 = require("./utils");
45
- var Config = class _Config {
46
- opts;
47
- mainConfigFile;
48
- prevConfig;
49
- files = [];
45
+ var Config = class {
50
46
  constructor(opts) {
47
+ this.files = [];
51
48
  this.opts = opts;
52
- this.mainConfigFile = _Config.getMainConfigFile(this.opts);
49
+ this.mainConfigFile = Config.getMainConfigFile(this.opts);
53
50
  this.prevConfig = null;
54
51
  }
55
52
  getUserConfig() {
56
- const configFiles = _Config.getConfigFiles({
53
+ const configFiles = Config.getConfigFiles({
57
54
  mainConfigFile: this.mainConfigFile,
58
55
  env: this.opts.env,
59
56
  specifiedEnv: this.opts.specifiedEnv
60
57
  });
61
- return _Config.getUserConfig({
58
+ return Config.getUserConfig({
62
59
  configFiles: (0, import_utils2.getAbsFiles)({
63
60
  files: configFiles,
64
61
  cwd: this.opts.cwd
@@ -67,7 +64,7 @@ var Config = class _Config {
67
64
  }
68
65
  getConfig(opts) {
69
66
  const { config, files } = this.getUserConfig();
70
- _Config.validateConfig({ config, schemas: opts.schemas });
67
+ Config.validateConfig({ config, schemas: opts.schemas });
71
68
  this.files = files;
72
69
  return this.prevConfig = {
73
70
  config,
@@ -96,7 +93,7 @@ var Config = class _Config {
96
93
  schemas: opts.schemas
97
94
  });
98
95
  watcher.add(files);
99
- const data = _Config.diffConfigs({
96
+ const data = Config.diffConfigs({
100
97
  origin,
101
98
  updated,
102
99
  onChangeTypes: opts.onChangeTypes
@@ -184,18 +181,21 @@ var Config = class _Config {
184
181
  const configKeys = new Set(Object.keys(opts.config));
185
182
  for (const key of Object.keys(opts.schemas)) {
186
183
  configKeys.delete(key);
187
- if (!opts.config[key]) continue;
184
+ if (!opts.config[key])
185
+ continue;
188
186
  const schema = opts.schemas[key]({ ...import_joi.default, zod: import_utils.zod });
189
187
  if (import_joi.default.isSchema(schema)) {
190
188
  const { error } = schema.validate(opts.config[key]);
191
- if (error) errors.set(key, error);
189
+ if (error)
190
+ errors.set(key, error);
192
191
  } else {
193
192
  (0, import_assert.default)(
194
193
  (0, import_utils.isZodSchema)(schema),
195
194
  `schema for config ${key} is not valid, neither joi nor zod.`
196
195
  );
197
196
  const { error } = schema.safeParse(opts.config[key]);
198
- if (error) errors.set(key, error);
197
+ if (error)
198
+ errors.set(key, error);
199
199
  }
200
200
  }
201
201
  (0, import_assert.default)(
@@ -23,13 +23,6 @@ __export(command_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(command_exports);
25
25
  var Command = class {
26
- name;
27
- description;
28
- options;
29
- details;
30
- configResolveMode;
31
- fn;
32
- plugin;
33
26
  constructor(opts) {
34
27
  this.name = opts.name;
35
28
  this.description = opts.description;
@@ -32,7 +32,8 @@ function loadEnv(opts) {
32
32
  (0, import_path.join)(opts.cwd, `${opts.envFile}.local`)
33
33
  ];
34
34
  for (const file of files) {
35
- if (!(0, import_fs.existsSync)(file)) continue;
35
+ if (!(0, import_fs.existsSync)(file))
36
+ continue;
36
37
  const parsed = (0, import_dotenv.parse)((0, import_fs.readFileSync)(file)) || {};
37
38
  (0, import_dotenv_expand.expand)({ parsed, ignoreProcessEnv: true });
38
39
  for (const key of Object.keys(parsed)) {
@@ -34,11 +34,6 @@ __export(hook_exports, {
34
34
  module.exports = __toCommonJS(hook_exports);
35
35
  var import_assert = __toESM(require("assert"));
36
36
  var Hook = class {
37
- plugin;
38
- key;
39
- fn;
40
- before;
41
- stage;
42
37
  constructor(opts) {
43
38
  (0, import_assert.default)(
44
39
  opts.key && opts.fn,
@@ -42,17 +42,11 @@ var RE = {
42
42
  plugin: /^(@umijs\/|umi-)plugin-/,
43
43
  preset: /^(@umijs\/|umi-)preset-/
44
44
  };
45
- var Plugin = class _Plugin {
46
- cwd;
47
- type;
48
- path;
49
- id;
50
- key;
51
- apply;
52
- config = {};
53
- time = { hooks: {} };
54
- enableBy = import_types.EnableBy.register;
45
+ var Plugin = class {
55
46
  constructor(opts) {
47
+ this.config = {};
48
+ this.time = { hooks: {} };
49
+ this.enableBy = import_types.EnableBy.register;
56
50
  this.type = opts.type;
57
51
  this.path = (0, import_utils.winPath)(opts.path);
58
52
  this.cwd = opts.cwd;
@@ -90,9 +84,12 @@ var Plugin = class _Plugin {
90
84
  };
91
85
  }
92
86
  merge(opts) {
93
- if (opts.key) this.key = opts.key;
94
- if (opts.config) this.config = opts.config;
95
- if (opts.enableBy) this.enableBy = opts.enableBy;
87
+ if (opts.key)
88
+ this.key = opts.key;
89
+ if (opts.config)
90
+ this.config = opts.config;
91
+ if (opts.enableBy)
92
+ this.enableBy = opts.enableBy;
96
93
  }
97
94
  getId(opts) {
98
95
  let id;
@@ -116,11 +113,11 @@ var Plugin = class _Plugin {
116
113
  return name.split(".").map((part) => import_utils.lodash.camelCase(part)).join(".");
117
114
  }
118
115
  return nameToKey(
119
- opts.isPkgEntry ? _Plugin.stripNoneUmiScope(opts.pkg.name).replace(RE[this.type], "") : (0, import_path.basename)(this.path, (0, import_path.extname)(this.path))
116
+ opts.isPkgEntry ? Plugin.stripNoneUmiScope(opts.pkg.name).replace(RE[this.type], "") : (0, import_path.basename)(this.path, (0, import_path.extname)(this.path))
120
117
  );
121
118
  }
122
119
  static isPluginOrPreset(type, name) {
123
- return RE[type].test(_Plugin.stripNoneUmiScope(name));
120
+ return RE[type].test(Plugin.stripNoneUmiScope(name));
124
121
  }
125
122
  static stripNoneUmiScope(name) {
126
123
  if (name.charAt(0) === "@" && !name.startsWith("@umijs/")) {
@@ -158,7 +155,7 @@ var Plugin = class _Plugin {
158
155
  cause: _e
159
156
  });
160
157
  }
161
- return new _Plugin({
158
+ return new Plugin({
162
159
  path: resolved,
163
160
  type,
164
161
  cwd: opts.cwd
@@ -42,10 +42,6 @@ var import_plugin = require("./plugin");
42
42
  var import_utils2 = require("./utils");
43
43
  var resolveConfigModes = ["strict", "loose"];
44
44
  var PluginAPI = class {
45
- service;
46
- plugin;
47
- logger;
48
- telemetry;
49
45
  constructor(opts) {
50
46
  this.service = opts.service;
51
47
  this.plugin = opts.plugin;
@@ -27,7 +27,6 @@ export declare class Service {
27
27
  framework?: IFrameworkType;
28
28
  prepare?: {
29
29
  buildResult: Omit<BuildResult, 'outputFiles'>;
30
- fileImports?: Record<string, Declaration[]>;
31
30
  };
32
31
  mpa?: {
33
32
  entry?: {
@@ -152,52 +151,4 @@ export interface IServicePluginAPI {
152
151
  registerPresets: (presets: any[]) => void;
153
152
  registerPlugins: (plugins: (Plugin | {})[]) => void;
154
153
  }
155
- declare type DeclareKind = 'value' | 'type';
156
- declare type Declaration = {
157
- type: 'ImportDeclaration';
158
- source: string;
159
- specifiers: Array<SimpleImportSpecifier>;
160
- importKind: DeclareKind;
161
- start: number;
162
- end: number;
163
- } | {
164
- type: 'DynamicImport';
165
- source: string;
166
- start: number;
167
- end: number;
168
- } | {
169
- type: 'ExportNamedDeclaration';
170
- source: string;
171
- specifiers: Array<SimpleExportSpecifier>;
172
- exportKind: DeclareKind;
173
- start: number;
174
- end: number;
175
- } | {
176
- type: 'ExportAllDeclaration';
177
- source: string;
178
- start: number;
179
- end: number;
180
- };
181
- declare type SimpleImportSpecifier = {
182
- type: 'ImportDefaultSpecifier';
183
- local: string;
184
- } | {
185
- type: 'ImportNamespaceSpecifier';
186
- local: string;
187
- imported: string;
188
- } | {
189
- type: 'ImportNamespaceSpecifier';
190
- local?: string;
191
- };
192
- declare type SimpleExportSpecifier = {
193
- type: 'ExportDefaultSpecifier';
194
- exported: string;
195
- } | {
196
- type: 'ExportNamespaceSpecifier';
197
- exported?: string;
198
- } | {
199
- type: 'ExportSpecifier';
200
- exported: string;
201
- local: string;
202
- };
203
154
  export {};
@@ -24,9 +24,17 @@ __export(telemetry_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(telemetry_exports);
26
26
  var Telemetry = class {
27
- queuedEvents = [];
28
- storage = new NoopStorage();
29
27
  constructor() {
28
+ this.queuedEvents = [];
29
+ this.storage = new NoopStorage();
30
+ this.afterFlush = () => {
31
+ const un = this.unFinishedEvents();
32
+ if (un.length) {
33
+ this.scheduleFlush();
34
+ } else {
35
+ this.queuedEvents = [];
36
+ }
37
+ };
30
38
  }
31
39
  prefixWith(prefix) {
32
40
  const upStream = this;
@@ -91,14 +99,6 @@ var Telemetry = class {
91
99
  this.flush().then(this.afterFlush, this.afterFlush);
92
100
  }, 5e3);
93
101
  }
94
- afterFlush = () => {
95
- const un = this.unFinishedEvents();
96
- if (un.length) {
97
- this.scheduleFlush();
98
- } else {
99
- this.queuedEvents = [];
100
- }
101
- };
102
102
  unFinishedEvents() {
103
103
  return this.queuedEvents.filter((e) => {
104
104
  if (e.status === "sent") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/core",
3
- "version": "4.6.62",
3
+ "version": "4.6.63",
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": {
@@ -15,8 +15,8 @@
15
15
  "compiled"
16
16
  ],
17
17
  "dependencies": {
18
- "@umijs/bundler-utils": "4.6.62",
19
- "@umijs/utils": "4.6.62"
18
+ "@umijs/bundler-utils": "4.6.63",
19
+ "@umijs/utils": "4.6.63"
20
20
  },
21
21
  "devDependencies": {
22
22
  "dotenv": "16.0.0",