@umijs/mfsu 4.6.67 → 4.6.69

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.
@@ -1,5 +1,5 @@
1
- declare type IExternal = Record<string, string> | Function;
2
- declare type IExternals = IExternal[] | IExternal;
1
+ type IExternal = Record<string, string> | Function;
2
+ type IExternals = IExternal[] | IExternal;
3
3
  export declare function isExternals({ value, externals, }: {
4
4
  value: string;
5
5
  externals: IExternals;
@@ -4,5 +4,5 @@ export declare const MF_STATIC_PREFIX = "mf-static/";
4
4
  export declare const DEFAULT_MF_NAME = "mf";
5
5
  export declare const DEFAULT_TMP_DIR_NAME = ".mfsu";
6
6
  export declare const REMOTE_FILE = "remoteEntry.js";
7
- export declare const REMOTE_FILE_FULL: string;
7
+ export declare const REMOTE_FILE_FULL = "mf-va_remoteEntry.js";
8
8
  export declare const VIRTUAL_ENTRY_DIR = "mfsu-virtual-entry";
package/dist/dep/dep.js CHANGED
@@ -41,15 +41,7 @@ var import_constants = require("../constants");
41
41
  var import_resolveUtils = require("../utils/resolveUtils");
42
42
  var import_trimFileContent = require("../utils/trimFileContent");
43
43
  var import_getExposeFromContent = require("./getExposeFromContent");
44
- var Dep = class _Dep {
45
- file;
46
- version;
47
- cwd;
48
- shortFile;
49
- normalizedFile;
50
- filePath;
51
- excludeNodeNatives;
52
- importer;
44
+ var Dep = class {
53
45
  constructor(opts) {
54
46
  this.file = (0, import_utils.winPath)(opts.file);
55
47
  this.version = opts.version;
@@ -113,7 +105,7 @@ export * from '${this.file}';
113
105
  }
114
106
  static buildDeps(opts) {
115
107
  return Object.keys(opts.deps).map((file) => {
116
- return new _Dep({
108
+ return new Dep({
117
109
  ...opts.deps[file],
118
110
  cwd: opts.cwd,
119
111
  excludeNodeNatives: opts.mfsu.opts.excludeNodeNatives
@@ -59,7 +59,7 @@ export default _;`.trim();
59
59
  (0, import_utils.isJavaScriptFile)(opts.filePath),
60
60
  `file type not supported for ${(0, import_path.basename)(opts.filePath)}.`
61
61
  );
62
- const { exports: exports2, isCJS } = await (0, import_getModuleExports.getModuleExports)({
62
+ const { exports, isCJS } = await (0, import_getModuleExports.getModuleExports)({
63
63
  content: opts.content,
64
64
  filePath: opts.filePath
65
65
  });
@@ -72,12 +72,12 @@ export default _;`.trim();
72
72
  } else {
73
73
  const ret = [];
74
74
  let hasExports = false;
75
- if (exports2.includes("default")) {
75
+ if (exports.includes("default")) {
76
76
  ret.push(`import _ from '${importPath}';`);
77
77
  ret.push(`export default _;`);
78
78
  hasExports = true;
79
79
  }
80
- if (hasNonDefaultExports(exports2) || // export * from 不会有 exports,只会有 imports
80
+ if (hasNonDefaultExports(exports) || // export * from 不会有 exports,只会有 imports
81
81
  // case: export*from'.'
82
82
  // export * from '.'
83
83
  /export\s*\*\s*from/.test(opts.content)) {
@@ -85,7 +85,7 @@ export default _;`.trim();
85
85
  hasExports = true;
86
86
  }
87
87
  if (!hasExports) {
88
- if (exports2.includes("__esModule")) {
88
+ if (exports.includes("__esModule")) {
89
89
  ret.push(`import _ from '${importPath}';`);
90
90
  ret.push(`export default _;`);
91
91
  ret.push(`export * from '${importPath}';`);
@@ -96,8 +96,8 @@ export default _;`.trim();
96
96
  return ret.join("\n");
97
97
  }
98
98
  }
99
- function hasNonDefaultExports(exports2) {
100
- return exports2.filter((exp) => !["__esModule", "default"].includes(exp)).length > 0;
99
+ function hasNonDefaultExports(exports) {
100
+ return exports.filter((exp) => !["__esModule", "default"].includes(exp)).length > 0;
101
101
  }
102
102
  // Annotate the CommonJS export names for ESM import in node:
103
103
  0 && (module.exports = {
@@ -40,8 +40,8 @@ async function getModuleExports({
40
40
  })).code;
41
41
  }
42
42
  await import_es_module_lexer.init;
43
- const [imports, exports2] = (0, import_es_module_lexer.parse)(content);
44
- let isCJS = !imports.length && !exports2.length;
43
+ const [imports, exports] = (0, import_es_module_lexer.parse)(content);
44
+ let isCJS = !imports.length && !exports.length;
45
45
  let cjsEsmExports = null;
46
46
  if (isCJS) {
47
47
  cjsEsmExports = (0, import_getCJSExports.getCJSExports)({ content });
@@ -50,7 +50,7 @@ async function getModuleExports({
50
50
  }
51
51
  }
52
52
  return {
53
- exports: cjsEsmExports || exports2,
53
+ exports: cjsEsmExports || exports,
54
54
  isCJS
55
55
  };
56
56
  }
@@ -32,10 +32,9 @@ var import_stripSourceMapUrlPlugin = require("../webpackPlugins/stripSourceMapUr
32
32
  var import_getESBuildEntry = require("./getESBuildEntry");
33
33
  var MF_ENTRY = "mf_index.js";
34
34
  var DepBuilder = class {
35
- opts;
36
- completeFns = [];
37
- isBuilding = false;
38
35
  constructor(opts) {
36
+ this.completeFns = [];
37
+ this.isBuilding = false;
39
38
  this.opts = opts;
40
39
  }
41
40
  async buildWithWebpack(opts) {
@@ -170,8 +169,10 @@ var DepBuilder = class {
170
169
  depConfig.output.path = this.opts.mfsu.opts.tmpBase;
171
170
  depConfig.output.publicPath = "auto";
172
171
  depConfig.devtool = false;
173
- if ((_a = depConfig.output) == null ? void 0 : _a.library) delete depConfig.output.library;
174
- if ((_b = depConfig.output) == null ? void 0 : _b.libraryTarget) delete depConfig.output.libraryTarget;
172
+ if ((_a = depConfig.output) == null ? void 0 : _a.library)
173
+ delete depConfig.output.library;
174
+ if ((_b = depConfig.output) == null ? void 0 : _b.libraryTarget)
175
+ delete depConfig.output.libraryTarget;
175
176
  depConfig.optimization || (depConfig.optimization = {});
176
177
  depConfig.optimization.splitChunks = {
177
178
  chunks: (chunk) => {
package/dist/depInfo.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ModuleGraph } from './moduleGraph';
3
3
  interface IOpts {
4
4
  mfsu: MFSU;
5
5
  }
6
- export declare type DepModule = {
6
+ export type DepModule = {
7
7
  file: string;
8
8
  version: string;
9
9
  importer?: string;
@@ -22,7 +22,7 @@ export declare class DepInfo implements IDepInfo {
22
22
  moduleGraph: ModuleGraph;
23
23
  private cacheDependency;
24
24
  constructor(opts: IOpts);
25
- shouldBuild(): false | "cacheDependency has changed" | "moduleGraph has changed";
25
+ shouldBuild(): "cacheDependency has changed" | "moduleGraph has changed" | false;
26
26
  snapshot(): void;
27
27
  loadCache(): void;
28
28
  writeCache(): void;
package/dist/depInfo.js CHANGED
@@ -27,11 +27,9 @@ var import_fs = require("fs");
27
27
  var import_path = require("path");
28
28
  var import_moduleGraph = require("./moduleGraph");
29
29
  var DepInfo = class {
30
- opts;
31
- cacheFilePath;
32
- moduleGraph = new import_moduleGraph.ModuleGraph();
33
- cacheDependency = {};
34
30
  constructor(opts) {
31
+ this.moduleGraph = new import_moduleGraph.ModuleGraph();
32
+ this.cacheDependency = {};
35
33
  this.opts = opts;
36
34
  this.cacheFilePath = (0, import_path.join)(this.opts.mfsu.opts.tmpBase, "MFSU_CACHE.json");
37
35
  }
@@ -30,7 +30,8 @@ function getImportHandlerV4(params) {
30
30
  let { code } = opts;
31
31
  const { imports } = opts;
32
32
  imports.forEach((i) => {
33
- if (!i.n) return;
33
+ if (!i.n)
34
+ return;
34
35
  const isLazyImport = i.d > 0;
35
36
  const from = i.n;
36
37
  const replaceValue = params.resolveImportSource(from);
@@ -52,7 +53,8 @@ function getAwaitImportHandler(params) {
52
53
  let { code } = opts;
53
54
  const { filePath, imports } = opts;
54
55
  imports.forEach((i) => {
55
- if (!i.n) return;
56
+ if (!i.n)
57
+ return;
56
58
  const isLazyImport = i.d > 0;
57
59
  const from = i.n;
58
60
  const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
@@ -62,8 +62,8 @@ async function esbuildTranspiler(source) {
62
62
  if (handler.length) {
63
63
  await import_es_module_lexer.init;
64
64
  handler.forEach((handle) => {
65
- const [imports, exports2] = (0, import_es_module_lexer.parse)(code);
66
- code = handle({ code, imports, exports: exports2, filePath });
65
+ const [imports, exports] = (0, import_es_module_lexer.parse)(code);
66
+ code = handle({ code, imports, exports, filePath });
67
67
  });
68
68
  }
69
69
  done(null, code, map && JSON.parse(map));
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { NextFunction, Request, Response } from '@umijs/bundler-utils/compiled/express';
3
2
  import webpack, { Configuration } from 'webpack';
4
3
  import type { Worker } from 'worker_threads';
@@ -49,7 +48,7 @@ export declare class MFSU {
49
48
  buildDeps(opts?: {
50
49
  useWorker: boolean;
51
50
  }): Promise<void>;
52
- getMiddlewares(): (((req: Request, res: Response, next: NextFunction) => void) | import("@umijs/bundler-utils/compiled/express/serve-static").RequestHandler<Response<any, Record<string, any>>>)[];
51
+ getMiddlewares(): (import("@umijs/bundler-utils/compiled/express/serve-static").RequestHandler<Response<any, Record<string, any>>> | ((req: Request, res: Response, next: NextFunction) => void))[];
53
52
  getBabelPlugins(): any[][];
54
53
  getEsbuildLoaderHandler(): any[];
55
54
  getCacheFilePath(): string;
package/dist/mfsu/mfsu.js CHANGED
@@ -53,18 +53,14 @@ var import_buildDepPlugin = require("../webpackPlugins/buildDepPlugin");
53
53
  var import_strategyCompileTime = require("./strategyCompileTime");
54
54
  var import_strategyStaticAnalyze = require("./strategyStaticAnalyze");
55
55
  var MFSU = class {
56
- opts;
57
- alias = {};
58
- externals = [];
59
- depBuilder;
60
- depConfig = null;
61
- buildDepsAgain = false;
62
- progress = { done: false };
63
- onProgress;
64
- publicPath = "/";
65
- strategy;
66
- lastBuildError = null;
67
56
  constructor(opts) {
57
+ this.alias = {};
58
+ this.externals = [];
59
+ this.depConfig = null;
60
+ this.buildDepsAgain = false;
61
+ this.progress = { done: false };
62
+ this.publicPath = "/";
63
+ this.lastBuildError = null;
68
64
  this.opts = opts;
69
65
  this.opts.mfName = this.opts.mfName || import_constants.DEFAULT_MF_NAME;
70
66
  this.opts.tmpBase = this.opts.tmpBase || (0, import_path.join)(process.cwd(), import_constants.DEFAULT_TMP_DIR_NAME);
@@ -134,10 +130,10 @@ var MFSU = class {
134
130
  );
135
131
  entry2 = realEntry;
136
132
  const content = (0, import_fs.readFileSync)(entry2, "utf-8");
137
- const [_imports, exports2] = await (0, import_bundler_utils.parseModule)({ content, path: entry2 });
138
- if (exports2.length) {
133
+ const [_imports, exports] = await (0, import_bundler_utils.parseModule)({ content, path: entry2 });
134
+ if (exports.length) {
139
135
  virtualContent.push(`const k${index} = ${this.asyncImport(entry2)}`);
140
- for (const exportName of exports2) {
136
+ for (const exportName of exports) {
141
137
  if (exportName === "default") {
142
138
  hasDefaultExport = true;
143
139
  virtualContent.push(`export default k${index}.${exportName}`);
@@ -10,7 +10,7 @@ export declare class StrategyCompileTime implements IMFSUStrategy {
10
10
  getDepModules(): Record<string, DepModule>;
11
11
  getCacheFilePath(): string;
12
12
  init(): void;
13
- shouldBuild(): false | "cacheDependency has changed" | "moduleGraph has changed";
13
+ shouldBuild(): "cacheDependency has changed" | "moduleGraph has changed" | false;
14
14
  loadCache(): void;
15
15
  writeCache(): void;
16
16
  refresh(): void;
@@ -38,8 +38,6 @@ var import_getRealPath = require("../babelPlugins/awaitImport/getRealPath");
38
38
  var import_dep = require("../dep/dep");
39
39
  var import_depInfo = require("../depInfo");
40
40
  var StrategyCompileTime = class {
41
- mfsu;
42
- depInfo;
43
41
  constructor({ mfsu }) {
44
42
  this.mfsu = mfsu;
45
43
  this.depInfo = new import_depInfo.DepInfo({ mfsu });
@@ -14,7 +14,7 @@ export declare class StaticAnalyzeStrategy implements IMFSUStrategy {
14
14
  version: string;
15
15
  }>;
16
16
  getCacheFilePath(): string;
17
- shouldBuild(): false | "cacheDependency has changed" | "dependencies changed";
17
+ shouldBuild(): "cacheDependency has changed" | "dependencies changed" | false;
18
18
  writeCache(): void;
19
19
  getBabelPlugin(): any[];
20
20
  private getMfImportOpts;
@@ -38,8 +38,6 @@ var import_MFImport = __toESM(require("../babelPlugins/awaitImport/MFImport"));
38
38
  var import_staticDepInfo = require("../staticDepInfo/staticDepInfo");
39
39
  var import_webpackUtils = require("../utils/webpackUtils");
40
40
  var StaticAnalyzeStrategy = class {
41
- mfsu;
42
- staticDepInfo;
43
41
  constructor({ mfsu, srcCodeCache }) {
44
42
  this.mfsu = mfsu;
45
43
  this.staticDepInfo = new import_staticDepInfo.StaticDepInfo({
@@ -29,7 +29,7 @@ export declare class ModuleGraph {
29
29
  roots: string[];
30
30
  fileModules: Record<string, {
31
31
  importedModules: string[];
32
- isRoot?: boolean | undefined;
32
+ isRoot?: boolean;
33
33
  }>;
34
34
  depModules: Record<string, {
35
35
  version: string | null;
@@ -23,22 +23,21 @@ __export(moduleGraph_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(moduleGraph_exports);
25
25
  var ModuleNode = class {
26
- file;
27
- importers = /* @__PURE__ */ new Set();
28
- importedModules = /* @__PURE__ */ new Set();
29
- isDependency = false;
30
- isRoot = false;
31
- version = null;
32
26
  constructor(file) {
27
+ this.importers = /* @__PURE__ */ new Set();
28
+ this.importedModules = /* @__PURE__ */ new Set();
29
+ this.isDependency = false;
30
+ this.isRoot = false;
31
+ this.version = null;
33
32
  this.file = file;
34
33
  }
35
34
  };
36
35
  var ModuleGraph = class {
37
- fileToModules = /* @__PURE__ */ new Map();
38
- depToModules = /* @__PURE__ */ new Map();
39
- depSnapshotModules = {};
40
- rootModules = /* @__PURE__ */ new Set();
41
36
  constructor() {
37
+ this.fileToModules = /* @__PURE__ */ new Map();
38
+ this.depToModules = /* @__PURE__ */ new Map();
39
+ this.depSnapshotModules = {};
40
+ this.rootModules = /* @__PURE__ */ new Set();
42
41
  }
43
42
  restore(data) {
44
43
  const getModuleNode = (file) => {
@@ -61,7 +60,8 @@ var ModuleGraph = class {
61
60
  info = data.depModules[file];
62
61
  isDependency = true;
63
62
  }
64
- if (info.isRoot) mod.isRoot = true;
63
+ if (info.isRoot)
64
+ mod.isRoot = true;
65
65
  if (importer) {
66
66
  mod.importers.add(importer);
67
67
  if (!importer.importedModules.has(mod)) {
@@ -201,11 +201,13 @@ var ModuleGraph = class {
201
201
  let mod;
202
202
  if (modules.has(opts.file)) {
203
203
  mod = modules.get(opts.file);
204
- if (opts.version !== void 0) mod.version = opts.version;
204
+ if (opts.version !== void 0)
205
+ mod.version = opts.version;
205
206
  } else {
206
207
  mod = new ModuleNode(opts.file);
207
208
  mod.isDependency = opts.isDependency;
208
- if (opts.version !== void 0) mod.version = opts.version;
209
+ if (opts.version !== void 0)
210
+ mod.version = opts.version;
209
211
  modules.set(opts.file, mod);
210
212
  }
211
213
  if (!mod.importers.has(opts.importer)) {
@@ -22,7 +22,7 @@ __export(importParser_exports, {
22
22
  default: () => parse
23
23
  });
24
24
  module.exports = __toCommonJS(importParser_exports);
25
- var import_importParser = require("../../vendors/importParser/_importParser.js");
25
+ var { parse: _parse } = require("../../vendors/importParser/_importParser.js");
26
26
  function parse(code) {
27
- return (0, import_importParser.parse)(code);
27
+ return _parse(code);
28
28
  }
@@ -1,16 +1,16 @@
1
1
  import { ImportSpecifier } from '@umijs/bundler-utils/compiled/es-module-lexer';
2
2
  import { checkMatch } from '../babelPlugins/awaitImport/checkMatch';
3
3
  import { MFSU } from '../mfsu/mfsu';
4
- declare type FileChangeEvent = {
4
+ type FileChangeEvent = {
5
5
  event: 'unlink' | 'change' | 'add';
6
6
  path: string;
7
7
  };
8
- declare type MergedCodeInfo = {
8
+ type MergedCodeInfo = {
9
9
  imports: readonly ImportSpecifier[];
10
10
  code: string;
11
11
  events: FileChangeEvent[];
12
12
  };
13
- declare type AutoUpdateSrcCodeCache = {
13
+ type AutoUpdateSrcCodeCache = {
14
14
  register(listener: (info: MergedCodeInfo) => void): void;
15
15
  getMergedCode(): MergedCodeInfo;
16
16
  handleFileChangeEvents(events: FileChangeEvent[]): void;
@@ -22,7 +22,7 @@ interface IOpts {
22
22
  srcCodeCache: AutoUpdateSrcCodeCache;
23
23
  safeList?: string[];
24
24
  }
25
- export declare type Match = ReturnType<typeof checkMatch> & {
25
+ export type Match = ReturnType<typeof checkMatch> & {
26
26
  version: string;
27
27
  };
28
28
  export declare class StaticDepInfo {
@@ -41,7 +41,7 @@ export declare class StaticDepInfo {
41
41
  changes: unknown[];
42
42
  }[];
43
43
  consumeAllProducedEvents(): void;
44
- shouldBuild(): false | "cacheDependency has changed" | "dependencies changed";
44
+ shouldBuild(): "cacheDependency has changed" | "dependencies changed" | false;
45
45
  getDepModules(): Record<string, {
46
46
  file: string;
47
47
  version: string;
@@ -40,17 +40,11 @@ var import_checkMatch = require("../babelPlugins/awaitImport/checkMatch");
40
40
  var import_dep = require("../dep/dep");
41
41
  var import_babel_plugin_import = __toESM(require("./simulations/babel-plugin-import"));
42
42
  var StaticDepInfo = class {
43
- opts;
44
- cacheFilePath;
45
- mfsu;
46
- include;
47
- currentDep = {};
48
- builtWithDep = {};
49
- cacheDependency = {};
50
- produced = [];
51
- cwd;
52
- runtimeSimulations;
53
43
  constructor(opts) {
44
+ this.currentDep = {};
45
+ this.builtWithDep = {};
46
+ this.cacheDependency = {};
47
+ this.produced = [];
54
48
  this.mfsu = opts.mfsu;
55
49
  this.include = this.mfsu.opts.include || [];
56
50
  this.opts = opts;
@@ -25,7 +25,6 @@ module.exports = __toCommonJS(buildDepPlugin_exports);
25
25
  var import_utils = require("@umijs/utils");
26
26
  var PLUGIN_NAME = "MFSUBuildDeps";
27
27
  var BuildDepPlugin = class {
28
- opts;
29
28
  constructor(opts) {
30
29
  this.opts = opts;
31
30
  }
@@ -23,7 +23,6 @@ __export(stripSourceMapUrlPlugin_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(stripSourceMapUrlPlugin_exports);
25
25
  var StripSourceMapUrlPlugin = class {
26
- opts;
27
26
  constructor(opts) {
28
27
  this.opts = opts;
29
28
  }
@@ -24,7 +24,6 @@ __export(writeCachePlugin_exports, {
24
24
  module.exports = __toCommonJS(writeCachePlugin_exports);
25
25
  var PLUGIN_NAME = "MFSUWriteCache";
26
26
  var WriteCachePlugin = class {
27
- opts;
28
27
  constructor(opts) {
29
28
  this.opts = opts;
30
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/mfsu",
3
- "version": "4.6.67",
3
+ "version": "4.6.69",
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",
@@ -19,9 +19,9 @@
19
19
  "dependencies": {
20
20
  "enhanced-resolve": "5.9.3",
21
21
  "is-equal": "^1.6.4",
22
- "@umijs/utils": "4.6.67",
23
- "@umijs/bundler-esbuild": "4.6.67",
24
- "@umijs/bundler-utils": "4.6.67"
22
+ "@umijs/bundler-esbuild": "4.6.69",
23
+ "@umijs/bundler-utils": "4.6.69",
24
+ "@umijs/utils": "4.6.69"
25
25
  },
26
26
  "devDependencies": {
27
27
  "is-absolute-url": "^4.0.1",
@@ -185,8 +185,7 @@ parse: function parse(input) {
185
185
  vstack.length = vstack.length - n;
186
186
  lstack.length = lstack.length - n;
187
187
  }
188
- _token_stack:
189
- var lex = function () {
188
+ var lex = function () {
190
189
  var token;
191
190
  token = lexer.lex() || EOF;
192
191
  if (typeof token !== 'number') {
@@ -680,4 +679,4 @@ exports.main = function commonjsMain (args) {
680
679
  if (typeof module !== 'undefined' && require.main === module) {
681
680
  exports.main(process.argv.slice(1));
682
681
  }
683
- }
682
+ }