@umijs/mfsu 4.0.0-beta.4 → 4.0.0-beta.8

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 (46) hide show
  1. package/compiled/webpack-virtual-modules/LICENSE +21 -0
  2. package/compiled/webpack-virtual-modules/index.js +1 -0
  3. package/compiled/webpack-virtual-modules/package.json +1 -0
  4. package/dist/babelPlugins/autoExport.d.ts.map +1 -0
  5. package/dist/babelPlugins/awaitImport/awaitImport.d.ts +5 -3
  6. package/dist/babelPlugins/awaitImport/awaitImport.d.ts.map +1 -0
  7. package/dist/babelPlugins/awaitImport/awaitImport.js +21 -89
  8. package/dist/babelPlugins/awaitImport/checkMatch.d.ts.map +1 -0
  9. package/dist/babelPlugins/awaitImport/getAliasedPath.d.ts.map +1 -0
  10. package/dist/babelPlugins/awaitImport/getRealPath.d.ts.map +1 -0
  11. package/dist/babelPlugins/awaitImport/isExternals.d.ts.map +1 -0
  12. package/dist/babelPlugins/awaitImport/parseSpecifiers.d.ts.map +1 -0
  13. package/dist/constants.d.ts.map +1 -0
  14. package/dist/dep/dep.d.ts +2 -1
  15. package/dist/dep/dep.d.ts.map +1 -0
  16. package/dist/dep/dep.js +26 -40
  17. package/dist/dep/getCJSExports.d.ts.map +1 -0
  18. package/dist/dep/getExposeFromContent.d.ts +1 -0
  19. package/dist/dep/getExposeFromContent.d.ts.map +1 -0
  20. package/dist/dep/getModuleExports.d.ts.map +1 -0
  21. package/dist/depBuilder/depBuilder.d.ts +10 -1
  22. package/dist/depBuilder/depBuilder.d.ts.map +1 -0
  23. package/dist/depBuilder/depBuilder.js +49 -6
  24. package/dist/depBuilder/getESBuildEntry.d.ts +5 -0
  25. package/dist/depBuilder/getESBuildEntry.d.ts.map +1 -0
  26. package/dist/depBuilder/getESBuildEntry.js +315 -0
  27. package/dist/depInfo.d.ts +1 -0
  28. package/dist/depInfo.d.ts.map +1 -0
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/mfsu.d.ts +2 -1
  32. package/dist/mfsu.d.ts.map +1 -0
  33. package/dist/mfsu.js +17 -20
  34. package/dist/moduleGraph.d.ts.map +1 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/utils/makeArray.d.ts.map +1 -0
  37. package/dist/utils/trimFileContent.d.ts.map +1 -0
  38. package/dist/webpackPlugins/buildDepPlugin.d.ts.map +1 -0
  39. package/dist/webpackPlugins/depChunkIdPrefixPlugin.d.ts.map +1 -0
  40. package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts +10 -0
  41. package/dist/webpackPlugins/stripSourceMapUrlPlugin.d.ts.map +1 -0
  42. package/dist/webpackPlugins/stripSourceMapUrlPlugin.js +28 -0
  43. package/dist/webpackPlugins/writeCachePlugin.d.ts.map +1 -0
  44. package/package.json +13 -6
  45. package/dist/dep/getFilePath.d.ts +0 -3
  46. package/dist/dep/getFilePath.js +0 -73
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 SysGears
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ (function(){"use strict";var e={636:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};const a=i(r(622));const s=r(570);let n=45e6;function checkActivation(e){if(!e._compiler){throw new Error("You must use this plugin only after creating webpack instance!")}}function getModulePath(e,t){return a.default.isAbsolute(e)?e:a.default.join(t.context,e)}function createWebpackData(e){return t=>{if(t._data){const r=t._currentLevel;const i=t._levels[r];return{result:e,level:i}}return[null,e]}}function getData(e,t){if(e._data instanceof Map){return e._data.get(t)}else if(e._data){return e.data[t]}else if(e.data instanceof Map){return e.data.get(t)}else{return e.data[t]}}function setData(e,t,r){const i=r(e);if(e._data instanceof Map){e._data.set(t,i)}else if(e._data){e.data[t]=i}else if(e.data instanceof Map){e.data.set(t,i)}else{e.data[t]=i}}function getStatStorage(e){if(e._statStorage){return e._statStorage}else if(e._statBackend){return e._statBackend}else{throw new Error("Couldn't find a stat storage")}}function getFileStorage(e){if(e._readFileStorage){return e._readFileStorage}else if(e._readFileBackend){return e._readFileBackend}else{throw new Error("Couldn't find a readFileStorage")}}function getReadDirBackend(e){if(e._readdirBackend){return e._readdirBackend}else if(e._readdirStorage){return e._readdirStorage}else{throw new Error("Couldn't find a readDirStorage from Webpack Internals")}}class VirtualModulesPlugin{constructor(e){this._compiler=null;this._watcher=null;this._staticModules=e||null}writeModule(e,t){if(!this._compiler){throw new Error(`Plugin has not been initialized`)}checkActivation(this);const r=t?t.length:0;const i=Date.now();const a=new Date(i);const o=new s.VirtualStats({dev:8675309,nlink:0,uid:1e3,gid:1e3,rdev:0,blksize:4096,ino:n++,mode:33188,size:r,blocks:Math.floor(r/4096),atime:a,mtime:a,ctime:a,birthtime:a});const l=getModulePath(e,this._compiler);if(process.env.WVM_DEBUG)console.log(this._compiler.name,"Write virtual module:",l,t);let c=this._watcher&&this._watcher.watchFileSystem;while(c&&c.wfs){c=c.wfs}let u=this._compiler.inputFileSystem;while(u&&u._inputFileSystem){u=u._inputFileSystem}u._writeVirtualFile(l,o,t);if(c&&(c.watcher.fileWatchers.size||c.watcher.fileWatchers.length)){const t=c.watcher.fileWatchers instanceof Map?Array.from(c.watcher.fileWatchers.values()):c.watcher.fileWatchers;for(const r of t){if(r.path===l){if(process.env.DEBUG)console.log(this._compiler.name,"Emit file change:",l,i);delete r.directoryWatcher._cachedTimeInfoEntries;r.directoryWatcher.setFileTime(e,i,false,false,null);r.emit("change",i,null)}}}}apply(e){this._compiler=e;const afterEnvironmentHook=()=>{let t=e.inputFileSystem;while(t&&t._inputFileSystem){t=t._inputFileSystem}if(!t._writeVirtualFile){const e=t.purge;t.purge=()=>{e.apply(t,[]);if(t._virtualFiles){Object.keys(t._virtualFiles).forEach((e=>{const r=t._virtualFiles[e];t._writeVirtualFile(e,r.stats,r.contents)}))}};t._writeVirtualFile=(e,r,i)=>{const o=getStatStorage(t);const l=getFileStorage(t);const c=getReadDirBackend(t);t._virtualFiles=t._virtualFiles||{};t._virtualFiles[e]={stats:r,contents:i};setData(o,e,createWebpackData(r));setData(l,e,createWebpackData(i));const u=e.split(/[\\/]/);let d=u.length-1;const _=u[0]?1:0;while(d>_){const e=u.slice(0,d).join(a.default.sep)||a.default.sep;try{t.readdirSync(e)}catch(t){const i=Date.now();const a=new s.VirtualStats({dev:8675309,nlink:0,uid:1e3,gid:1e3,rdev:0,blksize:4096,ino:n++,mode:16877,size:r.size,blocks:Math.floor(r.size/4096),atime:i,mtime:i,ctime:i,birthtime:i});setData(c,e,createWebpackData([]));setData(o,e,createWebpackData(a))}let i=getData(getReadDirBackend(t),e);i=i[1]||i.result;const l=u[d];if(i.indexOf(l)<0){const r=i.concat([l]).sort();setData(getReadDirBackend(t),e,createWebpackData(r))}else{break}d--}}}};const afterResolversHook=()=>{if(this._staticModules){for(const[e,t]of Object.entries(this._staticModules)){this.writeModule(e,t)}this._staticModules=null}};const watchRunHook=(t,r)=>{this._watcher=t.compiler||t;const i=e.inputFileSystem._virtualFiles;const a=e.fileTimestamps;if(i&&a&&typeof a.set==="function"){Object.keys(i).forEach((e=>{a.set(e,+i[e].stats.mtime)}))}r()};if(e.hooks){e.hooks.afterEnvironment.tap("VirtualModulesPlugin",afterEnvironmentHook);e.hooks.afterResolvers.tap("VirtualModulesPlugin",afterResolversHook);e.hooks.watchRun.tapAsync("VirtualModulesPlugin",watchRunHook)}else{e.plugin("after-environment",afterEnvironmentHook);e.plugin("after-resolvers",afterResolversHook);e.plugin("watch-run",watchRunHook)}}}e.exports=VirtualModulesPlugin},570:function(e,t,r){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.VirtualStats=void 0;const a=i(r(619));class VirtualStats{constructor(e){for(const t in e){if(!Object.prototype.hasOwnProperty.call(e,t)){continue}this[t]=e[t]}}_checkModeProperty(e){return(this.mode&a.default.S_IFMT)===e}isDirectory(){return this._checkModeProperty(a.default.S_IFDIR)}isFile(){return this._checkModeProperty(a.default.S_IFREG)}isBlockDevice(){return this._checkModeProperty(a.default.S_IFBLK)}isCharacterDevice(){return this._checkModeProperty(a.default.S_IFCHR)}isSymbolicLink(){return this._checkModeProperty(a.default.S_IFLNK)}isFIFO(){return this._checkModeProperty(a.default.S_IFIFO)}isSocket(){return this._checkModeProperty(a.default.S_IFSOCK)}}t.VirtualStats=VirtualStats},619:function(e){e.exports=require("constants")},622:function(e){e.exports=require("path")}};var t={};function __nccwpck_require__(r){var i=t[r];if(i!==undefined){return i.exports}var a=t[r]={exports:{}};var s=true;try{e[r].call(a.exports,a,a.exports,__nccwpck_require__);s=false}finally{if(s)delete t[r]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(636);module.exports=r})();
@@ -0,0 +1 @@
1
+ {"name":"webpack-virtual-modules","author":"SysGears INC","license":"MIT"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoExport.d.ts","sourceRoot":"","sources":["../../src/babelPlugins/autoExport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,0CAA0C,CAAC;AAClE,OAAO,KAAK,CAAC,MAAM,2CAA2C,CAAC;AAE/D,MAAM,CAAC,OAAO;;sBAGM,MAAM,QAAQ,CAAC,EAAE,OAAO,CAAC;;EA2C5C"}
@@ -18,8 +18,10 @@ export default function (): {
18
18
  opts: IOpts;
19
19
  }): void;
