@umijs/mfsu 4.0.6 → 4.0.9

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.
Files changed (40) hide show
  1. package/compiled/is-absolute-url/LICENSE +9 -0
  2. package/compiled/is-absolute-url/index.d.ts +22 -0
  3. package/compiled/is-absolute-url/index.js +1 -0
  4. package/compiled/is-absolute-url/package.json +1 -0
  5. package/dist/babelPlugins/awaitImport/MFImport.js +59 -66
  6. package/dist/babelPlugins/awaitImport/awaitImport.d.ts +1 -1
  7. package/dist/babelPlugins/awaitImport/awaitImport.js +103 -117
  8. package/dist/babelPlugins/awaitImport/checkMatch.js +131 -119
  9. package/dist/babelPlugins/awaitImport/getAliasedPath.js +54 -35
  10. package/dist/babelPlugins/awaitImport/getRealPath.js +42 -21
  11. package/dist/babelPlugins/awaitImport/isExternals.js +55 -26
  12. package/dist/babelPlugins/awaitImport/parseSpecifiers.js +51 -52
  13. package/dist/constants.js +47 -10
  14. package/dist/dep/dep.js +112 -83
  15. package/dist/dep/getCJSExports.js +60 -53
  16. package/dist/dep/getExposeFromContent.js +71 -59
  17. package/dist/dep/getModuleExports.js +58 -32
  18. package/dist/depBuilder/depBuilder.js +184 -158
  19. package/dist/depBuilder/getESBuildEntry.js +35 -12
  20. package/dist/depInfo.js +75 -53
  21. package/dist/esbuildHandlers/autoCssModules.js +43 -22
  22. package/dist/esbuildHandlers/awaitImport/index.js +82 -70
  23. package/dist/index.js +32 -22
  24. package/dist/loader/esbuild.js +87 -35
  25. package/dist/mfsu/mfsu.d.ts +1 -1
  26. package/dist/mfsu/mfsu.js +231 -257
  27. package/dist/mfsu/strategyCompileTime.js +123 -99
  28. package/dist/mfsu/strategyStaticAnalyze.js +135 -117
  29. package/dist/moduleGraph.js +227 -186
  30. package/dist/staticDepInfo/importParser.js +28 -6
  31. package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -91
  32. package/dist/staticDepInfo/staticDepInfo.js +230 -197
  33. package/dist/types.js +33 -8
  34. package/dist/utils/makeArray.js +29 -5
  35. package/dist/utils/trimFileContent.js +29 -5
  36. package/dist/webpackPlugins/buildDepPlugin.js +49 -25
  37. package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +44 -19
  38. package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +46 -27
  39. package/dist/webpackPlugins/writeCachePlugin.js +39 -15
  40. package/package.json +8 -6
