@umijs/mfsu 4.0.0-canary.20220831.2 → 4.0.0-canary.20220920.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/dist/dep/dep.js CHANGED
@@ -1,26 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  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
7
  var __export = (target, all) => {
25
8
  for (var name in all)
26
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -84,7 +67,10 @@ export * from '${this.file}';
84
67
  `);
85
68
  }
86
69
  const realFile = await this.getRealFile();
87
- (0, import_assert.default)(realFile, `filePath not found of ${this.file}`);
70
+ if (!realFile) {
71
+ import_utils.logger.error(`Can not resolve dependence : '${import_utils.chalk.red(this.file)}', please install it`);
72
+ }
73
+ (0, import_assert.default)(realFile, `dependence not found: ${this.file}`);
88
74
  const content = (0, import_fs.readFileSync)(realFile, "utf-8");
89
75
  return await (0, import_getExposeFromContent.getExposeFromContent)({
90
76
  content,
@@ -101,10 +87,11 @@ export * from '${this.file}';
101
87
  }
102
88
  static buildDeps(opts) {
103
89
  return Object.keys(opts.deps).map((file) => {
104
- return new Dep(__spreadProps(__spreadValues({}, opts.deps[file]), {
90
+ return new Dep({
91
+ ...opts.deps[file],
105
92
  cwd: opts.cwd,
106
93
  excludeNodeNatives: opts.mfsu.opts.excludeNodeNatives
107
- }));
94
+ });
108
95
  });
109
96
  }
110
97
  static getDepVersion(opts) {
@@ -1,24 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
4
  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
5
  var __export = (target, all) => {
23
6
  for (var name in all)
24
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -87,11 +70,12 @@ var DepBuilder = class {
87
70
  entry: {
88
71
  [`${import_constants.MF_VA_PREFIX}remoteEntry`]: entryPath
89
72
  },
90
- config: __spreadProps(__spreadValues({}, this.opts.mfsu.opts.depBuildConfig), {
73
+ config: {
74
+ ...this.opts.mfsu.opts.depBuildConfig,
91
75
  outputPath: tmpDir,
92
76
  alias: this.opts.mfsu.alias,
93
77
  externals: this.opts.mfsu.externals
94
- }),
78
+ },
95
79
  inlineStyle: true
96
80
  });
97
81
  import_utils.logger.event(`[mfsu] compiled with esbuild successfully in ${+new Date() - date} ms`);
@@ -137,9 +121,10 @@ var DepBuilder = class {
137
121
  this.completeFns = [];
138
122
  };
139
123
  try {
140
- const buildOpts = __spreadProps(__spreadValues({}, opts), {
124
+ const buildOpts = {
125
+ ...opts,
141
126
  onBuildComplete
142
- });
127
+ };
143
128
  if (this.opts.mfsu.opts.strategy === "eager") {
144
129
  await this.buildWithWorker(buildOpts);
145
130
  return;
@@ -1,36 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
4
  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 __objRest = (source, exclude) => {
23
- var target = {};
24
- for (var prop in source)
25
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
- target[prop] = source[prop];
27
- if (source != null && __getOwnPropSymbols)
28
- for (var prop of __getOwnPropSymbols(source)) {
29
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
- target[prop] = source[prop];
31
- }
32
- return target;
33
- };
34
5
  var __export = (target, all) => {
35
6
  for (var name in all)
36
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -58,16 +29,17 @@ var import_path = require("path");
58
29
  async function esbuildTranspiler(source) {
59
30
  const done = this.async();
60
31
  const options = this.getOptions();
61
- const _a = options, { handler = [], implementation } = _a, otherOptions = __objRest(_a, ["handler", "implementation"]);
32
+ const { handler = [], implementation, ...otherOptions } = options;
62
33
  const transform = (implementation == null ? void 0 : implementation.transform) || import_esbuild.transform;
63
34
  const filePath = this.resourcePath;
64
35
  const ext = (0, import_path.extname)(filePath).slice(1);
65
- const transformOptions = __spreadProps(__spreadValues({}, otherOptions), {
36
+ const transformOptions = {
37
+ ...otherOptions,
66
38
  target: options.target ?? "es2015",
67
39
  loader: ext ?? "js",
68
40
  sourcemap: this.sourceMap,
69
41
  sourcefile: filePath
70
- });
42
+ };
71
43
  try {
72
44
  let { code, map } = await transform(source, transformOptions);
73
45
  if (handler.length) {
@@ -26,7 +26,6 @@ interface IOpts {
26
26
  shared?: any;
27
27
  remoteName?: string;
28
28
  remoteAliases?: string[];
29
- serverBase?: string;
30
29
  startBuildWorker: (dep: any[]) => Worker;
31
30
  }
32
31
  export declare class MFSU {
@@ -40,6 +39,7 @@ export declare class MFSU {
40
39
  onProgress: Function;
41
40
  publicPath: string;
42
41
  private strategy;
42
+ private lastBuildError;
43
43
  constructor(opts: IOpts);
44
44
  asyncImport(content: string): string;
45
45
  setWebpackConfig(opts: {
package/dist/mfsu/mfsu.js CHANGED
@@ -2,22 +2,8 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
5
  var __getProtoOf = Object.getPrototypeOf;
7
6
  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
7
  var __export = (target, all) => {
22
8
  for (var name in all)
23
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -64,6 +50,7 @@ var MFSU = class {
64
50
  this.buildDepsAgain = false;
65
51
  this.progress = { done: false };
66
52
  this.publicPath = "/";
53
+ this.lastBuildError = null;
67
54
  this.opts = opts;
68
55
  this.opts.mfName = this.opts.mfName || import_constants.DEFAULT_MF_NAME;
69
56
  this.opts.tmpBase = this.opts.tmpBase || (0, import_path.join)(process.cwd(), import_constants.DEFAULT_TMP_DIR_NAME);
@@ -71,7 +58,10 @@ var MFSU = class {
71
58
  this.opts.getCacheDependency = this.opts.getCacheDependency || (() => ({}));
72
59
  this.onProgress = (progress) => {
73
60
  var _a, _b;
74
- this.progress = __spreadValues(__spreadValues({}, this.progress), progress);
61
+ this.progress = {
62
+ ...this.progress,
63
+ ...progress
64
+ };
75
65
  (_b = (_a = this.opts).onMFSUProgress) == null ? void 0 : _b.call(_a, this.progress);
76
66
  };
77
67
  this.opts.cwd = this.opts.cwd || process.cwd();
@@ -184,7 +174,7 @@ promise new Promise(resolve => {
184
174
  // inject this script with the src set to the versioned remoteEntry.js
185
175
  document.head.appendChild(script);
186
176
  })
187
- `.trimLeft() : `${mfName}@${this.opts.serverBase || ""}${publicPath}${import_constants.REMOTE_FILE_FULL}`
177
+ `.trimLeft() : `${mfName}@${publicPath}${import_constants.REMOTE_FILE_FULL}`
188
178
  }
189
179
  }),
190
180
  new import_buildDepPlugin.BuildDepPlugin(this.strategy.getBuildDepPlugConfig())
@@ -194,30 +184,36 @@ promise new Promise(resolve => {
194
184
  this.strategy.init();
195
185
  }
196
186
  async buildDeps() {
197
- const shouldBuild = this.strategy.shouldBuild();
198
- if (!shouldBuild) {
199
- import_utils.logger.info("[MFSU] skip buildDeps");
200
- return;
201
- }
202
- this.strategy.refresh();
203
- const staticDeps = this.strategy.getDepModules();
204
- const deps = import_dep.Dep.buildDeps({
205
- deps: staticDeps,
206
- cwd: this.opts.cwd,
207
- mfsu: this
208
- });
209
- import_utils.logger.info(`[MFSU] buildDeps since ${shouldBuild}`);
210
- import_utils.logger.debug(deps.map((dep) => dep.file).join(", "));
211
- await this.depBuilder.build({
212
- deps
213
- });
214
- this.strategy.writeCache();
215
- if (this.buildDepsAgain) {
216
- import_utils.logger.info("[MFSU] buildDepsAgain");
217
- this.buildDepsAgain = false;
218
- this.buildDeps().catch((e) => {
219
- import_utils.printHelp.runtime(e);
187
+ try {
188
+ const shouldBuild = this.strategy.shouldBuild();
189
+ if (!shouldBuild) {
190
+ import_utils.logger.info("[MFSU] skip buildDeps");
191
+ return;
192
+ }
193
+ this.strategy.refresh();
194
+ const staticDeps = this.strategy.getDepModules();
195
+ const deps = import_dep.Dep.buildDeps({
196
+ deps: staticDeps,
197
+ cwd: this.opts.cwd,
198
+ mfsu: this
220
199
  });
200
+ import_utils.logger.info(`[MFSU] buildDeps since ${shouldBuild}`);
201
+ import_utils.logger.debug(deps.map((dep) => dep.file).join(", "));
202
+ await this.depBuilder.build({
203
+ deps
204
+ });
205
+ this.lastBuildError = null;
206
+ this.strategy.writeCache();
207
+ if (this.buildDepsAgain) {
208
+ import_utils.logger.info("[MFSU] buildDepsAgain");
209
+ this.buildDepsAgain = false;
210
+ this.buildDeps().catch((e) => {
211
+ import_utils.printHelp.runtime(e);
212
+ });
213
+ }
214
+ } catch (e) {
215
+ this.lastBuildError = e;
216
+ throw e;
221
217
  }
222
218
  }
223
219
  getMiddlewares() {
@@ -233,7 +229,16 @@ promise new Promise(resolve => {
233
229
  }
234
230
  res.setHeader("content-type", (0, import_mrmime.lookup)((0, import_path.extname)(req.path)) || "text/plain");
235
231
  const relativePath = req.path.replace(new RegExp(`^${relativePublicPath}`), "/");
236
- const content = (0, import_fs.readFileSync)((0, import_path.join)(this.opts.tmpBase, relativePath));
232
+ const realFilePath = (0, import_path.join)(this.opts.tmpBase, relativePath);
233
+ if (!(0, import_fs.existsSync)(realFilePath)) {
234
+ import_utils.logger.error(`MFSU dist file: ${realFilePath} not found`);
235
+ if (this.lastBuildError) {
236
+ import_utils.logger.error(`MFSU latest build error: `, this.lastBuildError);
237
+ }
238
+ res.status(404);
239
+ return res.end();
240
+ }
241
+ const content = (0, import_fs.readFileSync)(realFilePath);
237
242
  res.send(content);
238
243
  });
239
244
  } else {
@@ -1,24 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
4
  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
5
  var __export = (target, all) => {
23
6
  for (var name in all)
24
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -192,7 +175,7 @@ var ModuleGraph = class {
192
175
  this.deleteNode({ mod: importedModulesMap[key], importer: opts.mod });
193
176
  });
194
177
  newDeps.forEach((dep) => {
195
- this.addNode(__spreadProps(__spreadValues({}, dep), { importer: opts.mod }));
178
+ this.addNode({ ...dep, importer: opts.mod });
196
179
  });
197
180
  }
198
181
  addNode(opts) {
@@ -1,26 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  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
7
  var __export = (target, all) => {
25
8
  for (var name in all)
26
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -185,12 +168,13 @@ var StaticDepInfo = class {
185
168
  opts
186
169
  });
187
170
  if (match.isMatch) {
188
- matched[match.value] = __spreadProps(__spreadValues({}, match), {
171
+ matched[match.value] = {
172
+ ...match,
189
173
  version: import_dep.Dep.getDepVersion({
190
174
  dep: match.value,
191
175
  cwd
192
176
  })
193
- });
177
+ };
194
178
  } else {
195
179
  unMatched.add(imp.n);
196
180
  }
@@ -230,12 +214,13 @@ var StaticDepInfo = class {
230
214
  opts
231
215
  });
232
216
  if (match.isMatch) {
233
- matched[match.value] = __spreadProps(__spreadValues({}, match), {
217
+ matched[match.value] = {
218
+ ...match,
234
219
  version: import_dep.Dep.getDepVersion({
235
220
  dep: match.value,
236
221
  cwd: this.cwd
237
222
  })
238
- });
223
+ };
239
224
  }
240
225
  }
241
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/mfsu",
3
- "version": "4.0.0-canary.20220831.2",
3
+ "version": "4.0.0-canary.20220920.1",
4
4
  "description": "@umijs/mfsu",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/mfsu#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -23,9 +23,9 @@
23
23
  "test": "umi-scripts jest-turbo"
24
24
  },
25
25
  "dependencies": {
26
- "@umijs/bundler-esbuild": "4.0.0-canary.20220831.2",
27
- "@umijs/bundler-utils": "4.0.0-canary.20220831.2",
28
- "@umijs/utils": "4.0.0-canary.20220831.2",
26
+ "@umijs/bundler-esbuild": "4.0.0-canary.20220920.1",
27
+ "@umijs/bundler-utils": "4.0.0-canary.20220920.1",
28
+ "@umijs/utils": "4.0.0-canary.20220920.1",
29
29
  "enhanced-resolve": "5.9.3",
30
30
  "is-equal": "^1.6.4"
31
31
  },