@umijs/mfsu 4.6.1 → 4.6.2
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 +2 -10
- package/dist/dep/getExposeFromContent.js +6 -6
- package/dist/dep/getModuleExports.js +3 -3
- package/dist/depBuilder/depBuilder.js +6 -5
- package/dist/depInfo.js +2 -4
- package/dist/esbuildHandlers/awaitImport/index.js +4 -2
- package/dist/loader/esbuild.js +2 -2
- package/dist/mfsu/mfsu.js +10 -14
- package/dist/mfsu/strategyCompileTime.js +0 -2
- package/dist/mfsu/strategyStaticAnalyze.js +0 -2
- package/dist/moduleGraph.js +15 -13
- package/dist/staticDepInfo/staticDepInfo.js +4 -10
- package/dist/webpackPlugins/buildDepPlugin.js +0 -1
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +0 -1
- package/dist/webpackPlugins/writeCachePlugin.js +0 -1
- package/package.json +4 -4
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
|
|
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
|
|
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
|
|
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 (
|
|
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(
|
|
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 (
|
|
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(
|
|
100
|
-
return
|
|
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,
|
|
44
|
-
let isCJS = !imports.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 ||
|
|
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)
|
|
174
|
-
|
|
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.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)
|
|
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)
|
|
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)({
|
package/dist/loader/esbuild.js
CHANGED
|
@@ -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,
|
|
66
|
-
code = handle({ code, imports, exports
|
|
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));
|
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,
|
|
138
|
-
if (
|
|
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
|
|
136
|
+
for (const exportName of exports) {
|
|
141
137
|
if (exportName === "default") {
|
|
142
138
|
hasDefaultExport = true;
|
|
143
139
|
virtualContent.push(`export default k${index}.${exportName}`);
|
|
@@ -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 });
|
|
@@ -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({
|
package/dist/moduleGraph.js
CHANGED
|
@@ -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)
|
|
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)
|
|
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)
|
|
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)) {
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.2",
|
|
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/bundler-
|
|
23
|
-
"@umijs/utils": "4.6.
|
|
24
|
-
"@umijs/
|
|
22
|
+
"@umijs/bundler-esbuild": "4.6.2",
|
|
23
|
+
"@umijs/bundler-utils": "4.6.2",
|
|
24
|
+
"@umijs/utils": "4.6.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"is-absolute-url": "^4.0.1",
|