@@ -1,74 +1,86 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImportHandlerV4 = void 0;
4
- const checkMatch_1 = require("../../babelPlugins/awaitImport/checkMatch");
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
+ // 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
- return function awaitImportHandler(opts) {
7
- let offset = 0;
8
- let { code } = opts;
9
- const { imports } = opts;
10
- imports.forEach((i) => {
11
- if (!i.n)
12
- return;
13
- const isLazyImport = i.d > 0;
14
- const from = i.n;
15
- const replaceValue = params.resolveImportSource(from);
16
- if (replaceValue !== from) {
17
- // case: import x from './index.ts';
18
- // import('./index.ts');
19
- // import x from '
20
- // import(
21
- const preSeg = code.substring(0, i.s + offset);
22
- // ';
23
- // );
24
- const tailSeg = code.substring(i.e + offset);
25
- const quote = isLazyImport ? '"' : '';
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
- return function awaitImportHandler(opts) {
36
- var _a, _b;
37
- let offset = 0;
38
- let { code } = opts;
39
- const { filePath, imports } = opts;
40
- imports.forEach((i) => {
41
- if (!i.n)
42
- return;
43
- const isLazyImport = i.d > 0;
44
- const from = i.n;
45
- const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
46
- cache: params.cache,
47
- value: from,
48
- opts: params.opts,
49
- filename: filePath,
50
- });
51
- if (isMatch) {
52
- // case: import x from './index.ts';
53
- // import('./index.ts');
54
- // import x from '
55
- // import(
56
- const preSeg = code.substring(0, i.s + offset);
57
- // ';
58
- // );
59
- const tailSeg = code.substring(i.e + offset);
60
- const quote = isLazyImport ? '"' : '';
61
- code = `${preSeg}${quote}${replaceValue}${quote}${tailSeg}`;
62
- offset += replaceValue.length - from.length;
63
- }
64
- });
65
- if (params.cache.has(filePath)) {
66
- (_b = (_a = params.opts).onCollect) === null || _b === void 0 ? void 0 : _b.call(_a, {
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
- exports.default = getAwaitImportHandler;
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ getImportHandlerV4
86
+ });
package/dist/index.js CHANGED
@@ -1,23 +1,33 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
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
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.esbuildLoader = void 0;
18
- __exportStar(require("./constants"), exports);
19
- __exportStar(require("./esbuildHandlers/autoCssModules"), exports);
20
- // for independent use `esbuild-loader`
21
- var esbuild_1 = require("./loader/esbuild");
22
- Object.defineProperty(exports, "esbuildLoader", { enumerable: true, get: function () { return esbuild_1.esbuildLoader; } });
23
- __exportStar(require("./mfsu/mfsu"), exports);
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
+ // 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
+ });
@@ -1,38 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.esbuildLoader = void 0;
4
- const es_module_lexer_1 = require("@umijs/bundler-utils/compiled/es-module-lexer");
5
- const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
6
- const path_1 = require("path");
7
- async function esbuildTranspiler(source) {
8
- var _a;
9
- const done = this.async();
10
- const options = this.getOptions();
11
- const { handler = [], implementation, ...otherOptions } = options;
12
- const transform = (implementation === null || implementation === void 0 ? void 0 : implementation.transform) || esbuild_1.transform;
13
- const filePath = this.resourcePath;
14
- const ext = (0, path_1.extname)(filePath).slice(1);
15
- const transformOptions = {
16
- ...otherOptions,
17
- target: (_a = options.target) !== null && _a !== void 0 ? _a : 'es2015',
18
- loader: ext !== null && ext !== void 0 ? ext : 'js',
19
- sourcemap: this.sourceMap,
20
- sourcefile: filePath,
21
- };
22
- try {
23
- let { code, map } = await transform(source, transformOptions);
24
- if (handler.length) {
25
- await es_module_lexer_1.init;
26
- handler.forEach((handle) => {
27
- const [imports, exports] = (0, es_module_lexer_1.parse)(code);
28
- code = handle({ code, imports, exports, filePath });
29
- });
30
- }
31
- done(null, code, map && JSON.parse(map));
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ 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];
32
31
  }
33
- catch (error) {
34
- done(error);
32
+ return target;
33
+ };
34
+ var __export = (target, all) => {
35
+ for (var name in all)
36
+ __defProp(target, name, { get: all[name], enumerable: true });
37
+ };
38
+ var __copyProps = (to, from, except, desc) => {
39
+ if (from && typeof from === "object" || typeof from === "function") {
40
+ for (let key of __getOwnPropNames(from))
41
+ if (!__hasOwnProp.call(to, key) && key !== except)
42
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
43
+ }
44
+ return to;
45
+ };
46
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
+
48
+ // esbuild.ts
49
+ var esbuild_exports = {};
50
+ __export(esbuild_exports, {
51
+ default: () => esbuild_default,
52
+ esbuildLoader: () => esbuildLoader
53
+ });
54
+ module.exports = __toCommonJS(esbuild_exports);
55
+ var import_es_module_lexer = require("@umijs/bundler-utils/compiled/es-module-lexer");
56
+ var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
57
+ var import_path = require("path");
58
+ async function esbuildTranspiler(source) {
59
+ const done = this.async();
60
+ const options = this.getOptions();
61
+ const _a = options, { handler = [], implementation } = _a, otherOptions = __objRest(_a, ["handler", "implementation"]);
62
+ const transform = (implementation == null ? void 0 : implementation.transform) || import_esbuild.transform;
63
+ const filePath = this.resourcePath;
64
+ const ext = (0, import_path.extname)(filePath).slice(1);
65
+ const transformOptions = __spreadProps(__spreadValues({}, otherOptions), {
66
+ target: options.target ?? "es2015",
67
+ loader: ext ?? "js",
68
+ sourcemap: this.sourceMap,
69
+ sourcefile: filePath
70
+ });
71
+ try {
72
+ let { code, map } = await transform(source, transformOptions);
73
+ if (handler.length) {
74
+ await import_es_module_lexer.init;
75
+ handler.forEach((handle) => {
76
+ const [imports, exports] = (0, import_es_module_lexer.parse)(code);
77
+ code = handle({ code, imports, exports, filePath });
78
+ });
35
79
  }
80
+ done(null, code, map && JSON.parse(map));
81
+ } catch (error) {
82
+ done(error);
83
+ }
36
84
  }
37
- exports.default = esbuildTranspiler;
38
- exports.esbuildLoader = __filename;
85
+ var esbuild_default = esbuildTranspiler;
86
+ var esbuildLoader = __filename;
87
+ // Annotate the CommonJS export names for ESM import in node:
88
+ 0 && (module.exports = {
89
+ esbuildLoader
90
+ });
@@ -13,7 +13,7 @@ interface IOpts {
13
13
  mfName?: string;
14
14
  mode?: Mode;
15
15
  tmpBase?: string;
16
- unMatchLibs?: string[];
16
+ unMatchLibs?: Array<string | RegExp>;
17
17
  runtimePublicPath?: boolean | string;
18
18
  implementor: typeof webpack;
19
19
  buildDepWithESBuild?: boolean;