@umijs/mfsu 4.0.8 → 4.0.11

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 (71) 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.d.ts +0 -0
  6. package/dist/babelPlugins/awaitImport/MFImport.js +1 -1
  7. package/dist/babelPlugins/awaitImport/awaitImport.d.ts +0 -0
  8. package/dist/babelPlugins/awaitImport/awaitImport.js +1 -1
  9. package/dist/babelPlugins/awaitImport/checkMatch.d.ts +0 -0
  10. package/dist/babelPlugins/awaitImport/checkMatch.js +129 -132
  11. package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts +0 -0
  12. package/dist/babelPlugins/awaitImport/getAliasedPath.js +1 -1
  13. package/dist/babelPlugins/awaitImport/getRealPath.d.ts +0 -0
  14. package/dist/babelPlugins/awaitImport/getRealPath.js +1 -1
  15. package/dist/babelPlugins/awaitImport/isExternals.d.ts +0 -0
  16. package/dist/babelPlugins/awaitImport/isExternals.js +1 -1
  17. package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts +0 -0
  18. package/dist/babelPlugins/awaitImport/parseSpecifiers.js +1 -1
  19. package/dist/constants.d.ts +0 -0
  20. package/dist/constants.js +1 -1
  21. package/dist/dep/dep.d.ts +0 -0
  22. package/dist/dep/dep.js +112 -83
  23. package/dist/dep/getCJSExports.d.ts +0 -0
  24. package/dist/dep/getCJSExports.js +1 -1
  25. package/dist/dep/getExposeFromContent.d.ts +0 -0
  26. package/dist/dep/getExposeFromContent.js +1 -1
  27. package/dist/dep/getModuleExports.d.ts +0 -0
  28. package/dist/dep/getModuleExports.js +1 -1
  29. package/dist/depBuilder/depBuilder.d.ts +0 -0
  30. package/dist/depBuilder/depBuilder.js +191 -158
  31. package/dist/depBuilder/getESBuildEntry.d.ts +0 -0
  32. package/dist/depBuilder/getESBuildEntry.js +1 -1
  33. package/dist/depInfo.d.ts +0 -0
  34. package/dist/depInfo.js +75 -53
  35. package/dist/esbuildHandlers/autoCssModules.d.ts +0 -0
  36. package/dist/esbuildHandlers/autoCssModules.js +43 -22
  37. package/dist/esbuildHandlers/awaitImport/index.d.ts +0 -0
  38. package/dist/esbuildHandlers/awaitImport/index.js +1 -1
  39. package/dist/index.d.ts +0 -0
  40. package/dist/index.js +1 -1
  41. package/dist/loader/esbuild.d.ts +0 -0
  42. package/dist/loader/esbuild.js +1 -1
  43. package/dist/mfsu/mfsu.d.ts +4 -0
  44. package/dist/mfsu/mfsu.js +236 -257
  45. package/dist/mfsu/strategyCompileTime.d.ts +0 -0
  46. package/dist/mfsu/strategyCompileTime.js +131 -99
  47. package/dist/mfsu/strategyStaticAnalyze.d.ts +0 -0
  48. package/dist/mfsu/strategyStaticAnalyze.js +151 -115
  49. package/dist/moduleGraph.d.ts +0 -0
  50. package/dist/moduleGraph.js +227 -186
  51. package/dist/staticDepInfo/importParser.d.ts +0 -0
  52. package/dist/staticDepInfo/importParser.js +1 -1
  53. package/dist/staticDepInfo/simulations/babel-plugin-import.d.ts +0 -0
  54. package/dist/staticDepInfo/simulations/babel-plugin-import.js +99 -91
  55. package/dist/staticDepInfo/staticDepInfo.d.ts +0 -0
  56. package/dist/staticDepInfo/staticDepInfo.js +239 -197
  57. package/dist/types.d.ts +0 -0
  58. package/dist/types.js +1 -1
  59. package/dist/utils/makeArray.d.ts +0 -0
  60. package/dist/utils/makeArray.js +1 -1
  61. package/dist/utils/trimFileContent.d.ts +0 -0
  62. package/dist/utils/trimFileContent.js +1 -1
  63. package/dist/webpackPlugins/buildDepPlugin.d.ts +0 -0
  64. package/dist/webpackPlugins/buildDepPlugin.js +1 -1
  65. package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts +0 -0
  66. package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +1 -1
  67. package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +0 -0
  68. package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +1 -1
  69. package/dist/webpackPlugins/writeCachePlugin.d.ts +0 -0
  70. package/dist/webpackPlugins/writeCachePlugin.js +1 -1
  71. package/package.json +8 -6