20
20
  };
21
- CallExpression(path: Babel.NodePath<t.CallExpression>, { opts }: {
22
- opts: IOpts;
23
- }): void;
21
+ CallExpression: {
22
+ exit(path: Babel.NodePath<t.CallExpression>, { opts }: {
23
+ opts: IOpts;
24
+ }): void;
25
+ };
24
26
  };
25
27
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awaitImport.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/awaitImport/awaitImport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,0CAA0C,CAAC;AAClE,OAAO,KAAK,CAAC,MAAM,2CAA2C,CAAC;AAG/D,MAAM,WAAW,KAAK;IACpB,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB;AAED,MAAM,CAAC,OAAO;;gBAME,GAAG;;;uBAaA,MAAM,QAAQ,CAAC,EAAE,OAAO,CAAC;sBAAoB,KAAK;;;;uBAwDrD,MAAM,QAAQ,CAAC,EAAE,cAAc,CAAC;sBACpB,KAAK;;;;EAuBhC"}
@@ -21,10 +21,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  const t = __importStar(require("@umijs/bundler-utils/compiled/babel/types"));
23
23
  const checkMatch_1 = require("./checkMatch");
24
- const parseSpecifiers_1 = require("./parseSpecifiers");
25
- function isCSS(val) {
26
- return /\.(css|less|sass|scss|stylus|styl)(\?.+?)?$/.test(val);
27
- }
28
24
  function default_1() {
29
25
  return {
30
26
  pre() {
@@ -46,9 +42,6 @@ function default_1() {
46
42
  visitor: {
47
43
  Program: {
48
44
  exit(path, { opts }) {
49
- var _a;
50
- const topDeclarations = [];
51
- const bottomDeclarations = [];
52
45
  let index = path.node.body.length - 1;
53
46
  while (index >= 0) {
54
47
  const node = path.node.body[index];
@@ -64,25 +57,8 @@ function default_1() {
64
57
  opts,
65
58
  path,
66
59
  });
67
- if (isMatch || isCSS(node.source.value)) {
68
- path.node.body.splice(index, 1);
69
- const { properties, namespaceIdentifier } = (0, parseSpecifiers_1.parseSpecifiers)(node.specifiers);
70
- const id = t.objectPattern(properties);
71
- const init = t.awaitExpression(t.callExpression(t.import(), [
72
- t.stringLiteral(isMatch ? replaceValue : node.source.value),
73
- ]));
74
- if (namespaceIdentifier) {
75
- topDeclarations.unshift(t.variableDeclaration('const', [
76
- t.variableDeclarator(namespaceIdentifier, init),
77
- properties.length &&
78
- t.variableDeclarator(id, namespaceIdentifier),
79
- ].filter(Boolean)));
80
- }
81
- else {
82
- topDeclarations.unshift(t.variableDeclaration('const', [
83
- t.variableDeclarator(id, init),
84
- ]));
85
- }
60
+ if (isMatch) {
61
+ node.source.value = replaceValue;
86
62
  }
87
63
  }
88
64
  // export * from 'x';
@@ -93,28 +69,9 @@ function default_1() {
93
69
  value: node.source.value,
94
70
  opts,
95
71
  path,
96
- isExportAll: true,
97
72
  });
98
73
  if (isMatch) {
99
- const members = ((_a = opts.exportAllMembers) === null || _a === void 0 ? void 0 : _a[node.source.value]) || [];
100
- if (members.length) {
101
- const id = t.identifier(`__all_exports_${node.source.value.replace(/([@\/\-])/g, '_')}`);
102
- const init = t.awaitExpression(t.callExpression(t.import(), [
103
- t.stringLiteral(replaceValue),
104
- ]));
105
- topDeclarations.unshift(t.variableDeclaration('const', [
106
- t.variableDeclarator(id, init),
107
- ]));
108
- // replace node with export const { a, b, c } = __all_exports
109
- // a, b, c was declared from opts.exportAllMembers
110
- path.node.body[index] = t.exportNamedDeclaration(t.variableDeclaration('const', [
111
- t.variableDeclarator(t.objectPattern(members.map((m) => t.objectProperty(t.identifier(m), t.identifier(m)))), id),
112
- ]));
113
- }
114
- // 有些 export * 只是为了类型
115
- else {
116
- path.node.body[index] = t.expressionStatement(t.numericLiteral(1));
117
- }
74
+ node.source.value = replaceValue;
118
75
  }
119
76
  }
120
77
  // export { x } from 'x';
@@ -127,56 +84,31 @@ function default_1() {
127
84
  path,
128
85
  });
129
86
  if (isMatch) {
130
- const { properties, defaultIdentifier } = (0, parseSpecifiers_1.parseSpecifiers)(node.specifiers);
131
- const id = t.objectPattern(properties);
132
- const init = t.awaitExpression(t.callExpression(t.import(), [t.stringLiteral(replaceValue)]));
133
- topDeclarations.unshift(t.variableDeclaration('const', [
134
- t.variableDeclarator(id, init),
135
- ]));
136
- node.source = null;
137
- node.specifiers = node.specifiers.filter((specifier) => {
138
- if (t.isExportSpecifier(specifier) &&
139
- t.isIdentifier(specifier.local) &&
140
- t.isIdentifier(specifier.exported)) {
141
- specifier.local = specifier.exported;
142
- }
143
- return !(t.isExportSpecifier(specifier) &&
144
- t.isIdentifier(specifier.exported) &&
145
- specifier.exported.name === 'default');
146
- });
147
- if (!node.specifiers.length) {
148
- path.node.body.splice(index, 1);
149
- }
150
- if (defaultIdentifier) {
151
- bottomDeclarations.push(t.exportDefaultDeclaration(t.identifier(defaultIdentifier)));
152
- }
87
+ node.source.value = replaceValue;
153
88
  }
154
89
  }
155
90
  index -= 1;
156
91
  }
157
- path.node.body = [
158
- ...topDeclarations,
159
- ...path.node.body,
160
- ...bottomDeclarations,
161
- ];
162
92
  },
163
93
  },
