@umijs/mfsu 4.0.0-canary.20220727.1 → 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.
Files changed (39) 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 +1 -1
  6. package/dist/babelPlugins/awaitImport/awaitImport.js +1 -1
  7. package/dist/babelPlugins/awaitImport/checkMatch.js +1 -1
  8. package/dist/babelPlugins/awaitImport/getAliasedPath.js +1 -1
  9. package/dist/babelPlugins/awaitImport/getRealPath.js +1 -1
  10. package/dist/babelPlugins/awaitImport/isExternals.js +1 -1
  11. package/dist/babelPlugins/awaitImport/parseSpecifiers.js +1 -1
  12. package/dist/constants.js +1 -1
  13. package/dist/dep/dep.js +1 -1
  14. package/dist/dep/getCJSExports.js +1 -1
  15. package/dist/dep/getExposeFromContent.js +1 -1
  16. package/dist/dep/getModuleExports.js +1 -1
  17. package/dist/depBuilder/depBuilder.js +13 -5
  18. package/dist/depBuilder/getESBuildEntry.js +1 -1
  19. package/dist/depInfo.js +1 -1
  20. package/dist/esbuildHandlers/autoCssModules.js +1 -1
  21. package/dist/esbuildHandlers/awaitImport/index.js +1 -1
  22. package/dist/index.js +1 -1
  23. package/dist/loader/esbuild.js +1 -1
  24. package/dist/mfsu/mfsu.d.ts +4 -0
  25. package/dist/mfsu/mfsu.js +11 -4
  26. package/dist/mfsu/strategyCompileTime.js +10 -2
  27. package/dist/mfsu/strategyStaticAnalyze.js +25 -7
  28. package/dist/moduleGraph.js +1 -1
  29. package/dist/staticDepInfo/importParser.js +1 -1
  30. package/dist/staticDepInfo/simulations/babel-plugin-import.js +3 -3
  31. package/dist/staticDepInfo/staticDepInfo.js +11 -2
  32. package/dist/types.js +1 -1
  33. package/dist/utils/makeArray.js +1 -1
  34. package/dist/utils/trimFileContent.js +1 -1
  35. package/dist/webpackPlugins/buildDepPlugin.js +1 -1
  36. package/dist/webpackPlugins/depChunkIdPrefixPlugin.js +1 -1
  37. package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +1 -1
  38. package/dist/webpackPlugins/writeCachePlugin.js +1 -1
  39. package/package.json +6 -4
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ /**
2
+ Check if a URL is absolute.
3
+
4
+ @param url - The URL to check.
5
+
6
+ @example
7
+ ```
8
+ import isAbsoluteUrl = require('./is-absolute-url');
9
+
10
+ isAbsoluteUrl('http://sindresorhus.com/foo/bar');
11
+ //=> true
12
+
13
+ isAbsoluteUrl('//sindresorhus.com');
14
+ //=> false
15
+
16
+ isAbsoluteUrl('foo/bar');
17
+ //=> false
18
+ ```
19
+ */
20
+ declare function isAbsoluteUrl(url: string): boolean;
21
+
22
+ export = isAbsoluteUrl;
@@ -0,0 +1 @@
1
+ (function(){"use strict";var e={442:function(e){e.exports=e=>{if(typeof e!=="string"){throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``)}if(/^[a-zA-Z]:\\/.test(e)){return false}return/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(e)}}};var r={};function __nccwpck_require__(t){var _=r[t];if(_!==undefined){return _.exports}var a=r[t]={exports:{}};var i=true;try{e[t](a,a.exports,__nccwpck_require__);i=false}finally{if(i)delete r[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(442);module.exports=t})();
@@ -0,0 +1 @@
1
+ {"name":"is-absolute-url","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"license":"MIT"}
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // MFImport.ts
22
+ // src/babelPlugins/awaitImport/MFImport.ts
23
23
  var MFImport_exports = {};
24
24
  __export(MFImport_exports, {
25
25
  default: () => MFImport_default
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // awaitImport.ts
22
+ // src/babelPlugins/awaitImport/awaitImport.ts
23
23
  var awaitImport_exports = {};
24
24
  __export(awaitImport_exports, {
25
25
  default: () => awaitImport_default
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // checkMatch.ts
22
+ // src/babelPlugins/awaitImport/checkMatch.ts
23
23
  var checkMatch_exports = {};
24
24
  __export(checkMatch_exports, {
25
25
  checkMatch: () => checkMatch,
@@ -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
- // getAliasedPath.ts
19
+ // src/babelPlugins/awaitImport/getAliasedPath.ts
20
20
  var getAliasedPath_exports = {};
21
21
  __export(getAliasedPath_exports, {
22
22
  getAliasedPath: () => getAliasedPath,
@@ -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
- // getRealPath.ts
19
+ // src/babelPlugins/awaitImport/getRealPath.ts
20
20
  var getRealPath_exports = {};
21
21
  __export(getRealPath_exports, {
22
22
  getRealPath: () => getRealPath
@@ -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
- // isExternals.ts
19
+ // src/babelPlugins/awaitImport/isExternals.ts
20
20
  var isExternals_exports = {};
21
21
  __export(isExternals_exports, {
22
22
  isExternal: () => isExternal,
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // parseSpecifiers.ts
22
+ // src/babelPlugins/awaitImport/parseSpecifiers.ts
23
23
  var parseSpecifiers_exports = {};
24
24
  __export(parseSpecifiers_exports, {
25
25
  parseSpecifiers: () => parseSpecifiers
package/dist/constants.js CHANGED
@@ -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
- // constants.ts
19
+ // src/constants.ts
20
20
  var constants_exports = {};
21
21
  __export(constants_exports, {
22
22
  DEFAULT_MF_NAME: () => DEFAULT_MF_NAME,
package/dist/dep/dep.js CHANGED
@@ -36,7 +36,7 @@ var __copyProps = (to, from, except, desc) => {
36
36
  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));
37
37
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
38
 
39
- // dep.ts
39
+ // src/dep/dep.ts
40
40
  var dep_exports = {};
41
41
  __export(dep_exports, {
42
42
  Dep: () => Dep
@@ -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
- // getCJSExports.ts
19
+ // src/dep/getCJSExports.ts
20
20
  var getCJSExports_exports = {};
21
21
  __export(getCJSExports_exports, {
22
22
  getCJSExports: () => getCJSExports
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // getExposeFromContent.ts
22
+ // src/dep/getExposeFromContent.ts
23
23
  var getExposeFromContent_exports = {};
24
24
  __export(getExposeFromContent_exports, {
25
25
  getExposeFromContent: () => getExposeFromContent
@@ -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
@@ -33,7 +33,7 @@ var __copyProps = (to, from, except, desc) => {
33
33
  };
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // depBuilder.ts
36
+ // src/depBuilder/depBuilder.ts
37
37
  var depBuilder_exports = {};
38
38
  __export(depBuilder_exports, {
39
39
  DepBuilder: () => DepBuilder
@@ -133,13 +133,15 @@ var DepBuilder = class {
133
133
  const content = await dep.buildExposeContent();
134
134
  (0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, dep.filePath), content, "utf-8");
135
135
  }
136
- (0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, "index.js"), '"\u{1F61B}"', "utf-8");
136
+ (0, import_fs.writeFileSync)((0, import_path.join)(tmpBase, "index.js"), `__webpack_public_path__ = document.currentScript.src + '/../';`, "utf-8");
137
137
  }
138
138
  getWebpackConfig(opts) {
139
139
  var _a, _b;
140
140
  const mfName = this.opts.mfsu.opts.mfName;
141
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");
142
+ depConfig.entry = {
143
+ [mfName]: (0, import_path.join)(this.opts.mfsu.opts.tmpBase, "index.js")
144
+ };
143
145
  depConfig.output.path = this.opts.mfsu.opts.tmpBase;
144
146
  depConfig.devtool = false;
145
147
  if ((_a = depConfig.output) == null ? void 0 : _a.library)
@@ -148,7 +150,12 @@ var DepBuilder = class {
148
150
  delete depConfig.output.libraryTarget;
149
151
  depConfig.optimization || (depConfig.optimization = {});
150
152
  depConfig.optimization.splitChunks = {
151
- chunks: "all",
153
+ chunks: (chunk) => {
154
+ const hasShared = chunk.getModules().some((m) => {
155
+ return m.type === "consume-shared-module" || m.type === "provide-module" || m.type === "provide-shared-module";
156
+ });
157
+ return !hasShared;
158
+ },
152
159
  maxInitialRequests: Infinity,
153
160
  minSize: 0,
154
161
  cacheGroups: {
@@ -179,7 +186,8 @@ var DepBuilder = class {
179
186
  },
180
187
  name: mfName,
181
188
  filename: import_constants.REMOTE_FILE_FULL,
182
- exposes
189
+ exposes,
190
+ shared: this.opts.mfsu.opts.shared || {}
183
191
  }));
184
192
  return depConfig;
185
193
  }
@@ -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.js CHANGED
@@ -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
- // depInfo.ts
19
+ // src/depInfo.ts
20
20
  var depInfo_exports = {};
21
21
  __export(depInfo_exports, {
22
22
  DepInfo: () => DepInfo
@@ -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
- // autoCssModules.ts
19
+ // src/esbuildHandlers/autoCssModules.ts
20
20
  var autoCssModules_exports = {};
21
21
  __export(autoCssModules_exports, {
22
22
  autoCssModulesHandler: () => autoCssModulesHandler
@@ -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.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
@@ -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;
package/dist/mfsu/mfsu.js CHANGED
@@ -33,7 +33,7 @@ var __copyProps = (to, from, except, desc) => {
33
33
  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));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // mfsu.ts
36
+ // src/mfsu/mfsu.ts
37
37
  var mfsu_exports = {};
38
38
  __export(mfsu_exports, {
39
39
  MFSU: () => MFSU
@@ -44,6 +44,7 @@ var import_utils = require("@umijs/utils");
44
44
  var import_assert = __toESM(require("assert"));
45
45
  var import_fs = require("fs");
46
46
  var import_path = require("path");
47
+ var import_is_absolute_url = __toESM(require("../../compiled/is-absolute-url"));
47
48
  var import_mrmime = require("../../compiled/mrmime");
48
49
  var import_webpack_virtual_modules = __toESM(require("../../compiled/webpack-virtual-modules"));
49
50
  var import_constants = require("../constants");
@@ -104,6 +105,10 @@ var MFSU = class {
104
105
  const entryObject = import_utils.lodash.isString(opts.config.entry) ? { default: [opts.config.entry] } : opts.config.entry;
105
106
  (0, import_assert.default)(import_utils.lodash.isPlainObject(entryObject), `webpack config 'entry' value must be a string or an object.`);
106
107
  for (const key of Object.keys(entryObject)) {
108
+ if (key === this.opts.remoteName) {
109
+ entry[key] = entryObject[key];
110
+ continue;
111
+ }
107
112
  const virtualPath = `./mfsu-virtual-entry/${key}.js`;
108
113
  const virtualContent = [];
109
114
  let index = 1;
@@ -154,6 +159,7 @@ var MFSU = class {
154
159
  new import_webpack_virtual_modules.default(virtualModules),
155
160
  new this.opts.implementor.container.ModuleFederationPlugin({
156
161
  name: "__",
162
+ shared: this.opts.shared || {},
157
163
  remotes: {
158
164
  [mfName]: this.opts.runtimePublicPath ? `
159
165
  promise new Promise(resolve => {
@@ -178,7 +184,7 @@ promise new Promise(resolve => {
178
184
  // inject this script with the src set to the versioned remoteEntry.js
179
185
  document.head.appendChild(script);
180
186
  })
181
- `.trimLeft() : `${mfName}@${publicPath}${import_constants.REMOTE_FILE_FULL}`
187
+ `.trimLeft() : `${mfName}@${this.opts.serverBase || ""}${publicPath}${import_constants.REMOTE_FILE_FULL}`
182
188
  }
183
189
  }),
184
190
  new import_buildDepPlugin.BuildDepPlugin(this.strategy.getBuildDepPlugConfig())
@@ -218,14 +224,15 @@ promise new Promise(resolve => {
218
224
  return [
219
225
  (req, res, next) => {
220
226
  const publicPath = this.publicPath;
221
- const isMF = req.path.startsWith(`${publicPath}${import_constants.MF_VA_PREFIX}`) || req.path.startsWith(`${publicPath}${import_constants.MF_DEP_PREFIX}`) || req.path.startsWith(`${publicPath}${import_constants.MF_STATIC_PREFIX}`);
227
+ const relativePublicPath = (0, import_is_absolute_url.default)(publicPath) ? new URL(publicPath).pathname : publicPath;
228
+ const isMF = req.path.startsWith(`${relativePublicPath}${import_constants.MF_VA_PREFIX}`) || req.path.startsWith(`${relativePublicPath}${import_constants.MF_DEP_PREFIX}`) || req.path.startsWith(`${relativePublicPath}${import_constants.MF_STATIC_PREFIX}`);
222
229
  if (isMF) {
223
230
  this.depBuilder.onBuildComplete(() => {
224
231
  if (!req.path.includes(import_constants.REMOTE_FILE)) {
225
232
  res.setHeader("cache-control", "max-age=31536000,immutable");
226
233
  }
227
234
  res.setHeader("content-type", (0, import_mrmime.lookup)((0, import_path.extname)(req.path)) || "text/plain");
228
- const relativePath = req.path.replace(new RegExp(`^${publicPath}`), "/");
235
+ const relativePath = req.path.replace(new RegExp(`^${relativePublicPath}`), "/");
229
236
  const content = (0, import_fs.readFileSync)((0, import_path.join)(this.opts.tmpBase, relativePath));
230
237
  res.send(content);
231
238
  });
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // strategyCompileTime.ts
22
+ // src/mfsu/strategyCompileTime.ts
23
23
  var strategyCompileTime_exports = {};
24
24
  __export(strategyCompileTime_exports, {
25
25
  StrategyCompileTime: () => StrategyCompileTime
@@ -82,6 +82,14 @@ var StrategyCompileTime = class {
82
82
  getAwaitImportCollectOpts() {
83
83
  const mfsuOpts = this.mfsu.opts;
84
84
  const mfsu = this.mfsu;
85
+ const userUnMatches = mfsuOpts.unMatchLibs || [];
86
+ const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
87
+ const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map((str) => new RegExp(`^${str}`));
88
+ const unMatches = [
89
+ ...userUnMatches,
90
+ ...sharedUnMatches,
91
+ ...remoteAliasUnMatches
92
+ ];
85
93
  return {
86
94
  onTransformDeps: () => {
87
95
  },
@@ -111,7 +119,7 @@ var StrategyCompileTime = class {
111
119
  });
112
120
  },
113
121
  exportAllMembers: mfsuOpts.exportAllMembers,
114
- unMatchLibs: mfsuOpts.unMatchLibs,
122
+ unMatchLibs: unMatches,
115
123
  remoteName: mfsuOpts.mfName,
116
124
  alias: mfsu.alias,
117
125
  externals: mfsu.externals
@@ -19,14 +19,14 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // strategyStaticAnalyze.ts
22
+ // src/mfsu/strategyStaticAnalyze.ts
23
23
  var strategyStaticAnalyze_exports = {};
24
24
  __export(strategyStaticAnalyze_exports, {
25
25
  StaticAnalyzeStrategy: () => StaticAnalyzeStrategy
26
26
  });
27
27
  module.exports = __toCommonJS(strategyStaticAnalyze_exports);
28
28
  var import_utils = require("@umijs/utils");
29
- var import_getAliasedPath = require("../babelPlugins/awaitImport/getAliasedPath");
29
+ var import_checkMatch = require("../babelPlugins/awaitImport/checkMatch");
30
30
  var import_MFImport = __toESM(require("../babelPlugins/awaitImport/MFImport"));
31
31
  var import_staticDepInfo = require("../staticDepInfo/staticDepInfo");
32
32
  var StaticAnalyzeStrategy = class {
@@ -58,18 +58,36 @@ var StaticAnalyzeStrategy = class {
58
58
  getMfImportOpts() {
59
59
  const mfsu = this.mfsu;
60
60
  const mfsuOpts = this.mfsu.opts;
61
+ const userUnMatches = mfsuOpts.unMatchLibs || [];
62
+ const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
63
+ const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map((str) => new RegExp(`^${str}`));
64
+ const unMatches = [
65
+ ...userUnMatches,
66
+ ...sharedUnMatches,
67
+ ...remoteAliasUnMatches
68
+ ];
61
69
  return {
62
70
  resolveImportSource: (source) => {
63
- const depMat = this.staticDepInfo.getDependencies();
64
- const r = (0, import_getAliasedPath.getAliasedPathWithLoopDetect)({
71
+ const match = (0, import_checkMatch.checkMatch)({
65
72
  value: source,
66
- alias: mfsu.alias
73
+ filename: "_.js",
74
+ opts: {
75
+ exportAllMembers: mfsuOpts.exportAllMembers,
76
+ unMatchLibs: unMatches,
77
+ remoteName: mfsuOpts.mfName,
78
+ alias: mfsu.alias,
79
+ externals: mfsu.externals
80
+ }
67
81
  });
68
- const m = depMat[r];
82
+ if (!match.isMatch) {
83
+ return source;
84
+ }
85
+ const depMat = this.staticDepInfo.getDependencies();
86
+ const m = depMat[match.value];
69
87
  if (m) {
70
88
  return m.replaceValue;
71
89
  }
72
- return r;
90
+ return match.value;
73
91
  },
74
92
  exportAllMembers: mfsuOpts.exportAllMembers,
75
93
  unMatchLibs: mfsuOpts.unMatchLibs,
@@ -33,7 +33,7 @@ var __copyProps = (to, from, except, desc) => {
33
33
  };
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // moduleGraph.ts
36
+ // src/moduleGraph.ts
37
37
  var moduleGraph_exports = {};
38
38
  __export(moduleGraph_exports, {
39
39
  ModuleGraph: () => ModuleGraph
@@ -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
- // importParser.ts
19
+ // src/staticDepInfo/importParser.ts
20
20
  var importParser_exports = {};
21
21
  __export(importParser_exports, {
22
22
  default: () => parse
@@ -19,7 +19,7 @@ var __copyProps = (to, from, except, desc) => {
19
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
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
21
 
22
- // babel-plugin-import.ts
22
+ // src/staticDepInfo/simulations/babel-plugin-import.ts
23
23
  var babel_plugin_import_exports = {};
24
24
  __export(babel_plugin_import_exports, {
25
25
  default: () => createHandle
@@ -96,11 +96,11 @@ function transCamel(_str, symbol) {
96
96
  return str.replace(/([A-Z])/g, ($1) => `${symbol}${$1.toLowerCase()}`);
97
97
  }
98
98
  function errorLogForSpaceImport(libraryName) {
99
- import_utils.logger.error(`"import * as ant from 'antd'" or "export * from '${libraryName}'" are not allowed in mfsu#version=v4`);
99
+ import_utils.logger.error(`"import * as ant from 'antd'" or "export * from '${libraryName}'" are not allowed in mfsu#strategy='eager'`);
100
100
  import_utils.logger.error(`solutions:`);
101
101
  import_utils.logger.error(` change to "import { Xxx } from '${libraryName}'" or`);
102
102
  import_utils.logger.error(` "export { Xxx } from '${libraryName}'" syntax`);
103
- import_utils.logger.error(` or use mfsu#version=v3 configuration`);
103
+ import_utils.logger.error(` or use mfsu#strategy='normal' configuration`);
104
104
  throw Error(`"import * as ant from 'antd'" not allowed in mfsu#version=4`);
105
105
  }
106
106
  // Annotate the CommonJS export names for ESM import in node:
@@ -36,7 +36,7 @@ var __copyProps = (to, from, except, desc) => {
36
36
  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));
37
37
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
38
 
39
- // staticDepInfo.ts
39
+ // src/staticDepInfo/staticDepInfo.ts
40
40
  var staticDepInfo_exports = {};
41
41
  __export(staticDepInfo_exports, {
42
42
  StaticDepInfo: () => StaticDepInfo
@@ -142,9 +142,18 @@ var StaticDepInfo = class {
142
142
  _getDependencies(bigCodeString, imports) {
143
143
  const start = Date.now();
144
144
  const cwd = this.mfsu.opts.cwd;
145
+ const mfsuOpts = this.mfsu.opts;
146
+ const userUnMatches = mfsuOpts.unMatchLibs || [];
147
+ const sharedUnMatches = Object.keys(mfsuOpts.shared || {});
148
+ const remoteAliasUnMatches = (mfsuOpts.remoteAliases || []).map((str) => new RegExp(`^${str}`));
149
+ const unMatches = [
150
+ ...userUnMatches,
151
+ ...sharedUnMatches,
152
+ ...remoteAliasUnMatches
153
+ ];
145
154
  const opts = {
146
155
  exportAllMembers: this.mfsu.opts.exportAllMembers,
147
- unMatchLibs: this.mfsu.opts.unMatchLibs,
156
+ unMatchLibs: unMatches,
148
157
  remoteName: this.mfsu.opts.mfName,
149
158
  alias: this.mfsu.alias,
150
159
  externals: this.mfsu.externals
package/dist/types.js CHANGED
@@ -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
- // types.ts
19
+ // src/types.ts
20
20
  var types_exports = {};
21
21
  __export(types_exports, {
22
22
  Mode: () => Mode
@@ -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
- // makeArray.ts
19
+ // src/utils/makeArray.ts
20
20
  var makeArray_exports = {};
21
21
  __export(makeArray_exports, {
22
22
  makeArray: () => makeArray
@@ -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
- // trimFileContent.ts
19
+ // src/utils/trimFileContent.ts
20
20
  var trimFileContent_exports = {};
21
21
  __export(trimFileContent_exports, {
22
22
  trimFileContent: () => trimFileContent
@@ -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
- // buildDepPlugin.ts
19
+ // src/webpackPlugins/buildDepPlugin.ts
20
20
  var buildDepPlugin_exports = {};
21
21
  __export(buildDepPlugin_exports, {
22
22
  BuildDepPlugin: () => BuildDepPlugin
@@ -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
- // depChunkIdPrefixPlugin.ts
19
+ // src/webpackPlugins/depChunkIdPrefixPlugin.ts
20
20
  var depChunkIdPrefixPlugin_exports = {};
21
21
  __export(depChunkIdPrefixPlugin_exports, {
22
22
  DepChunkIdPrefixPlugin: () => DepChunkIdPrefixPlugin
@@ -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
- // stripSourceMapUrlPlugin.ts
19
+ // src/webpackPlugins/stripSourceMapUrlPlugin.ts
20
20
  var stripSourceMapUrlPlugin_exports = {};
21
21
  __export(stripSourceMapUrlPlugin_exports, {
22
22
  StripSourceMapUrlPlugin: () => StripSourceMapUrlPlugin
@@ -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
- // writeCachePlugin.ts
19
+ // src/webpackPlugins/writeCachePlugin.ts
20
20
  var writeCachePlugin_exports = {};
21
21
  __export(writeCachePlugin_exports, {
22
22
  WriteCachePlugin: () => WriteCachePlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/mfsu",
3
- "version": "4.0.0-canary.20220727.1",
3
+ "version": "4.0.0-canary.20220729.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,13 +23,14 @@
23
23
  "test": "umi-scripts jest-turbo"
24
24
  },
25
25
  "dependencies": {
26
- "@umijs/bundler-esbuild": "4.0.0-canary.20220727.1",
27
- "@umijs/bundler-utils": "4.0.0-canary.20220727.1",
28
- "@umijs/utils": "4.0.0-canary.20220727.1",
26
+ "@umijs/bundler-esbuild": "4.0.0-canary.20220729.1",
27
+ "@umijs/bundler-utils": "4.0.0-canary.20220729.1",
28
+ "@umijs/utils": "4.0.0-canary.20220729.1",
29
29
  "enhanced-resolve": "5.9.3",
30
30
  "is-equal": "^1.6.4"
31
31
  },
32
32
  "devDependencies": {
33
+ "is-absolute-url": "^3.0.3",
33
34
  "mrmime": "1.0.0",
34
35
  "webpack": "5.72.1",
35
36
  "webpack-virtual-modules": "0.4.3"
@@ -42,6 +43,7 @@
42
43
  ],
43
44
  "compiledConfig": {
44
45
  "deps": [
46
+ "is-absolute-url",
45
47
  "mrmime",
46
48
  "webpack-virtual-modules"
47
49
  ],