@umijs/mfsu 4.0.0-canary.20220718.2 → 4.0.0-canary.20220729.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/compiled/is-absolute-url/LICENSE +9 -0
- package/compiled/is-absolute-url/index.d.ts +22 -0
- package/compiled/is-absolute-url/index.js +1 -0
- package/compiled/is-absolute-url/package.json +1 -0
- package/dist/babelPlugins/awaitImport/MFImport.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/MFImport.js +59 -66
- package/dist/babelPlugins/awaitImport/awaitImport.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/awaitImport.js +103 -117
- package/dist/babelPlugins/awaitImport/checkMatch.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/checkMatch.js +129 -132
- package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/getAliasedPath.js +54 -35
- package/dist/babelPlugins/awaitImport/getRealPath.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
- package/dist/babelPlugins/awaitImport/isExternals.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
- package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts +0 -1
- package/dist/babelPlugins/awaitImport/parseSpecifiers.js +51 -52
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +47 -10
- package/dist/dep/dep.d.ts +0 -1
- package/dist/dep/dep.js +112 -83
- package/dist/dep/getCJSExports.d.ts +0 -1
- package/dist/dep/getCJSExports.js +60 -53
- package/dist/dep/getExposeFromContent.d.ts +0 -1
- package/dist/dep/getExposeFromContent.js +71 -61
- package/dist/dep/getModuleExports.d.ts +0 -1
- package/dist/dep/getModuleExports.js +58 -32
- package/dist/depBuilder/depBuilder.d.ts +0 -1
- package/dist/depBuilder/depBuilder.js +192 -158
- package/dist/depBuilder/getESBuildEntry.d.ts +0 -1
- package/dist/depBuilder/getESBuildEntry.js +35 -12
- package/dist/depInfo.d.ts +0 -1
- package/dist/depInfo.js +75 -53
- package/dist/esbuildHandlers/autoCssModules.d.ts +0 -1
- package/dist/esbuildHandlers/autoCssModules.js +43 -22
- package/dist/esbuildHandlers/awaitImport/index.d.ts +0 -1
- package/dist/esbuildHandlers/awaitImport/index.js +82 -70
- package/dist/index.d.ts +0 -1
- package/dist/index.js +32 -22
- package/dist/loader/esbuild.d.ts +0 -1
- package/dist/loader/esbuild.js +87 -35
- package/dist/mfsu/mfsu.d.ts +4 -1
- package/dist/mfsu/mfsu.js +236 -257
- package/dist/mfsu/strategyCompileTime.d.ts +0 -1
- package/dist/mfsu/strategyCompileTime.js +131 -99
- package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -1
- package/dist/mfsu/strategyStaticAnalyze.js +151 -115
- package/dist/moduleGraph.d.ts +0 -1
- package/dist/moduleGraph.js +227 -186
- package/dist/staticDepInfo/importParser.d.ts +0 -1
- package/dist/staticDepInfo/importParser.js +28 -6
- package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +0 -1
- package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -91
- package/dist/staticDepInfo/staticDepInfo.d.ts +0 -1
- package/dist/staticDepInfo/staticDepInfo.js +239 -197
- package/dist/types.d.ts +0 -1
- package/dist/types.js +33 -8
- package/dist/utils/makeArray.d.ts +0 -1
- package/dist/utils/makeArray.js +29 -5
- package/dist/utils/trimFileContent.d.ts +0 -1
- package/dist/utils/trimFileContent.js +29 -5
- package/dist/webpackPlugins/buildDepPlugin.d.ts +0 -1
- package/dist/webpackPlugins/buildDepPlugin.js +49 -25
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +0 -1
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +44 -19
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +0 -1
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +46 -27
- package/dist/webpackPlugins/writeCachePlugin.d.ts +0 -1
- package/dist/webpackPlugins/writeCachePlugin.js +39 -15
- package/package.json +8 -6
- package/dist/babelPlugins/awaitImport/MFImport.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/awaitImport.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/checkMatch.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/getRealPath.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/isExternals.d.ts.map +0 -1
- package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/dep/dep.d.ts.map +0 -1
- package/dist/dep/getCJSExports.d.ts.map +0 -1
- package/dist/dep/getExposeFromContent.d.ts.map +0 -1
- package/dist/dep/getModuleExports.d.ts.map +0 -1
- package/dist/depBuilder/depBuilder.d.ts.map +0 -1
- package/dist/depBuilder/getESBuildEntry.d.ts.map +0 -1
- package/dist/depInfo.d.ts.map +0 -1
- package/dist/esbuildHandlers/autoCssModules.d.ts.map +0 -1
- package/dist/esbuildHandlers/awaitImport/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/loader/esbuild.d.ts.map +0 -1
- package/dist/mfsu/mfsu.d.ts.map +0 -1
- package/dist/mfsu/strategyCompileTime.d.ts.map +0 -1
- package/dist/mfsu/strategyStaticAnalyze.d.ts.map +0 -1
- package/dist/moduleGraph.d.ts.map +0 -1
- package/dist/staticDepInfo/importParser.d.ts.map +0 -1
- package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts.map +0 -1
- package/dist/staticDepInfo/staticDepInfo.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/makeArray.d.ts.map +0 -1
- package/dist/utils/trimFileContent.d.ts.map +0 -1
- package/dist/webpackPlugins/buildDepPlugin.d.ts.map +0 -1
- package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts.map +0 -1
- package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts.map +0 -1
- package/dist/webpackPlugins/writeCachePlugin.d.ts.map +0 -1
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/depBuilder/getESBuildEntry.ts
|
|
20
|
+
var getESBuildEntry_exports = {};
|
|
21
|
+
__export(getESBuildEntry_exports, {
|
|
22
|
+
getESBuildEntry: () => getESBuildEntry
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getESBuildEntry_exports);
|
|
25
|
+
var import_constants = require("../constants");
|
|
26
|
+
var ES_INTEROP_FUNC = `__exportStar`;
|
|
27
|
+
var ES_INTEROP_HELPER = `
|
|
8
28
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
29
|
if (k2 === undefined) k2 = k;
|
|
10
30
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
@@ -17,7 +37,7 @@ var ${ES_INTEROP_FUNC} = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
37
|
};
|
|
18
38
|
`;
|
|
19
39
|
function getESBuildEntry(opts) {
|
|
20
|
-
|
|
40
|
+
return `
|
|
21
41
|
(function() {
|
|
22
42
|
/******/ "use strict";
|
|
23
43
|
/******/ var __webpack_modules__ = ({});
|
|
@@ -282,7 +302,7 @@ var __webpack_exports__ = {};
|
|
|
282
302
|
var exports = __webpack_exports__;
|
|
283
303
|
${ES_INTEROP_HELPER}
|
|
284
304
|
var moduleMap = {
|
|
285
|
-
${opts.deps.map(getDepModuleStr).join(
|
|
305
|
+
${opts.deps.map(getDepModuleStr).join(",\n")}
|
|
286
306
|
};
|
|
287
307
|
var get = function(module, getScope) {
|
|
288
308
|
__webpack_require__.R = getScope;
|
|
@@ -313,12 +333,11 @@ ${opts.deps.map(getDepModuleStr).join(',\n')}
|
|
|
313
333
|
})();
|
|
314
334
|
`;
|
|
315
335
|
}
|
|
316
|
-
exports.getESBuildEntry = getESBuildEntry;
|
|
317
336
|
function getDepModuleStr(dep) {
|
|
318
|
-
|
|
337
|
+
return `
|
|
319
338
|
"./${dep.file}": function() {
|
|
320
339
|
return new Promise(resolve => {
|
|
321
|
-
import('./${
|
|
340
|
+
import('./${import_constants.MF_VA_PREFIX}${dep.normalizedFile}.js').then(module => {
|
|
322
341
|
module.default && ${ES_INTEROP_FUNC}(module, module.default);
|
|
323
342
|
resolve(() => module.default || module);
|
|
324
343
|
});
|
|
@@ -326,3 +345,7 @@ function getDepModuleStr(dep) {
|
|
|
326
345
|
}
|
|
327
346
|
`.trim();
|
|
328
347
|
}
|
|
348
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
349
|
+
0 && (module.exports = {
|
|
350
|
+
getESBuildEntry
|
|
351
|
+
});
|
package/dist/depInfo.d.ts
CHANGED
package/dist/depInfo.js
CHANGED
|
@@ -1,57 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/depInfo.ts
|
|
20
|
+
var depInfo_exports = {};
|
|
21
|
+
__export(depInfo_exports, {
|
|
22
|
+
DepInfo: () => DepInfo
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(depInfo_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
var import_fs = require("fs");
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
var import_moduleGraph = require("./moduleGraph");
|
|
29
|
+
var DepInfo = class {
|
|
30
|
+
constructor(opts) {
|
|
31
|
+
this.moduleGraph = new import_moduleGraph.ModuleGraph();
|
|
32
|
+
this.cacheDependency = {};
|
|
33
|
+
this.opts = opts;
|
|
34
|
+
this.cacheFilePath = (0, import_path.join)(this.opts.mfsu.opts.tmpBase, "MFSU_CACHE.json");
|
|
35
|
+
}
|
|
36
|
+
shouldBuild() {
|
|
37
|
+
if (!import_utils.lodash.isEqual(this.cacheDependency, this.opts.mfsu.opts.getCacheDependency())) {
|
|
38
|
+
return "cacheDependency has changed";
|
|
14
39
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return 'cacheDependency has changed';
|
|
18
|
-
}
|
|
19
|
-
if (this.moduleGraph.hasDepChanged()) {
|
|
20
|
-
return 'moduleGraph has changed';
|
|
21
|
-
}
|
|
22
|
-
// fixme always rebuild in dev
|
|
23
|
-
return false;
|
|
40
|
+
if (this.moduleGraph.hasDepChanged()) {
|
|
41
|
+
return "moduleGraph has changed";
|
|
24
42
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
snapshot() {
|
|
46
|
+
this.cacheDependency = this.opts.mfsu.opts.getCacheDependency();
|
|
47
|
+
this.moduleGraph.snapshotDeps();
|
|
48
|
+
}
|
|
49
|
+
loadCache() {
|
|
50
|
+
if ((0, import_fs.existsSync)(this.cacheFilePath)) {
|
|
51
|
+
import_utils.logger.info("[MFSU] restore cache");
|
|
52
|
+
const { cacheDependency, moduleGraph } = JSON.parse((0, import_fs.readFileSync)(this.cacheFilePath, "utf-8"));
|
|
53
|
+
this.cacheDependency = cacheDependency;
|
|
54
|
+
this.moduleGraph.restore(moduleGraph);
|
|
28
55
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
56
|
+
}
|
|
57
|
+
writeCache() {
|
|
58
|
+
import_utils.fsExtra.mkdirpSync((0, import_path.dirname)(this.cacheFilePath));
|
|
59
|
+
const newContent = JSON.stringify({
|
|
60
|
+
cacheDependency: this.cacheDependency,
|
|
61
|
+
moduleGraph: this.moduleGraph.toJSON()
|
|
62
|
+
}, null, 2);
|
|
63
|
+
if ((0, import_fs.existsSync)(this.cacheFilePath) && (0, import_fs.readFileSync)(this.cacheFilePath, "utf-8") === newContent) {
|
|
64
|
+
return;
|
|
36
65
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return this.moduleGraph.depSnapshotModules;
|
|
52
|
-
}
|
|
53
|
-
getCacheFilePath() {
|
|
54
|
-
return this.cacheFilePath;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.DepInfo = DepInfo;
|
|
66
|
+
import_utils.logger.info("[MFSU] write cache");
|
|
67
|
+
(0, import_fs.writeFileSync)(this.cacheFilePath, newContent, "utf-8");
|
|
68
|
+
}
|
|
69
|
+
getDepModules() {
|
|
70
|
+
return this.moduleGraph.depSnapshotModules;
|
|
71
|
+
}
|
|
72
|
+
getCacheFilePath() {
|
|
73
|
+
return this.cacheFilePath;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
DepInfo
|
|
79
|
+
});
|
|
@@ -1,24 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/esbuildHandlers/autoCssModules.ts
|
|
20
|
+
var autoCssModules_exports = {};
|
|
21
|
+
__export(autoCssModules_exports, {
|
|
22
|
+
autoCssModulesHandler: () => autoCssModulesHandler
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(autoCssModules_exports);
|
|
25
|
+
var import_utils = require("@umijs/utils");
|
|
26
|
+
var CSS_MODULES_QUERY = "?modules";
|
|
27
|
+
var QUERY_LENGTH = CSS_MODULES_QUERY.length;
|
|
7
28
|
function autoCssModulesHandler(opts) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return code;
|
|
29
|
+
let { code } = opts;
|
|
30
|
+
let offset = 0;
|
|
31
|
+
opts.imports.forEach((i) => {
|
|
32
|
+
if (i.d < 0 && (0, import_utils.isStyleFile)({ filename: i.n })) {
|
|
33
|
+
const importSegment = code.substring(i.ss + offset, i.s + offset);
|
|
34
|
+
if (~importSegment.indexOf(" from")) {
|
|
35
|
+
code = `${code.substring(0, i.e + offset)}${CSS_MODULES_QUERY}${code.substring(i.e + offset)}`;
|
|
36
|
+
offset += QUERY_LENGTH;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return code;
|
|
23
41
|
}
|
|
24
|
-
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
autoCssModulesHandler
|
|
45
|
+
});
|
|
@@ -1,74 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/esbuildHandlers/awaitImport/index.ts
|
|
20
|
+
var awaitImport_exports = {};
|
|
21
|
+
__export(awaitImport_exports, {
|
|
22
|
+
default: () => getAwaitImportHandler,
|
|
23
|
+
getImportHandlerV4: () => getImportHandlerV4
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(awaitImport_exports);
|
|
26
|
+
var import_checkMatch = require("../../babelPlugins/awaitImport/checkMatch");
|
|
5
27
|
function getImportHandlerV4(params) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
code = `${preSeg}${quote}${replaceValue}${quote}${tailSeg}`;
|
|
27
|
-
offset += replaceValue.length - from.length;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return code;
|
|
31
|
-
};
|
|
28
|
+
return function awaitImportHandler(opts) {
|
|
29
|
+
let offset = 0;
|
|
30
|
+
let { code } = opts;
|
|
31
|
+
const { imports } = opts;
|
|
32
|
+
imports.forEach((i) => {
|
|
33
|
+
if (!i.n)
|
|
34
|
+
return;
|
|
35
|
+
const isLazyImport = i.d > 0;
|
|
36
|
+
const from = i.n;
|
|
37
|
+
const replaceValue = params.resolveImportSource(from);
|
|
38
|
+
if (replaceValue !== from) {
|
|
39
|
+
const preSeg = code.substring(0, i.s + offset);
|
|
40
|
+
const tailSeg = code.substring(i.e + offset);
|
|
41
|
+
const quote = isLazyImport ? '"' : "";
|
|
42
|
+
code = `${preSeg}${quote}${replaceValue}${quote}${tailSeg}`;
|
|
43
|
+
offset += replaceValue.length - from.length;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return code;
|
|
47
|
+
};
|
|
32
48
|
}
|
|
33
|
-
exports.getImportHandlerV4 = getImportHandlerV4;
|
|
34
49
|
function getAwaitImportHandler(params) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
file: filePath,
|
|
68
|
-
data: params.cache.get(filePath),
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return code;
|
|
72
|
-
};
|
|
50
|
+
return function awaitImportHandler(opts) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
let offset = 0;
|
|
53
|
+
let { code } = opts;
|
|
54
|
+
const { filePath, imports } = opts;
|
|
55
|
+
imports.forEach((i) => {
|
|
56
|
+
if (!i.n)
|
|
57
|
+
return;
|
|
58
|
+
const isLazyImport = i.d > 0;
|
|
59
|
+
const from = i.n;
|
|
60
|
+
const { isMatch, replaceValue } = (0, import_checkMatch.checkMatch)({
|
|
61
|
+
cache: params.cache,
|
|
62
|
+
value: from,
|
|
63
|
+
opts: params.opts,
|
|
64
|
+
filename: filePath
|
|
65
|
+
});
|
|
66
|
+
if (isMatch) {
|
|
67
|
+
const preSeg = code.substring(0, i.s + offset);
|
|
68
|
+
const tailSeg = code.substring(i.e + offset);
|
|
69
|
+
const quote = isLazyImport ? '"' : "";
|
|
70
|
+
code = `${preSeg}${quote}${replaceValue}${quote}${tailSeg}`;
|
|
71
|
+
offset += replaceValue.length - from.length;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
if (params.cache.has(filePath)) {
|
|
75
|
+
(_b = (_a = params.opts).onCollect) == null ? void 0 : _b.call(_a, {
|
|
76
|
+
file: filePath,
|
|
77
|
+
data: params.cache.get(filePath)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return code;
|
|
81
|
+
};
|
|
73
82
|
}
|
|
74
|
-
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
getImportHandlerV4
|
|
86
|
+
});
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
8
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
esbuildLoader: () => import_esbuild.esbuildLoader
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
__reExport(src_exports, require("./constants"), module.exports);
|
|
27
|
+
__reExport(src_exports, require("./esbuildHandlers/autoCssModules"), module.exports);
|
|
28
|
+
var import_esbuild = require("./loader/esbuild");
|
|
29
|
+
__reExport(src_exports, require("./mfsu/mfsu"), module.exports);
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
esbuildLoader
|
|
33
|
+
});
|
package/dist/loader/esbuild.d.ts
CHANGED
|
@@ -3,4 +3,3 @@ import type { IEsbuildLoaderOpts } from '../types';
|
|
|
3
3
|
declare function esbuildTranspiler(this: LoaderContext<IEsbuildLoaderOpts>, source: string): Promise<void>;
|
|
4
4
|
export default esbuildTranspiler;
|
|
5
5
|
export declare const esbuildLoader: string;
|
|
6
|
-
//# sourceMappingURL=esbuild.d.ts.map
|