164
- CallExpression(path, { opts }) {
165
- const { node } = path;
166
- if (t.isImport(node.callee) &&
167
- node.arguments.length === 1 &&
168
- node.arguments[0].type === 'StringLiteral') {
169
- const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
170
- // @ts-ignore
171
- cache: this.cache,
172
- value: node.arguments[0].value,
173
- opts,
174
- path,
175
- });
176
- if (isMatch) {
177
- node.arguments[0] = t.stringLiteral(replaceValue);
94
+ CallExpression: {
95
+ exit(path, { opts }) {
96
+ const { node } = path;
97
+ if (t.isImport(node.callee) &&
98
+ node.arguments.length === 1 &&
99
+ node.arguments[0].type === 'StringLiteral') {
100
+ const { isMatch, replaceValue } = (0, checkMatch_1.checkMatch)({
101
+ // @ts-ignore
102
+ cache: this.cache,
103
+ value: node.arguments[0].value,
104
+ opts,
105
+ path,
106
+ });
107
+ if (isMatch) {
108
+ node.arguments[0] = t.stringLiteral(replaceValue);
109
+ }
178
110
  }
179
- }
111
+ },
180
112
  },
181
113
  },
182
114
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkMatch.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/awaitImport/checkMatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,0CAA0C,CAAC;AAIlE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAQ3C,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,WAAW,EACX,KAAK,EACL,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1B,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAoG7C;AAGD,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,UAQtE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAliasedPath.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/awaitImport/getAliasedPath.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B,sBAwBA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRealPath.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/awaitImport/getRealPath.ts"],"names":[],"mappings":"AAKA,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,iBAe9D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isExternals.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/awaitImport/isExternals.ts"],"names":[],"mappings":"AAAA,aAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC;AACnD,aAAK,UAAU,GAAG,SAAS,EAAE,GAAG,SAAS,CAAC;AAE1C,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,UAAU,CAAC;CACvB,WAQA;AAED,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB,WAYA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSpecifiers.d.ts","sourceRoot":"","sources":["../../../src/babelPlugins/awaitImport/parseSpecifiers.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,OAyBhD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,WAAW,CAAC;AACrC,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C,eAAO,MAAM,eAAe,OAAO,CAAC;AACpC,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,gBAAgB,QAAkC,CAAC"}
package/dist/dep/dep.d.ts CHANGED
@@ -14,7 +14,7 @@ export declare class Dep {
14
14
  mfsu: MFSU;
15
15
  });
16
16
  buildExposeContent(): Promise<string>;
