@umijs/mfsu 4.0.0-canary.20221121.1 → 4.0.0-canary.20221208.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/babelPlugins/awaitImport/checkMatch.js +10 -2
- package/dist/dep/dep.d.ts +3 -0
- package/dist/dep/dep.js +7 -13
- package/dist/dep/getExposeFromContent.js +11 -9
- package/dist/depBuilder/depBuilder.js +4 -1
- package/dist/depBuilder/getESBuildEntry.d.ts +1 -0
- package/dist/depBuilder/getESBuildEntry.js +1 -1
- package/dist/depInfo.d.ts +1 -0
- package/dist/mfsu/mfsu.js +5 -10
- package/dist/mfsu/strategyStaticAnalyze.js +5 -4
- package/dist/moduleGraph.d.ts +1 -0
- package/dist/moduleGraph.js +19 -3
- package/dist/utils/resolveUtils.d.ts +1 -0
- package/dist/utils/resolveUtils.js +89 -0
- package/dist/utils/webpackUtils.d.ts +2 -1
- package/dist/utils/webpackUtils.js +21 -2
- package/package.json +4 -4
|
@@ -67,8 +67,11 @@ function checkMatch({
|
|
|
67
67
|
const remoteName = opts.remoteName || "mf";
|
|
68
68
|
value = value.replace(/^@fs\//, "/");
|
|
69
69
|
const unMatchLibsRegex = genUnMatchLibsRegex(opts.unMatchLibs);
|
|
70
|
-
|
|
70
|
+
const mfPathInitial = `${remoteName}/`;
|
|
71
|
+
if ((unMatchLibsRegex == null ? void 0 : unMatchLibsRegex.test(value)) || value.includes("client/client/client.js") || (0, import_utils.winPath)(value).includes("babel/svgr-webpack") || value.startsWith("!!") || (0, import_isExternals.isExternals)({ value, externals: opts.externals }) || value.startsWith(".")) {
|
|
71
72
|
isMatch = false;
|
|
73
|
+
} else if (value.startsWith(mfPathInitial)) {
|
|
74
|
+
isMatch = true;
|
|
72
75
|
} else if ((0, import_path.isAbsolute)(value)) {
|
|
73
76
|
isMatch = RE_NODE_MODULES.test(value) || isUmiLocalDev(value);
|
|
74
77
|
} else {
|
|
@@ -94,7 +97,12 @@ function checkMatch({
|
|
|
94
97
|
isMatch = !!(opts.exportAllMembers && value in opts.exportAllMembers);
|
|
95
98
|
}
|
|
96
99
|
if (isMatch) {
|
|
97
|
-
|
|
100
|
+
if (value.startsWith(mfPathInitial)) {
|
|
101
|
+
replaceValue = value;
|
|
102
|
+
value = value.replace(mfPathInitial, "");
|
|
103
|
+
} else {
|
|
104
|
+
replaceValue = `${remoteName}/${(0, import_utils.winPath)(value)}`;
|
|
105
|
+
}
|
|
98
106
|
}
|
|
99
107
|
const file = (path == null ? void 0 : path.hub.file.opts.filename) || filename;
|
|
100
108
|
(_a = opts.onTransformDeps) == null ? void 0 : _a.call(opts, {
|
package/dist/dep/dep.d.ts
CHANGED
|
@@ -7,11 +7,13 @@ export declare class Dep {
|
|
|
7
7
|
normalizedFile: string;
|
|
8
8
|
filePath: string;
|
|
9
9
|
excludeNodeNatives: boolean;
|
|
10
|
+
importer: string | undefined;
|
|
10
11
|
constructor(opts: {
|
|
11
12
|
file: string;
|
|
12
13
|
version: string;
|
|
13
14
|
cwd: string;
|
|
14
15
|
excludeNodeNatives: boolean;
|
|
16
|
+
importer?: string;
|
|
15
17
|
});
|
|
16
18
|
buildExposeContent(): Promise<string>;
|
|
17
19
|
getRealFile(): Promise<string | null>;
|
|
@@ -19,6 +21,7 @@ export declare class Dep {
|
|
|
19
21
|
deps: Record<string, {
|
|
20
22
|
file: string;
|
|
21
23
|
version: string;
|
|
24
|
+
importer?: string;
|
|
22
25
|
}>;
|
|
23
26
|
cwd: string;
|
|
24
27
|
mfsu: MFSU;
|
package/dist/dep/dep.js
CHANGED
|
@@ -27,23 +27,12 @@ __export(dep_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(dep_exports);
|
|
28
28
|
var import_utils = require("@umijs/utils");
|
|
29
29
|
var import_assert = __toESM(require("assert"));
|
|
30
|
-
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
31
30
|
var import_fs = require("fs");
|
|
32
31
|
var import_path = require("path");
|
|
33
32
|
var import_constants = require("../constants");
|
|
34
33
|
var import_trimFileContent = require("../utils/trimFileContent");
|
|
35
34
|
var import_getExposeFromContent = require("./getExposeFromContent");
|
|
36
|
-
var
|
|
37
|
-
mainFields: ["module", "browser", "main"],
|
|
38
|
-
extensions: [".wasm", ".mjs", ".js", ".jsx", ".ts", ".tsx", ".json"],
|
|
39
|
-
exportsFields: ["exports"],
|
|
40
|
-
conditionNames: ["import", "module", "require", "node"]
|
|
41
|
-
});
|
|
42
|
-
async function resolve(context, path) {
|
|
43
|
-
return new Promise((resolve2, reject) => {
|
|
44
|
-
resolver(context, path, (err, result) => err ? reject(err) : resolve2(result));
|
|
45
|
-
});
|
|
46
|
-
}
|
|
35
|
+
var import_resolveUtils = require("../utils/resolveUtils");
|
|
47
36
|
var Dep = class {
|
|
48
37
|
constructor(opts) {
|
|
49
38
|
this.file = (0, import_utils.winPath)(opts.file);
|
|
@@ -53,6 +42,7 @@ var Dep = class {
|
|
|
53
42
|
this.normalizedFile = this.shortFile.replace(/\//g, "_").replace(/:/g, "_");
|
|
54
43
|
this.filePath = `${import_constants.MF_VA_PREFIX}${this.normalizedFile}.js`;
|
|
55
44
|
this.excludeNodeNatives = opts.excludeNodeNatives;
|
|
45
|
+
this.importer = opts.importer;
|
|
56
46
|
}
|
|
57
47
|
async buildExposeContent() {
|
|
58
48
|
const isNodeNatives = !!process.binding("natives")[this.file];
|
|
@@ -80,7 +70,11 @@ export * from '${this.file}';
|
|
|
80
70
|
}
|
|
81
71
|
async getRealFile() {
|
|
82
72
|
try {
|
|
83
|
-
|
|
73
|
+
const contexts = [this.cwd];
|
|
74
|
+
if (this.importer) {
|
|
75
|
+
contexts.push((0, import_path.dirname)(this.importer));
|
|
76
|
+
}
|
|
77
|
+
return await (0, import_resolveUtils.resolveFromContexts)(contexts, this.file);
|
|
84
78
|
} catch (e) {
|
|
85
79
|
return null;
|
|
86
80
|
}
|
|
@@ -28,13 +28,15 @@ module.exports = __toCommonJS(getExposeFromContent_exports);
|
|
|
28
28
|
var import_assert = __toESM(require("assert"));
|
|
29
29
|
var import_path = require("path");
|
|
30
30
|
var import_getModuleExports = require("./getModuleExports");
|
|
31
|
+
var import_utils = require("@umijs/utils");
|
|
31
32
|
async function getExposeFromContent(opts) {
|
|
33
|
+
const importPath = (0, import_utils.winPath)(opts.filePath);
|
|
32
34
|
if (opts.filePath && /\.(css|less|scss|sass|stylus|styl)$/.test(opts.filePath)) {
|
|
33
|
-
return `import '${
|
|
35
|
+
return `import '${importPath}';`;
|
|
34
36
|
}
|
|
35
37
|
if (opts.filePath && /\.(json|svg|png|jpe?g|avif|gif|webp|ico|eot|woff|woff2|ttf|txt|text|mdx?)$/.test(opts.filePath)) {
|
|
36
38
|
return `
|
|
37
|
-
import _ from '${
|
|
39
|
+
import _ from '${importPath}';
|
|
38
40
|
export default _;`.trim();
|
|
39
41
|
}
|
|
40
42
|
(0, import_assert.default)(/(js|jsx|mjs|ts|tsx)$/.test(opts.filePath), `file type not supported for ${(0, import_path.basename)(opts.filePath)}.`);
|
|
@@ -44,29 +46,29 @@ export default _;`.trim();
|
|
|
44
46
|
});
|
|
45
47
|
if (isCJS) {
|
|
46
48
|
return [
|
|
47
|
-
`import _ from '${
|
|
49
|
+
`import _ from '${importPath}';`,
|
|
48
50
|
`export default _;`,
|
|
49
|
-
`export * from '${
|
|
51
|
+
`export * from '${importPath}';`
|
|
50
52
|
].join("\n");
|
|
51
53
|
} else {
|
|
52
54
|
const ret = [];
|
|
53
55
|
let hasExports = false;
|
|
54
56
|
if (exports.includes("default")) {
|
|
55
|
-
ret.push(`import _ from '${
|
|
57
|
+
ret.push(`import _ from '${importPath}';`);
|
|
56
58
|
ret.push(`export default _;`);
|
|
57
59
|
hasExports = true;
|
|
58
60
|
}
|
|
59
61
|
if (hasNonDefaultExports(exports) || /export\s*\*\s*from/.test(opts.content)) {
|
|
60
|
-
ret.push(`export * from '${
|
|
62
|
+
ret.push(`export * from '${importPath}';`);
|
|
61
63
|
hasExports = true;
|
|
62
64
|
}
|
|
63
65
|
if (!hasExports) {
|
|
64
66
|
if (exports.includes("__esModule")) {
|
|
65
|
-
ret.push(`import _ from '${
|
|
67
|
+
ret.push(`import _ from '${importPath}';`);
|
|
66
68
|
ret.push(`export default _;`);
|
|
67
|
-
ret.push(`export * from '${
|
|
69
|
+
ret.push(`export * from '${importPath}';`);
|
|
68
70
|
} else {
|
|
69
|
-
ret.push(`import '${
|
|
71
|
+
ret.push(`import '${importPath}';`);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
return ret.join("\n");
|
|
@@ -60,7 +60,10 @@ var DepBuilder = class {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
async buildWithESBuild(opts) {
|
|
63
|
-
const entryContent = (0, import_getESBuildEntry.getESBuildEntry)({
|
|
63
|
+
const entryContent = (0, import_getESBuildEntry.getESBuildEntry)({
|
|
64
|
+
mfName: this.opts.mfsu.opts.mfName,
|
|
65
|
+
deps: opts.deps
|
|
66
|
+
});
|
|
64
67
|
const ENTRY_FILE = "esbuild-entry.js";
|
|
65
68
|
const tmpDir = this.opts.mfsu.opts.tmpBase;
|
|
66
69
|
const entryPath = (0, import_path.join)(tmpDir, ENTRY_FILE);
|
package/dist/depInfo.d.ts
CHANGED
package/dist/mfsu/mfsu.js
CHANGED
|
@@ -41,6 +41,7 @@ var import_depBuilder = require("../depBuilder/depBuilder");
|
|
|
41
41
|
var import_awaitImport = __toESM(require("../esbuildHandlers/awaitImport"));
|
|
42
42
|
var import_types = require("../types");
|
|
43
43
|
var import_makeArray = require("../utils/makeArray");
|
|
44
|
+
var import_webpackUtils = require("../utils/webpackUtils");
|
|
44
45
|
var import_buildDepPlugin = require("../webpackPlugins/buildDepPlugin");
|
|
45
46
|
var import_strategyCompileTime = require("./strategyCompileTime");
|
|
46
47
|
var import_strategyStaticAnalyze = require("./strategyStaticAnalyze");
|
|
@@ -106,17 +107,11 @@ var MFSU = class {
|
|
|
106
107
|
let index = 1;
|
|
107
108
|
let hasDefaultExport = false;
|
|
108
109
|
const entryFiles = import_utils.lodash.isArray(entryObject[key]) ? entryObject[key] : [entryObject[key]];
|
|
110
|
+
const resolver = (0, import_webpackUtils.getResolver)(opts.config);
|
|
109
111
|
for (let entry2 of entryFiles) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
(0, import_path.join)(entry2, "index.ts"),
|
|
114
|
-
(0, import_path.join)(entry2, "index.jsx"),
|
|
115
|
-
(0, import_path.join)(entry2, "index.js")
|
|
116
|
-
]);
|
|
117
|
-
(0, import_assert.default)(realEntry, `entry file not found, please configure the specific entry path. (e.g. 'src/index.tsx')`);
|
|
118
|
-
entry2 = realEntry;
|
|
119
|
-
}
|
|
112
|
+
const realEntry = resolver(entry2);
|
|
113
|
+
(0, import_assert.default)(realEntry, `entry file not found (${entry2}), please configure the specific entry path. (e.g. 'src/index.tsx')`);
|
|
114
|
+
entry2 = realEntry;
|
|
120
115
|
const content = (0, import_fs.readFileSync)(entry2, "utf-8");
|
|
121
116
|
const [_imports, exports] = await (0, import_bundler_utils.parseModule)({ content, path: entry2 });
|
|
122
117
|
if (exports.length) {
|
|
@@ -122,15 +122,16 @@ var StaticAnalyzeStrategy = class {
|
|
|
122
122
|
},
|
|
123
123
|
onFileChange: async (c) => {
|
|
124
124
|
import_utils.logger.debug("webpack found changes modified:", c.modifiedFiles, "removed:", c.removedFiles);
|
|
125
|
+
const cwd = this.mfsu.opts.cwd;
|
|
125
126
|
const fileEvents = [
|
|
126
127
|
...this.staticDepInfo.opts.srcCodeCache.replayChangeEvents(),
|
|
127
|
-
...extractJSCodeFiles(c.modifiedFiles).map((f) => {
|
|
128
|
+
...extractJSCodeFiles(cwd, c.modifiedFiles).map((f) => {
|
|
128
129
|
return {
|
|
129
130
|
event: "change",
|
|
130
131
|
path: f
|
|
131
132
|
};
|
|
132
133
|
}),
|
|
133
|
-
...extractJSCodeFiles(c.removedFiles).map((f) => {
|
|
134
|
+
...extractJSCodeFiles(cwd, c.removedFiles).map((f) => {
|
|
134
135
|
return {
|
|
135
136
|
event: "unlink",
|
|
136
137
|
path: f
|
|
@@ -161,13 +162,13 @@ var StaticAnalyzeStrategy = class {
|
|
|
161
162
|
}
|
|
162
163
|
};
|
|
163
164
|
var REG_CODE_EXT = /\.(jsx|js|ts|tsx)$/;
|
|
164
|
-
function extractJSCodeFiles(files) {
|
|
165
|
+
function extractJSCodeFiles(folderBase, files) {
|
|
165
166
|
const jsFiles = [];
|
|
166
167
|
if (!files) {
|
|
167
168
|
return jsFiles;
|
|
168
169
|
}
|
|
169
170
|
for (let file of files.values()) {
|
|
170
|
-
if (REG_CODE_EXT.test(file)) {
|
|
171
|
+
if (file.startsWith(folderBase) && REG_CODE_EXT.test(file)) {
|
|
171
172
|
jsFiles.push(file);
|
|
172
173
|
}
|
|
173
174
|
}
|
package/dist/moduleGraph.d.ts
CHANGED
package/dist/moduleGraph.js
CHANGED
|
@@ -22,7 +22,6 @@ __export(moduleGraph_exports, {
|
|
|
22
22
|
ModuleGraph: () => ModuleGraph
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(moduleGraph_exports);
|
|
25
|
-
var import_utils = require("@umijs/utils");
|
|
26
25
|
var ModuleNode = class {
|
|
27
26
|
constructor(file) {
|
|
28
27
|
this.importers = /* @__PURE__ */ new Set();
|
|
@@ -124,14 +123,31 @@ var ModuleGraph = class {
|
|
|
124
123
|
}, {});
|
|
125
124
|
}
|
|
126
125
|
getDepInfo(mod) {
|
|
126
|
+
const [importer] = mod.importers;
|
|
127
127
|
return {
|
|
128
128
|
file: mod.file,
|
|
129
|
-
version: mod.version
|
|
129
|
+
version: mod.version,
|
|
130
|
+
importer: importer == null ? void 0 : importer.file
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
hasDepChanged() {
|
|
133
134
|
const depModulesInfo = this.getDepsInfo(this.depToModules);
|
|
134
|
-
|
|
135
|
+
const depKeys = Object.keys(depModulesInfo);
|
|
136
|
+
const snapshotKeys = Object.keys(this.depSnapshotModules);
|
|
137
|
+
if (depKeys.length !== snapshotKeys.length) {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
for (const k of depKeys) {
|
|
141
|
+
const dep = depModulesInfo[k];
|
|
142
|
+
const snapshot = this.depSnapshotModules[k];
|
|
143
|
+
if (dep.file !== (snapshot == null ? void 0 : snapshot.file)) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
if (dep.version !== (snapshot == null ? void 0 : snapshot.version)) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
135
151
|
}
|
|
136
152
|
onFileChange(opts) {
|
|
137
153
|
if (this.fileToModules.has(opts.file)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveFromContexts(contexts: string[], path: string): Promise<string>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/utils/resolveUtils.ts
|
|
23
|
+
var resolveUtils_exports = {};
|
|
24
|
+
__export(resolveUtils_exports, {
|
|
25
|
+
resolveFromContexts: () => resolveFromContexts
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(resolveUtils_exports);
|
|
28
|
+
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
29
|
+
var ORDERED_MAIN_FIELDS = ["browser", "module", "main"];
|
|
30
|
+
var SUPPORTED_EXTS = [".wasm", ".mjs", ".js", ".jsx", ".ts", ".tsx", ".json"];
|
|
31
|
+
var EXPORTS_FIELDS = ["exports"];
|
|
32
|
+
var browserResolver = import_enhanced_resolve.default.create({
|
|
33
|
+
mainFields: ORDERED_MAIN_FIELDS,
|
|
34
|
+
extensions: SUPPORTED_EXTS,
|
|
35
|
+
exportsFields: EXPORTS_FIELDS,
|
|
36
|
+
conditionNames: ["browser", "import"],
|
|
37
|
+
symlinks: false
|
|
38
|
+
});
|
|
39
|
+
var esmResolver = import_enhanced_resolve.default.create({
|
|
40
|
+
mainFields: ORDERED_MAIN_FIELDS,
|
|
41
|
+
extensions: SUPPORTED_EXTS,
|
|
42
|
+
exportsFields: EXPORTS_FIELDS,
|
|
43
|
+
conditionNames: ["module"],
|
|
44
|
+
symlinks: false
|
|
45
|
+
});
|
|
46
|
+
var cjsResolver = import_enhanced_resolve.default.create({
|
|
47
|
+
mainFields: ORDERED_MAIN_FIELDS,
|
|
48
|
+
extensions: SUPPORTED_EXTS,
|
|
49
|
+
exportsFields: EXPORTS_FIELDS,
|
|
50
|
+
conditionNames: ["require", "node"],
|
|
51
|
+
symlinks: false
|
|
52
|
+
});
|
|
53
|
+
async function resolveWith(resolver, context, path) {
|
|
54
|
+
return new Promise((resolve2, reject) => {
|
|
55
|
+
resolver(context, path, (err, result) => err ? reject(err) : resolve2(result));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async function tryResolvers(rs, context, path) {
|
|
59
|
+
let result = "";
|
|
60
|
+
let lastError = null;
|
|
61
|
+
for (const r of rs) {
|
|
62
|
+
try {
|
|
63
|
+
result = await resolveWith(r, context, path);
|
|
64
|
+
return result;
|
|
65
|
+
} catch (e) {
|
|
66
|
+
lastError = e;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!result) {
|
|
70
|
+
throw lastError || Error(`can't resolve ${path} from ${context}`);
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
async function resolve(context, path) {
|
|
75
|
+
return await tryResolvers([browserResolver, esmResolver, cjsResolver], context, path);
|
|
76
|
+
}
|
|
77
|
+
async function resolveFromContexts(contexts, path) {
|
|
78
|
+
for (const context of contexts) {
|
|
79
|
+
try {
|
|
80
|
+
return await resolve(context, path);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
throw new Error(`Can't resolve ${path} from ${contexts.join(", ")}`);
|
|
85
|
+
}
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
resolveFromContexts
|
|
89
|
+
});
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Configuration } from 'webpack';
|
|
2
2
|
export declare function extractBabelPluginImportOptions(webpackConfig: Configuration): Map<string, any>;
|
|
3
|
+
export declare function getResolver(opts: Configuration): (path: string) => string | false;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,15 +16,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
21
|
|
|
19
22
|
// src/utils/webpackUtils.ts
|
|
20
23
|
var webpackUtils_exports = {};
|
|
21
24
|
__export(webpackUtils_exports, {
|
|
22
|
-
extractBabelPluginImportOptions: () => extractBabelPluginImportOptions
|
|
25
|
+
extractBabelPluginImportOptions: () => extractBabelPluginImportOptions,
|
|
26
|
+
getResolver: () => getResolver
|
|
23
27
|
});
|
|
24
28
|
module.exports = __toCommonJS(webpackUtils_exports);
|
|
29
|
+
var import_webpack = require("webpack");
|
|
25
30
|
var import_utils = require("@umijs/utils");
|
|
31
|
+
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
26
32
|
var { property, compact, flatMap } = import_utils.lodash;
|
|
27
33
|
function extractBabelPluginImportOptions(webpackConfig) {
|
|
28
34
|
var _a;
|
|
@@ -41,7 +47,20 @@ function extractBabelPluginImportOptions(webpackConfig) {
|
|
|
41
47
|
}
|
|
42
48
|
return configs;
|
|
43
49
|
}
|
|
50
|
+
function getResolver(opts) {
|
|
51
|
+
const context = opts.context ?? process.cwd();
|
|
52
|
+
const resolveDefaults = {
|
|
53
|
+
extensions: [".tsx", ".ts", ".jsx", ".js"],
|
|
54
|
+
roots: [context]
|
|
55
|
+
};
|
|
56
|
+
const mergedResolve = import_webpack.util.cleverMerge(resolveDefaults, opts.resolve);
|
|
57
|
+
const resolver = import_enhanced_resolve.default.create.sync(mergedResolve);
|
|
58
|
+
return (path) => {
|
|
59
|
+
return resolver(context, path);
|
|
60
|
+
};
|
|
61
|
+
}
|
|
44
62
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
63
|
0 && (module.exports = {
|
|
46
|
-
extractBabelPluginImportOptions
|
|
64
|
+
extractBabelPluginImportOptions,
|
|
65
|
+
getResolver
|
|
47
66
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/mfsu",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20221208.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.
|
|
27
|
-
"@umijs/bundler-utils": "4.0.0-canary.
|
|
28
|
-
"@umijs/utils": "4.0.0-canary.
|
|
26
|
+
"@umijs/bundler-esbuild": "4.0.0-canary.20221208.1",
|
|
27
|
+
"@umijs/bundler-utils": "4.0.0-canary.20221208.1",
|
|
28
|
+
"@umijs/utils": "4.0.0-canary.20221208.1",
|
|
29
29
|
"enhanced-resolve": "5.9.3",
|
|
30
30
|
"is-equal": "^1.6.4"
|
|
31
31
|
},
|