File without changes
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // getModuleExports.ts
19
+ // src/dep/getModuleExports.ts
20
20
  var getModuleExports_exports = {};
21
21
  __export(getModuleExports_exports, {
22
22
  getModuleExports: () => getModuleExports
File without changes
@@ -1,164 +1,197 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DepBuilder = void 0;
4
- const bundler_esbuild_1 = require("@umijs/bundler-esbuild");
5
- const utils_1 = require("@umijs/utils");
6
- const fs_1 = require("fs");
7
- const path_1 = require("path");
8
- const constants_1 = require("../constants");
9
- const depChunkIdPrefixPlugin_1 = require("../webpackPlugins/depChunkIdPrefixPlugin");
10
- const stripSourceMapUrlPlugin_1 = require("../webpackPlugins/stripSourceMapUrlPlugin");
11
- const getESBuildEntry_1 = require("./getESBuildEntry");
12
- class DepBuilder {
13
- constructor(opts) {
14
- this.completeFns = [];
15
- this.isBuilding = false;
16
- this.opts = opts;
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]);
17
18
  }
18
- async buildWithWebpack(opts) {
19
- const config = this.getWebpackConfig({ deps: opts.deps });
20
- return new Promise((resolve, reject) => {
21
- const compiler = this.opts.mfsu.opts.implementor(config);
22
- compiler.run((err, stats) => {
23
- opts.onBuildComplete();
24
- if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
25
- if (err) {
26
- reject(err);
27
- }
28
- if (stats) {
29
- const errorMsg = stats.toString('errors-only');
30
- // console.error(errorMsg);
31
- reject(new Error(errorMsg));
32
- }
33
- }
34
- else {
35
- resolve(stats);
36
- }
37
- compiler.close(() => { });
38
- });
39
- });
40
- }
41
- // TODO: support watch and rebuild
42
- async buildWithESBuild(opts) {
43
- const entryContent = (0, getESBuildEntry_1.getESBuildEntry)({ deps: opts.deps });
44
- const ENTRY_FILE = 'esbuild-entry.js';
45
- const tmpDir = this.opts.mfsu.opts.tmpBase;
46
- const entryPath = (0, path_1.join)(tmpDir, ENTRY_FILE);
47
- (0, fs_1.writeFileSync)(entryPath, entryContent, 'utf-8');
48
- const date = new Date().getTime();
49
- await (0, bundler_esbuild_1.build)({
50
- cwd: this.opts.mfsu.opts.cwd,
51
- entry: {
52
- [`${constants_1.MF_VA_PREFIX}remoteEntry`]: entryPath,
53
- },
54
- config: {
55
- ...this.opts.mfsu.opts.depBuildConfig,
56
- outputPath: tmpDir,
57
- alias: this.opts.mfsu.alias,
58
- externals: this.opts.mfsu.externals,
59
- },
60
- inlineStyle: true,
61
- });
62
- utils_1.logger.event(`[mfsu] compiled with esbuild successfully in ${+new Date() - date} ms`);
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+
36
+ // src/depBuilder/depBuilder.ts
37
+ var depBuilder_exports = {};
38
+ __export(depBuilder_exports, {
39
+ DepBuilder: () => DepBuilder
40
+ });
41
+ module.exports = __toCommonJS(depBuilder_exports);
42
+ var import_bundler_esbuild = require("@umijs/bundler-esbuild");
43
+ var import_utils = require("@umijs/utils");
44
+ var import_fs = require("fs");
45
+ var import_path = require("path");
46
+ var import_constants = require("../constants");
47
+ var import_depChunkIdPrefixPlugin = require("../webpackPlugins/depChunkIdPrefixPlugin");
48
+ var import_stripSourceMapUrlPlugin = require("../webpackPlugins/stripSourceMapUrlPlugin");
49
+ var import_getESBuildEntry = require("./getESBuildEntry");
50
+ var DepBuilder = class {
51
+ constructor(opts) {
52
+ this.completeFns = [];
53
+ this.isBuilding = false;
54
+ this.opts = opts;
55
+ }
56
+ async buildWithWebpack(opts) {
57
+ const config = this.getWebpackConfig({ deps: opts.deps });
58
+ return new Promise((resolve, reject) => {
59
+ const compiler = this.opts.mfsu.opts.implementor(config);
60
+ compiler.run((err, stats) => {
63
61
  opts.onBuildComplete();
64
- }
65
- async build(opts) {
66
- this.isBuilding = true;
67
- const onBuildComplete = () => {
68
- this.isBuilding = false;
69
- this.completeFns.forEach((fn) => fn());
70
- this.completeFns = [];
71
- };
72
- try {
73
- await this.writeMFFiles({ deps: opts.deps });
74
- const newOpts = {
75
- ...opts,
76
- onBuildComplete,
77
- };
78
- if (this.opts.mfsu.opts.buildDepWithESBuild) {
79
- await this.buildWithESBuild(newOpts);
80
- }
81
- else {
82
- await this.buildWithWebpack(newOpts);
83
- }
84
- }
85
- catch (e) {
86
- onBuildComplete();
87
- throw e;
88
- }
89
- }
90
- onBuildComplete(fn) {
91
- if (this.isBuilding) {
92
- this.completeFns.push(fn);
93
- }
94
- else {
95
- fn();
62
+ if (err || (stats == null ? void 0 : stats.hasErrors())) {
63
+ if (err) {
64
+ reject(err);
65
+ }
66
+ if (stats) {
67
+ const errorMsg = stats.toString("errors-only");
68
+ reject(new Error(errorMsg));
69
+ }
70
+ } else {
71
+ resolve(stats);
96
72
  }
73
+ compiler.close(() => {
74
+ });
75
+ });
76
+ });
77
+ }
78
+ async buildWithESBuild(opts) {
79
+ const entryContent = (0, import_getESBuildEntry.getESBuildEntry)({ deps: opts.deps });
80
+ const ENTRY_FILE = "esbuild-entry.js";
81
+ const tmpDir = this.opts.mfsu.opts.tmpBase;
82
+ const entryPath = (0, import_path.join)(tmpDir, ENTRY_FILE);
83
+ (0, import_fs.writeFileSync)(entryPath, entryContent, "utf-8");
84
+ const date = new Date().getTime();
85
+ await (0, import_bundler_esbuild.build)({
86
+ cwd: this.opts.mfsu.opts.cwd,
87
+ entry: {
88
+ [`${import_constants.MF_VA_PREFIX}remoteEntry`]: entryPath
89
+ },
90
+ config: __spreadProps(__spreadValues({}, this.opts.mfsu.opts.depBuildConfig), {
91
+ outputPath: tmpDir,
92
+ alias: this.opts.mfsu.alias,
93
+ externals: this.opts.mfsu.externals
94
+ }),
95
+ inlineStyle: true
96
+ });
97
+ import_utils.logger.event(`[mfsu] compiled with esbuild successfully in ${+new Date() - date} ms`);
98
+ opts.onBuildComplete();
99
+ }
100
+ async build(opts) {
101
+ this.isBuilding = true;
102
+ const onBuildComplete = () => {
103
+ this.isBuilding = false;
104
+ this.completeFns.forEach((fn) => fn());
105
+ this.completeFns = [];
106
+ };
107
+ try {
108
+ await this.writeMFFiles({ deps: opts.deps });
109
+ const newOpts = __spreadProps(__spreadValues({}, opts), {
110
+ onBuildComplete
111
+ });
112
+ if (this.opts.mfsu.opts.buildDepWithESBuild) {
113
+ await this.buildWithESBuild(newOpts);
114
+ } else {
115
+ await this.buildWithWebpack(newOpts);
116
+ }
117
+ } catch (e) {
118
+ onBuildComplete();
119
+ throw e;
97
120
  }
98
- async writeMFFiles(opts) {
99
- const tmpBase = this.opts.mfsu.opts.tmpBase;
100
- utils_1.fsExtra.mkdirpSync(tmpBase);
101
- // expose files
102
- for (const dep of opts.deps) {
103
- const content = await dep.buildExposeContent();
104
- (0, fs_1.writeFileSync)((0, path_1.join)(tmpBase, dep.filePath), content, 'utf-8');
105
- }
106
- // index file
107
- (0, fs_1.writeFileSync)((0, path_1.join)(tmpBase, 'index.js'), '"😛"', 'utf-8');
121
+ }
122
+ onBuildComplete(fn) {
123
+ if (this.isBuilding) {
124
+ this.completeFns.push(fn);
125
+ } else {
126
+ fn();
108
127
  }
109
- getWebpackConfig(opts) {
110
- var _a, _b;
111
- const mfName = this.opts.mfsu.opts.mfName;
112
- const depConfig = utils_1.lodash.cloneDeep(this.opts.mfsu.depConfig);
113
- // depConfig.stats = 'none';
114
- depConfig.entry = (0, path_1.join)(this.opts.mfsu.opts.tmpBase, 'index.js');
115
- depConfig.output.path = this.opts.mfsu.opts.tmpBase;
116
- // disable devtool
117
- depConfig.devtool = false;
118
- // disable library
119
- // library 会影响 external 的语法,导致报错
120
- // ref: https://github.com/umijs/plugins/blob/6d3fc2d/packages/plugin-qiankun/src/slave/index.ts#L83
121
- if ((_a = depConfig.output) === null || _a === void 0 ? void 0 : _a.library)
122
- delete depConfig.output.library;
123
- if ((_b = depConfig.output) === null || _b === void 0 ? void 0 : _b.libraryTarget)
124
- delete depConfig.output.libraryTarget;
125
- // merge all deps to vendor
126
- depConfig.optimization || (depConfig.optimization = {});
127
- depConfig.optimization.splitChunks = {
128
- chunks: 'all',
129
- maxInitialRequests: Infinity,
130
- minSize: 0,
131
- cacheGroups: {
132
- vendor: {
133
- test: /.+/,
134
- name(_module, _chunks, cacheGroupKey) {
135
- return `${constants_1.MF_DEP_PREFIX}___${cacheGroupKey}`;
136
- },
137
- },
138
- },
139
- };
140
- depConfig.plugins = depConfig.plugins || [];
141
- depConfig.plugins.push(new depChunkIdPrefixPlugin_1.DepChunkIdPrefixPlugin());
142
- depConfig.plugins.push(new stripSourceMapUrlPlugin_1.StripSourceMapUrlPlugin({
143
- webpack: this.opts.mfsu.opts.implementor,
144
- }));
145
- depConfig.plugins.push(new this.opts.mfsu.opts.implementor.ProgressPlugin((percent, msg) => {
146
- this.opts.mfsu.onProgress({ percent, status: msg });
147
- }));
148
- const exposes = opts.deps.reduce((memo, dep) => {
149
- memo[`./${dep.file}`] = (0, path_1.join)(this.opts.mfsu.opts.tmpBase, dep.filePath);
150
- return memo;
151
- }, {});
152
- depConfig.plugins.push(new this.opts.mfsu.opts.implementor.container.ModuleFederationPlugin({
153
- library: {
154
- type: 'global',
155
- name: mfName,
156
- },
157
- name: mfName,
158
- filename: constants_1.REMOTE_FILE_FULL,
159
- exposes,
160
- }));
161
- return depConfig;
128
+ }
129
+ async writeMFFiles(opts) {
130
+ const tmpBase = this.opts.mfsu.opts.tmpBase;
131
+ import_utils.fsExtra.mkdirpSync(tmpBase);
132
+ for (const dep of opts.deps) {
133
+ const content = await dep.buildExposeContent();
134
+ (0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, dep.filePath), content, "utf-8");
162
135
  }
163
- }
164
- exports.DepBuilder = DepBuilder;
136
+ (0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, "index.js"), '"\u{1F61B}"', "utf-8");
137
+ }
138
+ getWebpackConfig(opts) {
139
+ var _a, _b;
140
+ const mfName = this.opts.mfsu.opts.mfName;
141
+ const depConfig = import_utils.lodash.cloneDeep(this.opts.mfsu.depConfig);
142
+ depConfig.entry = (0, import_path.join)(this.opts.mfsu.opts.tmpBase, "index.js");
143
+ depConfig.output.path = this.opts.mfsu.opts.tmpBase;
144
+ depConfig.output.publicPath = "auto";
145
+ depConfig.devtool = false;
146
+ if ((_a = depConfig.output) == null ? void 0 : _a.library)
147
+ delete depConfig.output.library;
148
+ if ((_b = depConfig.output) == null ? void 0 : _b.libraryTarget)
149
+ delete depConfig.output.libraryTarget;
150
+ depConfig.optimization || (depConfig.optimization = {});
151
+ depConfig.optimization.splitChunks = {
152
+ chunks: (chunk) => {
153
+ const hasShared = chunk.getModules().some((m) => {
154
+ return m.type === "consume-shared-module" || m.type === "provide-module" || m.type === "provide-shared-module";
155
+ });
156
+ return !hasShared;
157
+ },
158
+ maxInitialRequests: Infinity,
159
+ minSize: 0,
160
+ cacheGroups: {
161
+ vendor: {
162
+ test: /.+/,
163
+ name(_module, _chunks, cacheGroupKey) {
164
+ return `${import_constants.MF_DEP_PREFIX}___${cacheGroupKey}`;
165
+ }
166
+ }
167
+ }
168
+ };
169
+ depConfig.plugins = depConfig.plugins || [];
170
+ depConfig.plugins.push(new import_depChunkIdPrefixPlugin.DepChunkIdPrefixPlugin());
171
+ depConfig.plugins.push(new import_stripSourceMapUrlPlugin.StripSourceMapUrlPlugin({
172
+ webpack: this.opts.mfsu.opts.implementor
173
+ }));
174
+ depConfig.plugins.push(new this.opts.mfsu.opts.implementor.ProgressPlugin((percent, msg) => {
175
+ this.opts.mfsu.onProgress({ percent, status: msg });
176
+ }));
177
+ const exposes = opts.deps.reduce((memo, dep) => {
178
+ memo[`./${dep.file}`] = (0, import_path.join)(this.opts.mfsu.opts.tmpBase, dep.filePath);
179
+ return memo;
180
+ }, {});
181
+ depConfig.plugins.push(new this.opts.mfsu.opts.implementor.container.ModuleFederationPlugin({
182
+ library: {
183
+ type: "global",
184
+ name: mfName
185
+ },
186
+ name: mfName,
187
+ filename: import_constants.REMOTE_FILE_FULL,
188
+ exposes,
189
+ shared: this.opts.mfsu.opts.shared || {}
190
+ }));
191
+ return depConfig;
192
+ }
193
+ };
194
+ // Annotate the CommonJS export names for ESM import in node:
195
+ 0 && (module.exports = {
196
+ DepBuilder
197
+ });
File without changes
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // getESBuildEntry.ts
19
+ // src/depBuilder/getESBuildEntry.ts
20
20
  var getESBuildEntry_exports = {};
21
21
  __export(getESBuildEntry_exports, {
22
22
  getESBuildEntry: () => getESBuildEntry
package/dist/depInfo.d.ts CHANGED
File without changes
package/dist/depInfo.js CHANGED
@@ -1,57 +1,79 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DepInfo = void 0;
4
- const utils_1 = require("@umijs/utils");
5
- const fs_1 = require("fs");
6
- const path_1 = require("path");
7
- const moduleGraph_1 = require("./moduleGraph");
8
- class DepInfo {
9
- constructor(opts) {
10
- this.moduleGraph = new moduleGraph_1.ModuleGraph();
11
- this.cacheDependency = {};
12
- this.opts = opts;
13
- this.cacheFilePath = (0, path_1.join)(this.opts.mfsu.opts.tmpBase, 'MFSU_CACHE.json');
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
- shouldBuild() {
16
- if (!utils_1.lodash.isEqual(this.cacheDependency, this.opts.mfsu.opts.getCacheDependency())) {
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
- snapshot() {
26
- this.cacheDependency = this.opts.mfsu.opts.getCacheDependency();
27
- this.moduleGraph.snapshotDeps();
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
- loadCache() {
30
- if ((0, fs_1.existsSync)(this.cacheFilePath)) {
31
- utils_1.logger.info('[MFSU] restore cache');
32
- const { cacheDependency, moduleGraph } = JSON.parse((0, fs_1.readFileSync)(this.cacheFilePath, 'utf-8'));
33
- this.cacheDependency = cacheDependency;
34
- this.moduleGraph.restore(moduleGraph);
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
- writeCache() {
38
- utils_1.fsExtra.mkdirpSync((0, path_1.dirname)(this.cacheFilePath));
39
- const newContent = JSON.stringify({
40
- cacheDependency: this.cacheDependency,
41
- moduleGraph: this.moduleGraph.toJSON(),
42
- }, null, 2);
43
- if ((0, fs_1.existsSync)(this.cacheFilePath) &&
44
- (0, fs_1.readFileSync)(this.cacheFilePath, 'utf-8') === newContent) {
45
- return;
46
- }
47
- utils_1.logger.info('[MFSU] write cache');
48
- (0, fs_1.writeFileSync)(this.cacheFilePath, newContent, 'utf-8');
49
- }
50
- getDepModules() {
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
+ });
File without changes
@@ -1,24 +1,45 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.autoCssModulesHandler = void 0;
4
- const utils_1 = require("@umijs/utils");
5
- const CSS_MODULES_QUERY = '?modules';
6
- const QUERY_LENGTH = CSS_MODULES_QUERY.length;
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
- let { code } = opts;
9
- let offset = 0;
10
- opts.imports.forEach((i) => {
11
- if (i.d < 0 && (0, utils_1.isStyleFile)({ filename: i.n })) {
12
- // import x from './index.less'
13
- // => import x from '
14
- const importSegment = code.substring(i.ss + offset, i.s + offset);
15
- // is css module
16
- if (~importSegment.indexOf(' from')) {
17
- code = `${code.substring(0, i.e + offset)}${CSS_MODULES_QUERY}${code.substring(i.e + offset)}`;
18
- offset += QUERY_LENGTH;
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
- exports.autoCssModulesHandler = autoCssModulesHandler;
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ autoCssModulesHandler
45
+ });
File without changes
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // index.ts
19
+ // src/esbuildHandlers/awaitImport/index.ts
20
20
  var awaitImport_exports = {};
21
21
  __export(awaitImport_exports, {
22
22
  default: () => getAwaitImportHandler,
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // index.ts
20
+ // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  esbuildLoader: () => import_esbuild.esbuildLoader
File without changes
@@ -45,7 +45,7 @@ var __copyProps = (to, from, except, desc) => {
45
45
  };
46
46
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
47
47
 
48
- // esbuild.ts
48
+ // src/loader/esbuild.ts
49
49
  var esbuild_exports = {};
50
50
  __export(esbuild_exports, {
51
51
  default: () => esbuild_default,
@@ -21,6 +21,10 @@ interface IOpts {
21
21
  strategy?: 'eager' | 'normal';
22
22
  include?: string[];
23
23
  srcCodeCache?: any;
24
+ shared?: any;
25
+ remoteName?: string;
26
+ remoteAliases?: string[];
27
+ serverBase: string;
24
28
  }
25
29
  export declare class MFSU {
26
30
  opts: IOpts;