17
- getRealFile(): any;
17
+ getRealFile(): Promise<string | null>;
18
18
  static buildDeps(opts: {
19
19
  deps: Record<string, {
20
20
  file: string;
@@ -24,3 +24,4 @@ export declare class Dep {
24
24
  mfsu: MFSU;
25
25
  }): Dep[];
26
26
  }
27
+ //# sourceMappingURL=dep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dep.d.ts","sourceRoot":"","sources":["../../src/dep/dep.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAoB/B,qBAAa,GAAG;IACP,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;gBACN,IAAI,EAAE;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,IAAI,CAAC;KACZ;IAUK,kBAAkB;IA8BlB,WAAW;IAUjB,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACxD,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,IAAI,CAAC;KACZ;CASF"}
package/dist/dep/dep.js CHANGED
@@ -1,23 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -33,13 +14,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
14
  Object.defineProperty(exports, "__esModule", { value: true });
34
15
  exports.Dep = void 0;
35
16
  const assert_1 = __importDefault(require("assert"));
17
+ const enhanced_resolve_1 = __importDefault(require("enhanced-resolve"));
36
18
  const fs_1 = require("fs");
37
- const path_1 = require("path");
38
- const process = __importStar(require("process"));
39
19
  const constants_1 = require("../constants");
40
20
  const trimFileContent_1 = require("../utils/trimFileContent");
41
21
  const getExposeFromContent_1 = require("./getExposeFromContent");
42
- const getFilePath_1 = require("./getFilePath");
22
+ const resolver = enhanced_resolve_1.default.create({
23
+ mainFields: ['module', 'browser', 'main'],
24
+ extensions: ['.js', '.json', '.mjs'],
25
+ // TODO: support exports
26
+ // tried to add exports, but it don't work with swr
27
+ exportsFields: [],
28
+ });
29
+ function resolve(context, path) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ return new Promise((resolve, reject) => {
32
+ resolver(context, path, (err, result) => err ? reject(err) : resolve(result));
33
+ });
34
+ });
35
+ }
43
36
  class Dep {
44
37
  constructor(opts) {
45
38
  this.file = opts.file;
@@ -68,7 +61,7 @@ export * from '${this.file}';
68
61
  `);
69
62
  }
70
63
  // none node natives
71
- const realFile = this.getRealFile();
64
+ const realFile = yield this.getRealFile();
72
65
  (0, assert_1.default)(realFile, `filePath not found of ${this.file}`);
73
66
  const content = (0, fs_1.readFileSync)(realFile, 'utf-8');
74
67
  return yield (0, getExposeFromContent_1.getExposeFromContent)({
@@ -79,23 +72,16 @@ export * from '${this.file}';
79
72
  });
80
73
  }
81
74
  getRealFile() {
82
- // Support config dep module resolver
83
- for (const resolver of this.mfsu.opts.resolvers || []) {
84
- const ret = resolver(this.file);
85
- if (ret)
86
- return ret;
87
- }
88
- const absFiles = (0, path_1.isAbsolute)(this.file)
89
- ? [this.file]
90
- : [this.cwd, this.cwd !== process.cwd() && process.cwd()]
91
- .filter(Boolean)
92
- .map((base) => (0, path_1.join)(base, 'node_modules', this.file));
93
- for (const path of absFiles) {
94
- const realFile = (0, getFilePath_1.getFilePath)({ path });
95
- if (realFile)
96
- return realFile;
97
- }
98
- return null;
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ try {
77
+ // don't need to handle alias here
78
+ // it's already handled by babel plugin
79
+ return yield resolve(this.cwd, this.file);
80
+ }
81
+ catch (e) {
82
+ return null;
83
+ }
84
+ });
99
85
  }
100
86
  static buildDeps(opts) {
101
87
  return Object.keys(opts.deps).map((file) => {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCJSExports.d.ts","sourceRoot":"","sources":["../../src/dep/getCJSExports.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,YAoE7D"}
@@ -4,3 +4,4 @@ export declare function getExposeFromContent(opts: {
4
4
  filePath: string;
5
5
  content: string;
6
6
  }): Promise<string>;
7
+ //# sourceMappingURL=getExposeFromContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getExposeFromContent.d.ts","sourceRoot":"","sources":["../../src/dep/getExposeFromContent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,mBAoEA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getModuleExports.d.ts","sourceRoot":"","sources":["../../src/dep/getModuleExports.ts"],"names":[],"mappings":"AAKA,wBAAsB,gBAAgB,CAAC,EACrC,OAAO,EACP,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;;;GA4BA"}
@@ -8,9 +8,17 @@ export declare class DepBuilder {
8
8
  completeFns: Function[];
9
9
  isBuilding: boolean;
10
10
  constructor(opts: IOpts);
11
- build(opts: {
11
+ buildWithWebpack(opts: {
12
+ onBuildComplete: Function;
12
13
  deps: Dep[];
13
14
  }): Promise<unknown>;
15
+ buildWithESBuild(opts: {
16
+ onBuildComplete: Function;
17
+ deps: Dep[];
18
+ }): Promise<void>;
19
+ build(opts: {
20
+ deps: Dep[];
21
+ }): Promise<void>;
14
22
  onBuildComplete(fn: Function): void;
15
23
  writeMFFiles(opts: {
16
24
  deps: Dep[];
@@ -20,3 +28,4 @@ export declare class DepBuilder {
20
28
  }): import("webpack").Configuration;
21
29
  }
22
30
  export {};
31
+ //# sourceMappingURL=depBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depBuilder.d.ts","sourceRoot":"","sources":["../../src/depBuilder/depBuilder.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAK/B,UAAU,KAAK;IACb,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,qBAAa,UAAU;IACd,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,QAAQ,EAAE,CAAM;IAC7B,UAAU,UAAS;gBACd,IAAI,EAAE,KAAK;IAIjB,gBAAgB,CAAC,IAAI,EAAE;QAAE,eAAe,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,GAAG,EAAE,CAAA;KAAE;IAwBjE,gBAAgB,CAAC,IAAI,EAAE;QAAE,eAAe,EAAE,QAAQ,CAAC;QAAC,IAAI,EAAE,GAAG,EAAE,CAAA;KAAE;IAwBjE,KAAK,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,GAAG,EAAE,CAAA;KAAE;IAkBjC,eAAe,CAAC,EAAE,EAAE,QAAQ;IAQtB,YAAY,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,GAAG,EAAE,CAAA;KAAE;IAaxC,gBAAgB,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,GAAG,EAAE,CAAA;KAAE;CA0DvC"}
@@ -10,28 +10,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.DepBuilder = void 0;
13
+ const bundler_esbuild_1 = require("@umijs/bundler-esbuild");
13
14
  const utils_1 = require("@umijs/utils");
14
15
  const fs_1 = require("fs");
15
16
  const path_1 = require("path");
16
17
  const constants_1 = require("../constants");
17
18
  const depChunkIdPrefixPlugin_1 = require("../webpackPlugins/depChunkIdPrefixPlugin");
19
+ const stripSourceMapUrlPlugin_1 = require("../webpackPlugins/stripSourceMapUrlPlugin");
20
+ const getESBuildEntry_1 = require("./getESBuildEntry");
18
21
  class DepBuilder {
19
22
  constructor(opts) {
20
23
  this.completeFns = [];
21
24
  this.isBuilding = false;
22
25
  this.opts = opts;
23
26
  }
24
- build(opts) {
27
+ buildWithWebpack(opts) {
25
28
  return __awaiter(this, void 0, void 0, function* () {
26
- this.isBuilding = true;
27
- yield this.writeMFFiles({ deps: opts.deps });
28
29
  const config = this.getWebpackConfig({ deps: opts.deps });
29
30
  return new Promise((resolve, reject) => {
30
31
  const compiler = this.opts.mfsu.opts.implementor(config);
31
32
  compiler.run((err, stats) => {
32
- this.isBuilding = false;
33
- this.completeFns.forEach((fn) => fn());
34
- this.completeFns = [];
33
+ opts.onBuildComplete();
35
34
  if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
36
35
  if (err) {
37
36
  reject(err);
@@ -50,6 +49,47 @@ class DepBuilder {
50
49
  });
51
50
  });
52
51
  }
52
+ // TODO: support watch and rebuild
53
+ buildWithESBuild(opts) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const entryContent = (0, getESBuildEntry_1.getESBuildEntry)({ deps: opts.deps });
56
+ const ENTRY_FILE = 'esbuild-entry.js';
57
+ const tmpDir = this.opts.mfsu.opts.tmpBase;
58
+ const entryPath = (0, path_1.join)(tmpDir, ENTRY_FILE);
59
+ (0, fs_1.writeFileSync)(entryPath, entryContent, 'utf-8');
60
+ const date = new Date().getTime();
61
+ yield (0, bundler_esbuild_1.build)({
62
+ cwd: this.opts.mfsu.opts.cwd,
63
+ entry: {
64
+ [`${constants_1.MF_VA_PREFIX}remoteEntry`]: entryPath,
65
+ },
66
+ config: {
67
+ outputPath: tmpDir,
68
+ alias: this.opts.mfsu.alias,
69
+ externals: this.opts.mfsu.externals,
70
+ },
71
+ });
72
+ utils_1.logger.event(`[mfsu] compiled with esbuild successfully in ${+new Date() - date} ms`);
73
+ opts.onBuildComplete();
74
+ });
75
+ }
76
+ build(opts) {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ this.isBuilding = true;
79
+ yield this.writeMFFiles({ deps: opts.deps });
80
+ const newOpts = Object.assign(Object.assign({}, opts), { onBuildComplete: () => {
81
+ this.isBuilding = false;
82
+ this.completeFns.forEach((fn) => fn());
83
+ this.completeFns = [];
84
+ } });
85
+ if (this.opts.mfsu.opts.buildDepWithESBuild) {
86
+ yield this.buildWithESBuild(newOpts);
87
+ }
88
+ else {
89
+ yield this.buildWithWebpack(newOpts);
90
+ }
91
+ });
92
+ }
53
93
  onBuildComplete(fn) {
54
94
  if (this.isBuilding) {
55
95
  this.completeFns.push(fn);
@@ -103,6 +143,9 @@ class DepBuilder {
103
143
  };
104
144
  depConfig.plugins = depConfig.plugins || [];
105
145
  depConfig.plugins.push(new depChunkIdPrefixPlugin_1.DepChunkIdPrefixPlugin());
146
+ depConfig.plugins.push(new stripSourceMapUrlPlugin_1.StripSourceMapUrlPlugin({
147
+ webpack: this.opts.mfsu.opts.implementor,
148
+ }));
106
149
  const exposes = opts.deps.reduce((memo, dep) => {
107
150
  memo[`./${dep.shortFile}`] = (0, path_1.join)(this.opts.mfsu.opts.tmpBase, dep.filePath);
108
151
  return memo;
@@ -0,0 +1,5 @@
1
+ import { Dep } from '../dep/dep';
2
+ export declare function getESBuildEntry(opts: {
3
+ deps: Dep[];
4
+ }): string;
5
+ //# sourceMappingURL=getESBuildEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getESBuildEntry.d.ts","sourceRoot":"","sources":["../../src/depBuilder/getESBuildEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,wBAAgB,eAAe,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,UAuSpD"}
@@ -0,0 +1,315 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getESBuildEntry = void 0;
4
+ const constants_1 = require("../constants");
5
+ function getESBuildEntry(opts) {
6
+ return `
7
+ (function() {
8
+ /******/ "use strict";
9
+ /******/ var __webpack_modules__ = ({});
10
+ /************************************************************************/
11
+ /******/ // The module cache
12
+ /******/ var __webpack_module_cache__ = {};
13
+ /******/
14
+ /******/ // The require function
15
+ /******/ function __webpack_require__(moduleId) {
16
+ /******/ // Check if module is in cache
17
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
18
+ /******/ if (cachedModule !== undefined) {
19
+ /******/ return cachedModule.exports;
20
+ /******/ }
21
+ /******/ // Create a new module (and put it into the cache)
22
+ /******/ var module = __webpack_module_cache__[moduleId] = {
23
+ /******/ id: moduleId,
24
+ /******/ loaded: false,
25
+ /******/ exports: {}
26
+ /******/ };
27
+ /******/
28
+ /******/ // Execute the module function
29
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
30
+ /******/
31
+ /******/ // Flag the module as loaded
32
+ /******/ module.loaded = true;
33
+ /******/
34
+ /******/ // Return the exports of the module
35
+ /******/ return module.exports;
36
+ /******/ }
37
+ /******/
38
+ /******/ // expose the modules object (__webpack_modules__)
39
+ /******/ __webpack_require__.m = __webpack_modules__;
40
+ /******/
41
+ /************************************************************************/
42
+ /******/ /* webpack/runtime/compat get default export */
43
+ /******/ !function() {
44
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
45
+ /******/ __webpack_require__.n = function(module) {
46
+ /******/ var getter = module && module.__esModule ?
47
+ /******/ function() { return module['default']; } :
48
+ /******/ function() { return module; };
49
+ /******/ __webpack_require__.d(getter, { a: getter });
50
+ /******/ return getter;
51
+ /******/ };
52
+ /******/ }();
53
+ /******/
54
+ /******/ /* webpack/runtime/define property getters */
55
+ /******/ !function() {
56
+ /******/ // define getter functions for harmony exports
57
+ /******/ __webpack_require__.d = function(exports, definition) {
58
+ /******/ for(var key in definition) {
59
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
60
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
61
+ /******/ }
62
+ /******/ }
63
+ /******/ };
64
+ /******/ }();
65
+ /******/
66
+ /******/ /* webpack/runtime/ensure chunk */
67
+ /******/ !function() {
68
+ /******/ __webpack_require__.f = {};
69
+ /******/ // This file contains only the entry chunk.
70
+ /******/ // The chunk loading function for additional chunks
71
+ /******/ __webpack_require__.e = function(chunkId) {
72
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce(function(promises, key) {
73
+ /******/ __webpack_require__.f[key](chunkId, promises);
74
+ /******/ return promises;
75
+ /******/ }, []));
76
+ /******/ };
77
+ /******/ }();
78
+ /******/
79
+ /******/ /* webpack/runtime/get javascript chunk filename */
80
+ /******/ !function() {
81
+ /******/ // This function allow to reference async chunks
82
+ /******/ __webpack_require__.u = function(chunkId) {
83
+ /******/ // return url for filenames based on template
84
+ /******/ return "" + "mf-dep____vendor" + "." + "8b5e340b" + ".js";
85
+ /******/ };
86
+ /******/ }();
87
+ /******/
88
+ /******/ /* webpack/runtime/get mini-css chunk filename */
89
+ /******/ !function() {
90
+ /******/ // This function allow to reference all chunks
91
+ /******/ __webpack_require__.miniCssF = function(chunkId) {
92
+ /******/ // return url for filenames based on template
93
+ /******/ return undefined;
94
+ /******/ };
95
+ /******/ }();
96
+ /******/
97
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
98
+ /******/ !function() {
99
+ /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
100
+ /******/ }();
101
+ /******/
102
+ /******/ /* webpack/runtime/load script */
103
+ /******/ !function() {
104
+ /******/ var inProgress = {};
105
+ /******/ // data-webpack is not used as build has no uniqueName
106
+ /******/ // loadScript function to load a script via script tag
107
+ /******/ __webpack_require__.l = function(url, done, key, chunkId) {
108
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
109
+ /******/ var script, needAttach;
110
+ /******/ if(key !== undefined) {
111
+ /******/ var scripts = document.getElementsByTagName("script");
112
+ /******/ for(var i = 0; i < scripts.length; i++) {
113
+ /******/ var s = scripts[i];
114
+ /******/ if(s.getAttribute("src") == url) { script = s; break; }
115
+ /******/ }
116
+ /******/ }
117
+ /******/ if(!script) {
118
+ /******/ needAttach = true;
119
+ /******/ script = document.createElement('script');
120
+ /******/
121
+ /******/ script.charset = 'utf-8';
122
+ /******/ script.timeout = 120;
123
+ /******/ if (__webpack_require__.nc) {
124
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
125
+ /******/ }
126
+ /******/
127
+ /******/ script.src = url;
128
+ /******/ }
129
+ /******/ inProgress[url] = [done];
130
+ /******/ var onScriptComplete = function(prev, event) {
131
+ /******/ // avoid mem leaks in IE.
132
+ /******/ script.onerror = script.onload = null;
133
+ /******/ clearTimeout(timeout);
134
+ /******/ var doneFns = inProgress[url];
135
+ /******/ delete inProgress[url];
136
+ /******/ script.parentNode && script.parentNode.removeChild(script);
137
+ /******/ doneFns && doneFns.forEach(function(fn) { return fn(event); });
138
+ /******/ if(prev) return prev(event);
139
+ /******/ }
140
+ /******/ ;
141
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
142
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
143
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
144
+ /******/ needAttach && document.head.appendChild(script);
145
+ /******/ };
146
+ /******/ }();
147
+ /******/
148
+ /******/ /* webpack/runtime/make namespace object */
149
+ /******/ !function() {
150
+ /******/ // define __esModule on exports
151
+ /******/ __webpack_require__.r = function(exports) {
152
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
153
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
154
+ /******/ }
155
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
156
+ /******/ };
157
+ /******/ }();
158
+ /******/
159
+ /******/ /* webpack/runtime/node module decorator */
160
+ /******/ !function() {
161
+ /******/ __webpack_require__.nmd = function(module) {
162
+ /******/ module.paths = [];
163
+ /******/ if (!module.children) module.children = [];
164
+ /******/ return module;
165
+ /******/ };
166
+ /******/ }();
167
+ /******/
168
+ /******/ /* webpack/runtime/publicPath */
169
+ /******/ !function() {
170
+ /******/ __webpack_require__.p = "/";
171
+ /******/ }();
172
+ /******/
173
+ /******/ /* webpack/runtime/jsonp chunk loading */
174
+ /******/ !function() {
175
+ /******/ // no baseURI
176
+ /******/
177
+ /******/ // object to store loaded and loading chunks
178
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
179
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
180
+ /******/ var installedChunks = {
181
+ /******/ "mf-dep_mf": 0
182
+ /******/ };
183
+ /******/
184
+ /******/ __webpack_require__.f.j = function(chunkId, promises) {
185
+ /******/ // JSONP chunk loading for javascript
186
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
187
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
188
+ /******/
189
+ /******/ // a Promise means "currently loading".
190
+ /******/ if(installedChunkData) {
191
+ /******/ promises.push(installedChunkData[2]);
192
+ /******/ } else {
193
+ /******/ if(true) { // all chunks have JS
194
+ /******/ // setup Promise in chunk cache
195
+ /******/ var promise = new Promise(function(resolve, reject) { installedChunkData = installedChunks[chunkId] = [resolve, reject]; });
196
+ /******/ promises.push(installedChunkData[2] = promise);
197
+ /******/
198
+ /******/ // start chunk loading
199
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
200
+ /******/ // create error before stack unwound to get useful stacktrace later
201
+ /******/ var error = new Error();
202
+ /******/ var loadingEnded = function(event) {
203
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
204
+ /******/ installedChunkData = installedChunks[chunkId];
205
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
206
+ /******/ if(installedChunkData) {
207
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
208
+ /******/ var realSrc = event && event.target && event.target.src;
209
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';
210
+ /******/ error.name = 'ChunkLoadError';
211
+ /******/ error.type = errorType;
212
+ /******/ error.request = realSrc;
213
+ /******/ installedChunkData[1](error);
214
+ /******/ }
215
+ /******/ }
216
+ /******/ };
217
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
218
+ /******/ } else installedChunks[chunkId] = 0;
219
+ /******/ }
220
+ /******/ }
221
+ /******/ };
222
+ /******/
223
+ /******/ // no prefetching
224
+ /******/
225
+ /******/ // no preloaded
226
+ /******/
227
+ /******/ // no HMR
228
+ /******/
229
+ /******/ // no HMR manifest
230
+ /******/
231
+ /******/ // no on chunks loaded
232
+ /******/
233
+ /******/ // install a JSONP callback for chunk loading
234
+ /******/ var webpackJsonpCallback = function(parentChunkLoadingFunction, data) {
235
+ /******/ var chunkIds = data[0];
236
+ /******/ var moreModules = data[1];
237
+ /******/ var runtime = data[2];
238
+ /******/ // add "moreModules" to the modules object,
239
+ /******/ // then flag all "chunkIds" as loaded and fire callback
240
+ /******/ var moduleId, chunkId, i = 0;
241
+ /******/ if(chunkIds.some(function(id) { return installedChunks[id] !== 0; })) {
242
+ /******/ for(moduleId in moreModules) {
243
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
244
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
245
+ /******/ }
246
+ /******/ }
247
+ /******/ if(runtime) var result = runtime(__webpack_require__);
248
+ /******/ }
249
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
250
+ /******/ for(;i < chunkIds.length; i++) {
251
+ /******/ chunkId = chunkIds[i];
252
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
253
+ /******/ installedChunks[chunkId][0]();
254
+ /******/ }
255
+ /******/ installedChunks[chunkIds[i]] = 0;
256
+ /******/ }
257
+ /******/
258
+ /******/ }
259
+ /******/
260
+ /******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || [];
261
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
262
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
263
+ /******/ }();
264
+ /******/
265
+ /************************************************************************/
266
+ var __webpack_exports__ = {};
267
+ (function() {
268
+ var exports = __webpack_exports__;
269
+ var moduleMap = {
270
+ ${opts.deps.map(getDepModuleStr).join(',\n')}
271
+ };
272
+ var get = function(module, getScope) {
273
+ __webpack_require__.R = getScope;
274
+ getScope = (
275
+ __webpack_require__.o(moduleMap, module)
276
+ ? moduleMap[module]()
277
+ : Promise.resolve().then(function() {
278
+ throw new Error('Module "' + module + '" does not exist in container.');
279
+ })
280
+ );
281
+ __webpack_require__.R = undefined;
282
+ return getScope;
283
+ };
284
+ var init = function(shareScope, initScope) {
285
+ if (!__webpack_require__.S) return;
286
+ var oldScope = __webpack_require__.S["default"];
287
+ var name = "default"
288
+ if(oldScope && oldScope !== shareScope) throw new Error("Container initialization failed as it has already been initialized with a different share scope");
289
+ __webpack_require__.S[name] = shareScope;
290
+ return __webpack_require__.I(name, initScope);
291
+ };
292
+ __webpack_require__.d(exports, {
293
+ get: function() { return get; },
294
+ init: function() { return init; }
295
+ });
296
+ self.mf = __webpack_exports__;
297
+ })();
298
+ })();
299
+ `;
300
+ }
301
+ exports.getESBuildEntry = getESBuildEntry;
302
+ function normalizeFile(file) {
303
+ return file.replace(/\//g, '_');
304
+ }
305
+ function getDepModuleStr(dep) {
306
+ return `
307
+ "./${dep.file}": function() {
308
+ return new Promise(resolve => {
309
+ import('./${constants_1.MF_VA_PREFIX}${normalizeFile(dep.file)}.js').then(module => {
310
+ resolve(() => module);
311
+ });
312
+ })
313
+ }
314
+ `.trim();
315
+ }
package/dist/depInfo.d.ts CHANGED
@@ -15,3 +15,4 @@ export declare class DepInfo {
15
15
  writeCache(): void;
16
16
  }
17
17
  export {};
18
+ //# sourceMappingURL=depInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depInfo.d.ts","sourceRoot":"","sources":["../src/depInfo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,UAAU,KAAK;IACb,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,IAAI,CAAQ;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,WAAW,CAAqB;IAC7C,eAAe,EAAE,MAAM,CAAM;gBACxB,IAAI,EAAE,KAAK;IAKvB,WAAW;IAiBX,QAAQ;IAKR,SAAS;IAUT,UAAU;CAeX"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './constants';
2
2
  export * from './mfsu';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC"}
package/dist/mfsu.d.ts CHANGED
@@ -14,8 +14,8 @@ interface IOpts {
14
14
  mode?: Mode;
15
15
  tmpBase?: string;
16
16
  unMatchLibs?: string[];
17
- resolvers?: Function[];
18
17
  implementor: typeof webpack;
18
+ buildDepWithESBuild?: boolean;
19
19
  }
20
20
  export declare class MFSU {
21
21
  opts: IOpts;
@@ -52,3 +52,4 @@ export declare class MFSU {
52
52
  })[])[];
53
53
  }
54
54
  export {};
55
+ //# sourceMappingURL=mfsu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mfsu.d.ts","sourceRoot":"","sources":["../src/mfsu.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAG/D,OAAO,OAAO,EAAE,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIjD,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,WAAW,MAAM,wCAAwC,CAAC;AAYjE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAK/B,UAAU,KAAK;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5C,kBAAkB,CAAC,EAAE,QAAQ,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,OAAO,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,qBAAa,IAAI;IACR,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IACnC,SAAS,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAM;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,aAAa,GAAG,IAAI,CAAQ;gBAClC,IAAI,EAAE,KAAK;IAYvB,gBAAgB,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,aAAa,CAAC;QAAC,SAAS,EAAE,aAAa,CAAA;KAAE;IAyDpE,SAAS;IAaf,cAAc,WAEJ,OAAO,OAAO,QAAQ,QAAQ,YAAY;IAgCpD,eAAe;;;kBAWC,MAAM;kBACN;gBACJ,SAAS,EAAE,IAAI;oBAAE,WAAW,EAAE,MAAM,CAAA;iBAAE,CAAC,CAAC;gBACxC,OAAO,EAAE,IAAI;oBAAE,WAAW,EAAE,MAAM,CAAA;iBAAE,CAAC,CAAC;aACvC;;;;;;;;CA4BZ"}
package/dist/mfsu.js CHANGED
@@ -1,23 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,8 +16,9 @@ exports.MFSU = void 0;
35
16
  const utils_1 = require("@umijs/utils");
36
17
  const fs_1 = require("fs");
37
18
  const path_1 = require("path");
38
- const process = __importStar(require("process"));
39
19
  const mrmime_1 = require("../compiled/mrmime");
20
+ // @ts-ignore
21
+ const webpack_virtual_modules_1 = __importDefault(require("../compiled/webpack-virtual-modules"));
40
22
  const autoExport_1 = __importDefault(require("./babelPlugins/autoExport"));
41
23
  const awaitImport_1 = __importDefault(require("./babelPlugins/awaitImport/awaitImport"));
42
24
  const getRealPath_1 = require("./babelPlugins/awaitImport/getRealPath");
@@ -72,8 +54,23 @@ class MFSU {
72
54
  // set alias and externals with reference for babel plugin
73
55
  Object.assign(this.alias, ((_a = opts.config.resolve) === null || _a === void 0 ? void 0 : _a.alias) || {});
74
56
  this.externals.push(...(0, makeArray_1.makeArray)(opts.config.externals || []));
57
+ // entry
58
+ const entry = {};
59
+ const virtualModules = {};
60
+ Object.keys(opts.config.entry).forEach((key) => {
61
+ const virtualPath = `./mfsu-virtual-entry/${key}.js`;
62
+ virtualModules[virtualPath] =
63
+ // @ts-ignore
64
+ opts.config
65
+ .entry[key].map((entry) => `await import('${entry}')`)
66
+ .join('\n') + `\nexport default 1;`;
67
+ entry[key] = virtualPath;
68
+ });
69
+ opts.config.entry = entry;
70
+ // plugins
75
71
  opts.config.plugins = opts.config.plugins || [];
76
72
  opts.config.plugins.push(...[
73
+ new webpack_virtual_modules_1.default(virtualModules),
77
74
  new this.opts.implementor.container.ModuleFederationPlugin({
78
75
  name: '__',
79
76
  remotes: {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moduleGraph.d.ts","sourceRoot":"","sources":["../src/moduleGraph.ts"],"names":[],"mappings":"AAEA,cAAM,UAAU;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,kBAAyB;IAClC,eAAe,kBAAyB;IACxC,YAAY,EAAE,OAAO,CAAS;IAC9B,MAAM,EAAE,OAAO,CAAS;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAQ;gBAClB,IAAI,EAAE,MAAM;CAGzB;AAED,UAAU,IAAI;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IACtB,aAAa,0BAAiC;IAC9C,YAAY,0BAAiC;IAC7C,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAM;IAC3E,WAAW,kBAAyB;;IAGpC,OAAO,CAAC,IAAI,EAAE;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,WAAW,EAAE,GAAG,CAAC;QACjB,UAAU,EAAE,GAAG,CAAC;QAChB,kBAAkB,EAAE,GAAG,CAAC;KACzB;IAiCD,MAAM;;;2BAE+C,MAAM,EAAE;;;qBACf,MAAM,GAAG,IAAI;;;;;;;IAwB3D,YAAY;IAIZ,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC;cAEd,MAAM;iBAAW,MAAM;;IAOlD,UAAU,CAAC,GAAG,EAAE,UAAU;;;;IAO1B,aAAa;IAKb,YAAY,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,EAAE,CAAA;KAAE;IAuBjD,YAAY,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,IAAI,EAAE,CAAA;KAAE;IA8BpD,OAAO,CAAC,IAAI,EAAE;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,OAAO,CAAC;QACtB,QAAQ,EAAE,UAAU,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACzB;IAoBD,UAAU,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,UAAU,CAAC;QAAC,QAAQ,EAAE,UAAU,CAAA;KAAE;CAiB3D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,IAAI;IACd,WAAW,gBAAgB;IAC3B,UAAU,eAAe;CAC1B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeArray.d.ts","sourceRoot":"","sources":["../../src/utils/makeArray.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,SAElC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trimFileContent.d.ts","sourceRoot":"","sources":["../../src/utils/trimFileContent.ts"],"names":[],"mappings":"AAAA,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,UAE9C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildDepPlugin.d.ts","sourceRoot":"","sources":["../../src/webpackPlugins/buildDepPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAS,MAAM,SAAS,CAAC;AAE/C,UAAU,KAAK;IACb,aAAa,EAAE,QAAQ,CAAC;CACzB;AAID,qBAAa,cAAc;IACzB,OAAO,CAAC,IAAI,CAAQ;gBACR,IAAI,EAAE,KAAK;IAGvB,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAOhC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"depChunkIdPrefixPlugin.d.ts","sourceRoot":"","sources":["../../src/webpackPlugins/depChunkIdPrefixPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKnC,qBAAa,sBAAsB;;IAEjC,KAAK,CAAC,QAAQ,EAAE,QAAQ;CAUzB"}
@@ -0,0 +1,10 @@
1
+ import type { Compiler } from 'webpack';
2
+ interface IOpts {
3
+ webpack: any;
4
+ }
5
+ export declare class StripSourceMapUrlPlugin {
6
+ opts: IOpts;
7
+ constructor(opts: IOpts);
8
+ apply(compiler: Compiler): void;
9
+ }
10
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stripSourceMapUrlPlugin.d.ts","sourceRoot":"","sources":["../../src/webpackPlugins/stripSourceMapUrlPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,UAAU,KAAK;IACb,OAAO,EAAE,GAAG,CAAC;CACd;AAED,qBAAa,uBAAuB;IAClC,IAAI,EAAE,KAAK,CAAC;gBACA,IAAI,EAAE,KAAK;IAIvB,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAyBhC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StripSourceMapUrlPlugin = void 0;
4
+ class StripSourceMapUrlPlugin {
5
+ constructor(opts) {
6
+ this.opts = opts;
7
+ }
8
+ apply(compiler) {
9
+ compiler.hooks.compilation.tap('StripSourceMapUrlPlugin', (compilation) => {
10
+ compilation.hooks.processAssets.tap({
11
+ name: 'StripSourceMapUrlPlugin',
12
+ stage: this.opts.webpack.Compilation.PROCESS_ASSETS_STAGE_DERIVE,
13
+ }, (assets) => {
14
+ Object.keys(assets)
15
+ .filter((filename) => /\.js$/.test(filename))
16
+ .forEach((filename) => {
17
+ const asset = assets[filename];
18
+ const source = asset
19
+ .source()
20
+ .toString()
21
+ .replace(/# sourceMappingURL=(.+?\.map)/g, '# $1');
22
+ compilation.updateAsset(filename, new this.opts.webpack.sources.RawSource(source));
23
+ });
24
+ });
25
+ });
26
+ }
27
+ }
28
+ exports.StripSourceMapUrlPlugin = StripSourceMapUrlPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeCachePlugin.d.ts","sourceRoot":"","sources":["../../src/webpackPlugins/writeCachePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,UAAU,KAAK;IACb,YAAY,EAAE,QAAQ,CAAC;CACxB;AAID,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,IAAI,CAAQ;gBACR,IAAI,EAAE,KAAK;IAGvB,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAQhC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/mfsu",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.8",
4
4
  "description": "@umijs/mfsu",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,20 +27,27 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@umijs/bundler-utils": "4.0.0-beta.4",
31
- "@umijs/utils": "4.0.0-beta.4"
30
+ "@umijs/bundler-esbuild": "4.0.0-beta.8",
31
+ "@umijs/bundler-utils": "4.0.0-beta.8",
32
+ "@umijs/utils": "4.0.0-beta.8"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/express": "4.17.13",
36
+ "enhanced-resolve": "5.8.3",
35
37
  "mrmime": "1.0.0",
36
- "webpack": "5.61.0"
38
+ "webpack": "5.61.0",
39
+ "webpack-virtual-modules": "0.4.3"
37
40
  },
38
41
  "compiledConfig": {
39
42
  "deps": [
40
- "mrmime"
43
+ "mrmime",
44
+ "webpack-virtual-modules"
41
45
  ],
42
46
  "externals": {
43
47
  "mrmime": "$$LOCAL"
44
- }
48
+ },
49
+ "excludeDtsDeps": [
50
+ "webpack-virtual-modules"
51
+ ]
45
52
  }
46
53
  }
@@ -1,3 +0,0 @@
1
- export declare function getFilePath({ path }: {
2
- path: string;
3
- }): string | null;
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFilePath = void 0;
4
- const utils_1 = require("@umijs/utils");
5
- const fs_1 = require("fs");
6
- const path_1 = require("path");
7
- // similar with resolve.extensions in webpack config
8
- const EXT_NAMES = ['.ts', '.tsx', '.jsx', '.mjs', '.js'];
9
- function getPathWithExt(path) {
10
- if ((0, fs_1.existsSync)(path) && (0, fs_1.statSync)(path).isFile()) {
11
- return path;
12
- }
13
- for (const extName of EXT_NAMES) {
14
- const newPath = `${path}${extName}`;
15
- if ((0, fs_1.existsSync)(newPath) && (0, fs_1.statSync)(newPath).isFile()) {
16
- return newPath;
17
- }
18
- }
19
- return null;
20
- }
21
- function getPathWithPkgJSON(path) {
22
- // TODO: 这里是否会有 symlink 问题?
23
- if ((0, fs_1.existsSync)(path) && (0, fs_1.statSync)(path).isDirectory()) {
24
- const pkgPath = (0, path_1.join)(path, 'package.json');
25
- if ((0, fs_1.existsSync)(pkgPath)) {
26
- const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf-8'));
27
- // ref: https://webpack.js.org/configuration/resolve/#resolvemainfields
28
- // TODO: support browser object
29
- // ref: https://unpkg.alibaba-inc.com/browse/react-dom@17.0.2/package.json
30
- const indexTarget = (0, path_1.join)(path, 'index.js');
31
- return ((pkg.module &&
32
- (getPathWithExt((0, path_1.join)(path, pkg.module)) ||
33
- getPathWithIndexFile((0, path_1.join)(path, pkg.module)))) ||
34
- (pkg.main &&
35
- (getPathWithExt((0, path_1.join)(path, pkg.main)) ||
36
- getPathWithIndexFile((0, path_1.join)(path, pkg.main)))) ||
37
- getPathWithExt(indexTarget) ||
38
- getPathWithIndexFile(indexTarget));
39
- }
40
- }
41
- return null;
42
- }
43
- function getPathWithIndexFile(path) {
44
- if ((0, fs_1.existsSync)(path) && (0, fs_1.statSync)(path).isDirectory()) {
45
- for (const extName of EXT_NAMES) {
46
- const indexFilePath = (0, path_1.join)(path, `index${extName}`);
47
- if ((0, fs_1.existsSync)(indexFilePath) && (0, fs_1.statSync)(indexFilePath).isFile()) {
48
- return indexFilePath;
49
- }
50
- }
51
- }
52
- return null;
53
- }
54
- function getFilePath({ path }) {
55
- // 1. 文件存在
56
- // 2. 加后缀
57
- const pathWithExt = getPathWithExt(path);
58
- if (pathWithExt) {
59
- return (0, utils_1.winPath)(pathWithExt);
60
- }
61
- // 3. path + package.json
62
- const pathWithPkgJSON = getPathWithPkgJSON(path);
63
- if (pathWithPkgJSON) {
64
- return (0, utils_1.winPath)(pathWithPkgJSON);
65
- }
66
- // 4. path + index.js
67
- const pathWithIndexFile = getPathWithIndexFile(path);
68
- if (pathWithIndexFile) {
69
- return (0, utils_1.winPath)(pathWithIndexFile);
70
- }
71
- return null;
72
- }
73
- exports.getFilePath = getFilePath;