@module-federation/esbuild 0.0.0-chore-bump-node-22-20260710161714
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +113 -0
- package/dist/adapters/lib/collect-exports.d.ts +3 -0
- package/dist/adapters/lib/collect-exports.js +153 -0
- package/dist/adapters/lib/collect-exports.mjs +80 -0
- package/dist/adapters/lib/commonjs.d.ts +101 -0
- package/dist/adapters/lib/commonjs.js +258 -0
- package/dist/adapters/lib/commonjs.mjs +182 -0
- package/dist/adapters/lib/containerPlugin.d.ts +6 -0
- package/dist/adapters/lib/containerPlugin.js +233 -0
- package/dist/adapters/lib/containerPlugin.mjs +179 -0
- package/dist/adapters/lib/containerReference.d.ts +6 -0
- package/dist/adapters/lib/containerReference.js +257 -0
- package/dist/adapters/lib/containerReference.mjs +188 -0
- package/dist/adapters/lib/lexer.d.ts +9 -0
- package/dist/adapters/lib/lexer.js +187 -0
- package/dist/adapters/lib/lexer.mjs +136 -0
- package/dist/adapters/lib/linkRemotesPlugin.d.ts +6 -0
- package/dist/adapters/lib/linkRemotesPlugin.js +117 -0
- package/dist/adapters/lib/linkRemotesPlugin.mjs +48 -0
- package/dist/adapters/lib/manifest.d.ts +2 -0
- package/dist/adapters/lib/manifest.js +227 -0
- package/dist/adapters/lib/manifest.mjs +159 -0
- package/dist/adapters/lib/plugin.d.ts +8 -0
- package/dist/adapters/lib/plugin.js +340 -0
- package/dist/adapters/lib/plugin.mjs +247 -0
- package/dist/adapters/lib/react-replacements.d.ts +9 -0
- package/dist/adapters/lib/react-replacements.js +86 -0
- package/dist/adapters/lib/react-replacements.mjs +34 -0
- package/dist/adapters/lib/transform.d.ts +8 -0
- package/dist/adapters/lib/transform.js +171 -0
- package/dist/adapters/lib/transform.mjs +116 -0
- package/dist/adapters/lib/utils.d.ts +3 -0
- package/dist/adapters/lib/utils.js +87 -0
- package/dist/adapters/lib/utils.mjs +31 -0
- package/dist/build.d.ts +5 -0
- package/dist/build.js +140 -0
- package/dist/build.mjs +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +55 -0
- package/dist/index.mjs +3 -0
- package/dist/lib/config/configuration-context.d.ts +7 -0
- package/dist/lib/config/configuration-context.js +73 -0
- package/dist/lib/config/configuration-context.mjs +18 -0
- package/dist/lib/config/federation-config.d.ts +30 -0
- package/dist/lib/config/federation-config.js +29 -0
- package/dist/lib/config/federation-config.mjs +3 -0
- package/dist/lib/config/share-utils.d.ts +29 -0
- package/dist/lib/config/share-utils.js +340 -0
- package/dist/lib/config/share-utils.mjs +245 -0
- package/dist/lib/config/with-native-federation.d.ts +23 -0
- package/dist/lib/config/with-native-federation.js +120 -0
- package/dist/lib/config/with-native-federation.mjs +66 -0
- package/dist/lib/core/build-adapter.d.ts +4 -0
- package/dist/lib/core/build-adapter.js +72 -0
- package/dist/lib/core/build-adapter.mjs +16 -0
- package/dist/lib/core/createContainerTemplate.d.ts +1 -0
- package/dist/lib/core/createContainerTemplate.js +235 -0
- package/dist/lib/core/createContainerTemplate.mjs +183 -0
- package/dist/lib/core/default-skip-list.d.ts +12 -0
- package/dist/lib/core/default-skip-list.js +103 -0
- package/dist/lib/core/default-skip-list.mjs +45 -0
- package/dist/lib/core/federation-options.d.ts +10 -0
- package/dist/lib/core/federation-options.js +29 -0
- package/dist/lib/core/federation-options.mjs +3 -0
- package/dist/lib/core/get-externals.d.ts +2 -0
- package/dist/lib/core/get-externals.js +68 -0
- package/dist/lib/core/get-externals.mjs +17 -0
- package/dist/lib/core/load-federation-config.d.ts +6 -0
- package/dist/lib/core/load-federation-config.js +71 -0
- package/dist/lib/core/load-federation-config.mjs +16 -0
- package/dist/lib/core/write-federation-info.d.ts +9 -0
- package/dist/lib/core/write-federation-info.js +67 -0
- package/dist/lib/core/write-federation-info.mjs +12 -0
- package/dist/lib/utils/logger.d.ts +11 -0
- package/dist/lib/utils/logger.js +113 -0
- package/dist/lib/utils/logger.mjs +44 -0
- package/dist/lib/utils/mapped-paths.d.ts +10 -0
- package/dist/lib/utils/mapped-paths.js +95 -0
- package/dist/lib/utils/mapped-paths.mjs +40 -0
- package/dist/lib/utils/normalize.d.ts +1 -0
- package/dist/lib/utils/normalize.js +66 -0
- package/dist/lib/utils/normalize.mjs +15 -0
- package/dist/lib/utils/package-info.d.ts +18 -0
- package/dist/lib/utils/package-info.js +325 -0
- package/dist/lib/utils/package-info.mjs +259 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/plugin.js +96 -0
- package/dist/plugin.mjs +4 -0
- package/dist/resolve/esm-resolver.mjs +19 -0
- package/dist/resolve/package.json +3 -0
- package/dist/rslib-runtime.mjs +31 -0
- package/package.json +75 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
var __webpack_modules__ = ({
|
|
10
|
+
"esbuild"(module) {
|
|
11
|
+
module.exports = require("esbuild");
|
|
12
|
+
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
});
|
|
16
|
+
// The module cache
|
|
17
|
+
var __webpack_module_cache__ = {};
|
|
18
|
+
|
|
19
|
+
// The require function
|
|
20
|
+
function __webpack_require__(moduleId) {
|
|
21
|
+
|
|
22
|
+
// Check if module is in cache
|
|
23
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
24
|
+
if (cachedModule !== undefined) {
|
|
25
|
+
return cachedModule.exports;
|
|
26
|
+
}
|
|
27
|
+
// Create a new module (and put it into the cache)
|
|
28
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
29
|
+
exports: {}
|
|
30
|
+
});
|
|
31
|
+
// Execute the module function
|
|
32
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
33
|
+
|
|
34
|
+
// Return the exports of the module
|
|
35
|
+
return module.exports;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// webpack/runtime/define_property_getters
|
|
40
|
+
(() => {
|
|
41
|
+
__webpack_require__.d = (exports, getters, values) => {
|
|
42
|
+
var define = (defs, kind) => {
|
|
43
|
+
for(var key in defs) {
|
|
44
|
+
if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
|
|
45
|
+
Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
define(getters, "get");
|
|
50
|
+
define(values, "value");
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
53
|
+
// webpack/runtime/has_own_property
|
|
54
|
+
(() => {
|
|
55
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
56
|
+
})();
|
|
57
|
+
// webpack/runtime/make_namespace_object
|
|
58
|
+
(() => {
|
|
59
|
+
// define __esModule on exports
|
|
60
|
+
__webpack_require__.r = (exports) => {
|
|
61
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
62
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
63
|
+
}
|
|
64
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
65
|
+
};
|
|
66
|
+
})();
|
|
67
|
+
var __webpack_exports__ = {};
|
|
68
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
69
|
+
(() => {
|
|
70
|
+
// ESM COMPAT FLAG
|
|
71
|
+
__webpack_require__.r(__webpack_exports__);
|
|
72
|
+
|
|
73
|
+
// EXPORTS
|
|
74
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
75
|
+
commonjs: () => (/* binding */ commonjs),
|
|
76
|
+
"default": () => (/* binding */ lib_commonjs)
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
;// CONCATENATED MODULE: external "fs"
|
|
80
|
+
const external_fs_namespaceObject = require("fs");
|
|
81
|
+
;// CONCATENATED MODULE: external "./lexer.js"
|
|
82
|
+
const external_lexer_js_namespaceObject = require("./lexer.js");
|
|
83
|
+
;// CONCATENATED MODULE: external "./utils.js"
|
|
84
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
85
|
+
;// CONCATENATED MODULE: ./src/adapters/lib/commonjs.ts
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
function commonjs({ filter = /\.c?js$/, transform = true, transformConfig, requireReturnsDefault = true, ignore } = {}) {
|
|
90
|
+
const init_cjs_module_lexer = transform ? import("cjs-module-lexer") : undefined;
|
|
91
|
+
const use_default_export = typeof requireReturnsDefault === 'function' ? requireReturnsDefault : (_path)=>requireReturnsDefault;
|
|
92
|
+
const is_ignored = typeof ignore === 'function' ? ignore : Array.isArray(ignore) ? (path)=>ignore.includes(path) : ()=>false;
|
|
93
|
+
return {
|
|
94
|
+
name: 'commonjs',
|
|
95
|
+
setup ({ onLoad, esbuild, initialOptions }) {
|
|
96
|
+
let esbuild_shim;
|
|
97
|
+
const require_esbuild = ()=>// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
98
|
+
esbuild || (esbuild_shim ||= __webpack_require__("esbuild"));
|
|
99
|
+
const read = external_fs_namespaceObject.promises.readFile;
|
|
100
|
+
const lexer = new external_lexer_js_namespaceObject.Lexer();
|
|
101
|
+
//@ts-ignore
|
|
102
|
+
onLoad({
|
|
103
|
+
filter: filter
|
|
104
|
+
}, async (args)=>{
|
|
105
|
+
let parseCJS;
|
|
106
|
+
if (init_cjs_module_lexer) {
|
|
107
|
+
const { init, parse } = await init_cjs_module_lexer;
|
|
108
|
+
await init();
|
|
109
|
+
parseCJS = parse;
|
|
110
|
+
}
|
|
111
|
+
let contents;
|
|
112
|
+
try {
|
|
113
|
+
//@ts-ignore
|
|
114
|
+
contents = await read(args.path, 'utf8');
|
|
115
|
+
} catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const willTransform = transform === true || typeof transform === 'function' && transform(args.path);
|
|
119
|
+
let cjsExports;
|
|
120
|
+
try {
|
|
121
|
+
if (parseCJS && willTransform) {
|
|
122
|
+
// move sourcemap to the end of the transformed file
|
|
123
|
+
const sourcemapIndex = contents.lastIndexOf('//# sourceMappingURL=');
|
|
124
|
+
let sourcemap;
|
|
125
|
+
if (sourcemapIndex !== -1) {
|
|
126
|
+
sourcemap = contents.slice(sourcemapIndex);
|
|
127
|
+
const sourcemapEnd = sourcemap.indexOf('\n');
|
|
128
|
+
if (sourcemapEnd !== -1 && sourcemap.slice(sourcemapEnd + 1).trimStart().length > 0) {
|
|
129
|
+
// if there's code after sourcemap, it is invalid, don't do this.
|
|
130
|
+
sourcemap = undefined;
|
|
131
|
+
} else {
|
|
132
|
+
contents = contents.slice(0, sourcemapIndex);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// transform commonjs to es modules, easy mode
|
|
136
|
+
cjsExports = parseCJS(contents);
|
|
137
|
+
let { behavior, exports, sideEffects } = typeof willTransform === 'object' ? willTransform : {};
|
|
138
|
+
behavior ??= transformConfig?.behavior ?? 'node';
|
|
139
|
+
exports = (0,external_utils_js_namespaceObject.orderedUniq)(cjsExports.exports.concat(exports ?? []));
|
|
140
|
+
sideEffects ??= transformConfig?.sideEffects ?? true;
|
|
141
|
+
let exportDefault = behavior === 'node' ? 'export default exports;' : 'export default exports.__esModule ? exports.default : exports;';
|
|
142
|
+
let exportsMap = exports.map((e)=>[
|
|
143
|
+
e,
|
|
144
|
+
(0,external_utils_js_namespaceObject.makeLegalIdentifier)(e)
|
|
145
|
+
]);
|
|
146
|
+
if (exportsMap.some(([e])=>e === 'default')) {
|
|
147
|
+
if (behavior === 'node') {
|
|
148
|
+
exportsMap = exportsMap.filter(([e])=>e !== 'default');
|
|
149
|
+
} else {
|
|
150
|
+
exportDefault = '';
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const reexports = cjsExports.reexports.map((e)=>`export * from ${JSON.stringify(e)};`).join('');
|
|
154
|
+
let transformed;
|
|
155
|
+
if (sideEffects === false) {
|
|
156
|
+
transformed = [
|
|
157
|
+
// make sure we don't manipulate the first line so that sourcemap is fine
|
|
158
|
+
reexports + 'var mod, exports = /* @__PURE__ */ ((exports, module) => {' + contents,
|
|
159
|
+
'return module.exports})((mod = { exports: {} }).exports, mod); ' + exportDefault
|
|
160
|
+
];
|
|
161
|
+
if (exportsMap.length > 0) {
|
|
162
|
+
for (const [e, name] of exportsMap){
|
|
163
|
+
transformed.push(`var ${name} = /* @__PURE__ */ (() => exports[${JSON.stringify(e)}])();`);
|
|
164
|
+
}
|
|
165
|
+
transformed.push(`export { ${exportsMap.map(([e, name])=>e === name ? e : `${name} as ${JSON.stringify(e)}`).join(', ')} };`);
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
transformed = [
|
|
169
|
+
reexports + 'var exports = {}, module = { exports }; {' + contents,
|
|
170
|
+
'}; exports = module.exports; ' + exportDefault
|
|
171
|
+
];
|
|
172
|
+
if (exportsMap.length > 0) {
|
|
173
|
+
transformed.push(`var { ${exportsMap.map(([e, name])=>e === name ? e : `${JSON.stringify(e)}: ${name}`).join(', ')} } = exports;`, `export { ${exportsMap.map(([e, name])=>e === name ? e : `${name} as ${JSON.stringify(e)}`).join(', ')} };`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
contents = transformed.join('\n') + (sourcemap ? '\n' + sourcemap : '');
|
|
177
|
+
}
|
|
178
|
+
} catch (e) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
function makeName(path) {
|
|
182
|
+
let name = `__import_${(0,external_utils_js_namespaceObject.makeLegalIdentifier)(path)}`;
|
|
183
|
+
if (contents.includes(name)) {
|
|
184
|
+
let suffix = 2;
|
|
185
|
+
while(contents.includes(`${name}${suffix}`))suffix++;
|
|
186
|
+
name = `${name}${suffix}`;
|
|
187
|
+
}
|
|
188
|
+
return name;
|
|
189
|
+
}
|
|
190
|
+
let warnings;
|
|
191
|
+
try {
|
|
192
|
+
({ warnings } = await require_esbuild().transform(contents, {
|
|
193
|
+
format: 'esm',
|
|
194
|
+
logLevel: 'silent'
|
|
195
|
+
}));
|
|
196
|
+
} catch (err) {
|
|
197
|
+
({ warnings } = err);
|
|
198
|
+
}
|
|
199
|
+
const lines = contents.split('\n');
|
|
200
|
+
const getOffset = (0,external_utils_js_namespaceObject.cachedReduce)(lines, (a, b)=>a + 1 + b.length, 0);
|
|
201
|
+
if (warnings && (warnings = warnings.filter((e)=>e.text.includes('"require" to "esm"'))).length) {
|
|
202
|
+
const edits = [];
|
|
203
|
+
let imports = [];
|
|
204
|
+
for (const { location } of warnings){
|
|
205
|
+
if (location === null) continue;
|
|
206
|
+
const { line, lineText, column, length } = location;
|
|
207
|
+
const leftBrace = column + length + 1;
|
|
208
|
+
const path = lexer.readString(lineText, leftBrace);
|
|
209
|
+
if (path === null || is_ignored(path)) continue;
|
|
210
|
+
const rightBrace = lineText.indexOf(')', leftBrace + 2 + path.length) + 1;
|
|
211
|
+
const name = makeName(path);
|
|
212
|
+
let import_statement;
|
|
213
|
+
if (use_default_export(path)) {
|
|
214
|
+
import_statement = `import ${name} from ${JSON.stringify(path)};`;
|
|
215
|
+
} else {
|
|
216
|
+
import_statement = `import * as ${name} from ${JSON.stringify(path)};`;
|
|
217
|
+
}
|
|
218
|
+
const offset = getOffset(line - 1);
|
|
219
|
+
edits.push([
|
|
220
|
+
offset + column,
|
|
221
|
+
offset + rightBrace,
|
|
222
|
+
name
|
|
223
|
+
]);
|
|
224
|
+
imports.push(import_statement);
|
|
225
|
+
}
|
|
226
|
+
if (imports.length === 0) return null;
|
|
227
|
+
imports = (0,external_utils_js_namespaceObject.orderedUniq)(imports);
|
|
228
|
+
let offset = 0;
|
|
229
|
+
for (const [start, end, name] of edits){
|
|
230
|
+
contents = contents.slice(0, start + offset) + name + contents.slice(end + offset);
|
|
231
|
+
offset += name.length - (end - start);
|
|
232
|
+
}
|
|
233
|
+
// if we have transformed this module (i.e. having `cjsExports`), don't make the file commonjs
|
|
234
|
+
contents = [
|
|
235
|
+
...imports,
|
|
236
|
+
cjsExports ? 'exports;' : '',
|
|
237
|
+
contents
|
|
238
|
+
].join('');
|
|
239
|
+
return {
|
|
240
|
+
contents
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/* export default */ const lib_commonjs = (commonjs);
|
|
248
|
+
|
|
249
|
+
})();
|
|
250
|
+
|
|
251
|
+
exports.commonjs = __webpack_exports__.commonjs;
|
|
252
|
+
exports["default"] = __webpack_exports__["default"];
|
|
253
|
+
for(var __rspack_i in __webpack_exports__) {
|
|
254
|
+
if(["commonjs","default"].indexOf(__rspack_i) === -1) {
|
|
255
|
+
exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { promises } from "fs";
|
|
2
|
+
import { Lexer } from "./lexer.mjs";
|
|
3
|
+
import { cachedReduce, makeLegalIdentifier, orderedUniq } from "./utils.mjs";
|
|
4
|
+
import { __webpack_require__ } from "../../rslib-runtime.mjs";
|
|
5
|
+
|
|
6
|
+
import * as __rspack_external_esbuild from "esbuild";
|
|
7
|
+
__webpack_require__.add({
|
|
8
|
+
"esbuild?dc06"(module) {
|
|
9
|
+
|
|
10
|
+
module.exports = __rspack_external_esbuild;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function commonjs({ filter = /\.c?js$/, transform = true, transformConfig, requireReturnsDefault = true, ignore } = {}) {
|
|
22
|
+
const init_cjs_module_lexer = transform ? import("cjs-module-lexer") : undefined;
|
|
23
|
+
const use_default_export = typeof requireReturnsDefault === 'function' ? requireReturnsDefault : (_path)=>requireReturnsDefault;
|
|
24
|
+
const is_ignored = typeof ignore === 'function' ? ignore : Array.isArray(ignore) ? (path)=>ignore.includes(path) : ()=>false;
|
|
25
|
+
return {
|
|
26
|
+
name: 'commonjs',
|
|
27
|
+
setup ({ onLoad, esbuild, initialOptions }) {
|
|
28
|
+
let esbuild_shim;
|
|
29
|
+
const require_esbuild = ()=>// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
30
|
+
esbuild || (esbuild_shim ||= __webpack_require__("esbuild?dc06"));
|
|
31
|
+
const read = promises.readFile;
|
|
32
|
+
const lexer = new Lexer();
|
|
33
|
+
//@ts-ignore
|
|
34
|
+
onLoad({
|
|
35
|
+
filter: filter
|
|
36
|
+
}, async (args)=>{
|
|
37
|
+
let parseCJS;
|
|
38
|
+
if (init_cjs_module_lexer) {
|
|
39
|
+
const { init, parse } = await init_cjs_module_lexer;
|
|
40
|
+
await init();
|
|
41
|
+
parseCJS = parse;
|
|
42
|
+
}
|
|
43
|
+
let contents;
|
|
44
|
+
try {
|
|
45
|
+
//@ts-ignore
|
|
46
|
+
contents = await read(args.path, 'utf8');
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const willTransform = transform === true || typeof transform === 'function' && transform(args.path);
|
|
51
|
+
let cjsExports;
|
|
52
|
+
try {
|
|
53
|
+
if (parseCJS && willTransform) {
|
|
54
|
+
// move sourcemap to the end of the transformed file
|
|
55
|
+
const sourcemapIndex = contents.lastIndexOf('//# sourceMappingURL=');
|
|
56
|
+
let sourcemap;
|
|
57
|
+
if (sourcemapIndex !== -1) {
|
|
58
|
+
sourcemap = contents.slice(sourcemapIndex);
|
|
59
|
+
const sourcemapEnd = sourcemap.indexOf('\n');
|
|
60
|
+
if (sourcemapEnd !== -1 && sourcemap.slice(sourcemapEnd + 1).trimStart().length > 0) {
|
|
61
|
+
// if there's code after sourcemap, it is invalid, don't do this.
|
|
62
|
+
sourcemap = undefined;
|
|
63
|
+
} else {
|
|
64
|
+
contents = contents.slice(0, sourcemapIndex);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// transform commonjs to es modules, easy mode
|
|
68
|
+
cjsExports = parseCJS(contents);
|
|
69
|
+
let { behavior, exports, sideEffects } = typeof willTransform === 'object' ? willTransform : {};
|
|
70
|
+
behavior ??= transformConfig?.behavior ?? 'node';
|
|
71
|
+
exports = orderedUniq(cjsExports.exports.concat(exports ?? []));
|
|
72
|
+
sideEffects ??= transformConfig?.sideEffects ?? true;
|
|
73
|
+
let exportDefault = behavior === 'node' ? 'export default exports;' : 'export default exports.__esModule ? exports.default : exports;';
|
|
74
|
+
let exportsMap = exports.map((e)=>[
|
|
75
|
+
e,
|
|
76
|
+
makeLegalIdentifier(e)
|
|
77
|
+
]);
|
|
78
|
+
if (exportsMap.some(([e])=>e === 'default')) {
|
|
79
|
+
if (behavior === 'node') {
|
|
80
|
+
exportsMap = exportsMap.filter(([e])=>e !== 'default');
|
|
81
|
+
} else {
|
|
82
|
+
exportDefault = '';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const reexports = cjsExports.reexports.map((e)=>`export * from ${JSON.stringify(e)};`).join('');
|
|
86
|
+
let transformed;
|
|
87
|
+
if (sideEffects === false) {
|
|
88
|
+
transformed = [
|
|
89
|
+
// make sure we don't manipulate the first line so that sourcemap is fine
|
|
90
|
+
reexports + 'var mod, exports = /* @__PURE__ */ ((exports, module) => {' + contents,
|
|
91
|
+
'return module.exports})((mod = { exports: {} }).exports, mod); ' + exportDefault
|
|
92
|
+
];
|
|
93
|
+
if (exportsMap.length > 0) {
|
|
94
|
+
for (const [e, name] of exportsMap){
|
|
95
|
+
transformed.push(`var ${name} = /* @__PURE__ */ (() => exports[${JSON.stringify(e)}])();`);
|
|
96
|
+
}
|
|
97
|
+
transformed.push(`export { ${exportsMap.map(([e, name])=>e === name ? e : `${name} as ${JSON.stringify(e)}`).join(', ')} };`);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
transformed = [
|
|
101
|
+
reexports + 'var exports = {}, module = { exports }; {' + contents,
|
|
102
|
+
'}; exports = module.exports; ' + exportDefault
|
|
103
|
+
];
|
|
104
|
+
if (exportsMap.length > 0) {
|
|
105
|
+
transformed.push(`var { ${exportsMap.map(([e, name])=>e === name ? e : `${JSON.stringify(e)}: ${name}`).join(', ')} } = exports;`, `export { ${exportsMap.map(([e, name])=>e === name ? e : `${name} as ${JSON.stringify(e)}`).join(', ')} };`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
contents = transformed.join('\n') + (sourcemap ? '\n' + sourcemap : '');
|
|
109
|
+
}
|
|
110
|
+
} catch (e) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
function makeName(path) {
|
|
114
|
+
let name = `__import_${makeLegalIdentifier(path)}`;
|
|
115
|
+
if (contents.includes(name)) {
|
|
116
|
+
let suffix = 2;
|
|
117
|
+
while(contents.includes(`${name}${suffix}`))suffix++;
|
|
118
|
+
name = `${name}${suffix}`;
|
|
119
|
+
}
|
|
120
|
+
return name;
|
|
121
|
+
}
|
|
122
|
+
let warnings;
|
|
123
|
+
try {
|
|
124
|
+
({ warnings } = await require_esbuild().transform(contents, {
|
|
125
|
+
format: 'esm',
|
|
126
|
+
logLevel: 'silent'
|
|
127
|
+
}));
|
|
128
|
+
} catch (err) {
|
|
129
|
+
({ warnings } = err);
|
|
130
|
+
}
|
|
131
|
+
const lines = contents.split('\n');
|
|
132
|
+
const getOffset = cachedReduce(lines, (a, b)=>a + 1 + b.length, 0);
|
|
133
|
+
if (warnings && (warnings = warnings.filter((e)=>e.text.includes('"require" to "esm"'))).length) {
|
|
134
|
+
const edits = [];
|
|
135
|
+
let imports = [];
|
|
136
|
+
for (const { location } of warnings){
|
|
137
|
+
if (location === null) continue;
|
|
138
|
+
const { line, lineText, column, length } = location;
|
|
139
|
+
const leftBrace = column + length + 1;
|
|
140
|
+
const path = lexer.readString(lineText, leftBrace);
|
|
141
|
+
if (path === null || is_ignored(path)) continue;
|
|
142
|
+
const rightBrace = lineText.indexOf(')', leftBrace + 2 + path.length) + 1;
|
|
143
|
+
const name = makeName(path);
|
|
144
|
+
let import_statement;
|
|
145
|
+
if (use_default_export(path)) {
|
|
146
|
+
import_statement = `import ${name} from ${JSON.stringify(path)};`;
|
|
147
|
+
} else {
|
|
148
|
+
import_statement = `import * as ${name} from ${JSON.stringify(path)};`;
|
|
149
|
+
}
|
|
150
|
+
const offset = getOffset(line - 1);
|
|
151
|
+
edits.push([
|
|
152
|
+
offset + column,
|
|
153
|
+
offset + rightBrace,
|
|
154
|
+
name
|
|
155
|
+
]);
|
|
156
|
+
imports.push(import_statement);
|
|
157
|
+
}
|
|
158
|
+
if (imports.length === 0) return null;
|
|
159
|
+
imports = orderedUniq(imports);
|
|
160
|
+
let offset = 0;
|
|
161
|
+
for (const [start, end, name] of edits){
|
|
162
|
+
contents = contents.slice(0, start + offset) + name + contents.slice(end + offset);
|
|
163
|
+
offset += name.length - (end - start);
|
|
164
|
+
}
|
|
165
|
+
// if we have transformed this module (i.e. having `cjsExports`), don't make the file commonjs
|
|
166
|
+
contents = [
|
|
167
|
+
...imports,
|
|
168
|
+
cjsExports ? 'exports;' : '',
|
|
169
|
+
contents
|
|
170
|
+
].join('');
|
|
171
|
+
return {
|
|
172
|
+
contents
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/* export default */ const lib_commonjs = (commonjs);
|
|
180
|
+
|
|
181
|
+
export { commonjs };
|
|
182
|
+
export default lib_commonjs;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
3
|
+
return typeof document === 'undefined'
|
|
4
|
+
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
5
|
+
: (document.currentScript && document.currentScript.src) ||
|
|
6
|
+
new URL('main.js', document.baseURI).href;
|
|
7
|
+
})();
|
|
8
|
+
;
|
|
9
|
+
// The require scope
|
|
10
|
+
var __webpack_require__ = {};
|
|
11
|
+
|
|
12
|
+
// webpack/runtime/define_property_getters
|
|
13
|
+
(() => {
|
|
14
|
+
__webpack_require__.d = (exports, getters, values) => {
|
|
15
|
+
var define = (defs, kind) => {
|
|
16
|
+
for(var key in defs) {
|
|
17
|
+
if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
|
|
18
|
+
Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
define(getters, "get");
|
|
23
|
+
define(values, "value");
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
// webpack/runtime/has_own_property
|
|
27
|
+
(() => {
|
|
28
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
29
|
+
})();
|
|
30
|
+
// webpack/runtime/make_namespace_object
|
|
31
|
+
(() => {
|
|
32
|
+
// define __esModule on exports
|
|
33
|
+
__webpack_require__.r = (exports) => {
|
|
34
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
35
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
var __webpack_exports__ = {};
|
|
41
|
+
// ESM COMPAT FLAG
|
|
42
|
+
__webpack_require__.r(__webpack_exports__);
|
|
43
|
+
|
|
44
|
+
// EXPORTS
|
|
45
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
46
|
+
createContainerPlugin: () => (/* binding */ createContainerPlugin)
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
;// CONCATENATED MODULE: external "../../lib/core/createContainerTemplate.js"
|
|
50
|
+
const createContainerTemplate_js_namespaceObject = require("../../lib/core/createContainerTemplate.js");
|
|
51
|
+
;// CONCATENATED MODULE: ./src/adapters/lib/containerPlugin.ts
|
|
52
|
+
|
|
53
|
+
const buildContainerHost = (config)=>{
|
|
54
|
+
const { name, remotes = {}, shared = {}, exposes = {} } = config;
|
|
55
|
+
const remoteConfigs = Object.entries(remotes).map(([remoteAlias, remote])=>({
|
|
56
|
+
type: 'esm',
|
|
57
|
+
name: remoteAlias,
|
|
58
|
+
entry: remote.entry,
|
|
59
|
+
alias: remoteAlias
|
|
60
|
+
}));
|
|
61
|
+
const sharedConfig = Object.entries(shared).reduce((acc, [pkg, config])=>{
|
|
62
|
+
const version = config.requiredVersion?.replace(/^[^0-9]/, '') || '';
|
|
63
|
+
acc += `${JSON.stringify(pkg)}: {
|
|
64
|
+
"package": "${pkg}",
|
|
65
|
+
"version": "${version}",
|
|
66
|
+
"scope": "default",
|
|
67
|
+
"get": async () => import('federationShare/${pkg}'),
|
|
68
|
+
"shareConfig": {
|
|
69
|
+
"singleton": ${config.singleton},
|
|
70
|
+
"requiredVersion": "${config.requiredVersion}",
|
|
71
|
+
"eager": ${config.eager},
|
|
72
|
+
"strictVersion": ${config.strictVersion}
|
|
73
|
+
}
|
|
74
|
+
},\n`;
|
|
75
|
+
return acc;
|
|
76
|
+
}, '{') + '}';
|
|
77
|
+
let exposesConfig = Object.entries(exposes).map(([exposeName, exposePath])=>`${JSON.stringify(exposeName)}: async () => await import('${exposePath}')`).join(',\n');
|
|
78
|
+
exposesConfig = `{${exposesConfig}}`;
|
|
79
|
+
const injectedContent = `
|
|
80
|
+
export const moduleMap = '__MODULE_MAP__';
|
|
81
|
+
|
|
82
|
+
function appendImportMap(importMap) {
|
|
83
|
+
const script = document.createElement('script');
|
|
84
|
+
script.type = 'importmap-shim';
|
|
85
|
+
script.innerHTML = JSON.stringify(importMap);
|
|
86
|
+
document.head.appendChild(script);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const createVirtualRemoteModule = (name, ref, exports) => {
|
|
90
|
+
const genExports = exports.map(e =>
|
|
91
|
+
e === 'default' ? 'export default mfLsZJ92.default' : \`export const \${e} = mfLsZJ92[\${JSON.stringify(e)}];\`
|
|
92
|
+
).join('');
|
|
93
|
+
|
|
94
|
+
const loadRef = \`const mfLsZJ92 = await container.loadRemote(\${JSON.stringify(ref)});\`;
|
|
95
|
+
|
|
96
|
+
return \`
|
|
97
|
+
const container = __FEDERATION__.__INSTANCES__.find(container => container.name === name) || __FEDERATION__.__INSTANCES__[0];
|
|
98
|
+
\${loadRef}
|
|
99
|
+
\${genExports}
|
|
100
|
+
\`;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
function encodeInlineESM(code) {
|
|
104
|
+
const encodedCode = encodeURIComponent(code);
|
|
105
|
+
return \`data:text/javascript;charset=utf-8,\${encodedCode}\`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const runtimePlugin = () => ({
|
|
109
|
+
name: 'import-maps-plugin',
|
|
110
|
+
async init(args) {
|
|
111
|
+
|
|
112
|
+
const remotePrefetch = args.options.remotes.map(async (remote) => {
|
|
113
|
+
if (remote.type === 'esm') {
|
|
114
|
+
await import(remote.entry);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
await Promise.all(remotePrefetch);
|
|
120
|
+
|
|
121
|
+
const map = Object.keys(moduleMap).reduce((acc, expose) => {
|
|
122
|
+
const importMap = importShim.getImportMap().imports;
|
|
123
|
+
const key = args.origin.name + expose.replace('.', '');
|
|
124
|
+
if (!importMap[key]) {
|
|
125
|
+
const encodedModule = encodeInlineESM(
|
|
126
|
+
createVirtualRemoteModule(args.origin.name, key, moduleMap[expose].exports)
|
|
127
|
+
);
|
|
128
|
+
acc[key] = encodedModule;
|
|
129
|
+
}
|
|
130
|
+
return acc;
|
|
131
|
+
}, {});
|
|
132
|
+
await importShim.addImportMap({ imports: map });
|
|
133
|
+
|
|
134
|
+
return args;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const createdContainer = await createContainer({
|
|
139
|
+
name: ${JSON.stringify(name)},
|
|
140
|
+
exposes: ${exposesConfig},
|
|
141
|
+
remotes: ${JSON.stringify(remoteConfigs)},
|
|
142
|
+
shared: ${sharedConfig},
|
|
143
|
+
plugins: [runtimePlugin()],
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
export const get = createdContainer.get;
|
|
147
|
+
export const init = createdContainer.init;
|
|
148
|
+
`;
|
|
149
|
+
//replace with createContainer from bundler runtime - import it in the string as a dep etc
|
|
150
|
+
return [
|
|
151
|
+
createContainerTemplate_js_namespaceObject.createContainerCode,
|
|
152
|
+
injectedContent
|
|
153
|
+
].join('\n');
|
|
154
|
+
};
|
|
155
|
+
const createContainerPlugin = (config)=>({
|
|
156
|
+
name: 'createContainer',
|
|
157
|
+
setup (build) {
|
|
158
|
+
const { filename } = config;
|
|
159
|
+
const filter = new RegExp([
|
|
160
|
+
filename
|
|
161
|
+
].map((name)=>`${name}$`).join('|'));
|
|
162
|
+
const hasShared = Object.keys(config.shared || {}).length;
|
|
163
|
+
const shared = Object.keys(config.shared || {}).map((name)=>`${name}$`).join('|');
|
|
164
|
+
const sharedExternals = new RegExp(shared);
|
|
165
|
+
build.onResolve({
|
|
166
|
+
filter
|
|
167
|
+
}, async (args)=>({
|
|
168
|
+
path: args.path,
|
|
169
|
+
namespace: 'container',
|
|
170
|
+
pluginData: {
|
|
171
|
+
kind: args.kind,
|
|
172
|
+
resolveDir: args.resolveDir
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
build.onResolve({
|
|
176
|
+
filter: /^federationShare/
|
|
177
|
+
}, async (args)=>({
|
|
178
|
+
path: args.path.replace('federationShare/', ''),
|
|
179
|
+
namespace: 'esm-shares',
|
|
180
|
+
pluginData: {
|
|
181
|
+
kind: args.kind,
|
|
182
|
+
resolveDir: args.resolveDir
|
|
183
|
+
}
|
|
184
|
+
}));
|
|
185
|
+
if (hasShared) {
|
|
186
|
+
build.onResolve({
|
|
187
|
+
filter: sharedExternals
|
|
188
|
+
}, (args)=>{
|
|
189
|
+
if (args.namespace === 'esm-shares') return null;
|
|
190
|
+
return {
|
|
191
|
+
path: args.path,
|
|
192
|
+
namespace: 'virtual-share-module',
|
|
193
|
+
pluginData: {
|
|
194
|
+
kind: args.kind,
|
|
195
|
+
resolveDir: args.resolveDir
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
build.onResolve({
|
|
200
|
+
filter: /.*/,
|
|
201
|
+
namespace: 'esm-shares'
|
|
202
|
+
}, async (args)=>{
|
|
203
|
+
if (sharedExternals.test(args.path)) {
|
|
204
|
+
return {
|
|
205
|
+
path: args.path,
|
|
206
|
+
namespace: 'virtual-share-module',
|
|
207
|
+
pluginData: {
|
|
208
|
+
kind: args.kind,
|
|
209
|
+
resolveDir: args.resolveDir
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
build.onLoad({
|
|
217
|
+
filter,
|
|
218
|
+
namespace: 'container'
|
|
219
|
+
}, async (args)=>({
|
|
220
|
+
contents: buildContainerHost(config),
|
|
221
|
+
loader: 'js',
|
|
222
|
+
resolveDir: args.pluginData.resolveDir
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
exports.createContainerPlugin = __webpack_exports__.createContainerPlugin;
|
|
228
|
+
for(var __rspack_i in __webpack_exports__) {
|
|
229
|
+
if(["createContainerPlugin"].indexOf(__rspack_i) === -1) {
|
|
230
|
+
exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|