@module-federation/electron 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +79 -1
- package/dist/index.cjs +79 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -0
- package/dist/resolve.cjs +60 -0
- package/dist/resolve.cjs.map +1 -0
- package/dist/resolve.d.cts +7 -0
- package/dist/resolve.d.cts.map +1 -0
- package/dist/resolve.d.ts +7 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +12 -0
- package/dist/resolve.js.map +1 -0
- package/dist/rsbuild.cjs +89 -0
- package/dist/rsbuild.cjs.map +1 -0
- package/dist/rsbuild.d.cts +31 -0
- package/dist/rsbuild.d.cts.map +1 -0
- package/dist/rsbuild.d.ts +31 -0
- package/dist/rsbuild.d.ts.map +1 -0
- package/dist/rsbuild.js +30 -0
- package/dist/rsbuild.js.map +1 -0
- package/dist/url.cjs +67 -0
- package/dist/url.cjs.map +1 -0
- package/dist/url.d.cts +22 -0
- package/dist/url.d.cts.map +1 -0
- package/dist/url.d.ts +22 -0
- package/dist/url.d.ts.map +1 -0
- package/dist/url.js +17 -0
- package/dist/url.js.map +1 -0
- package/dist/vite.cjs +84 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.cts +29 -0
- package/dist/vite.d.cts.map +1 -0
- package/dist/vite.d.ts +29 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +25 -0
- package/dist/vite.js.map +1 -0
- package/package.json +82 -23
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.1](https://github.com/module-federation/electron/compare/0.1.0...0.1.1) (2026-11-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Documentation
|
|
7
|
+
|
|
8
|
+
* list requirements in the package README ([#9](https://github.com/module-federation/electron/issues/9)) ([c35a574](https://github.com/module-federation/electron/commit/c35a574dfbe2e47354db63c48007279e9338b44a))
|
|
9
|
+
|
|
10
|
+
## [0.1.0](https://github.com/module-federation/electron/compare/0.0.1...0.1.0) (2026-11-04)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add Electron integration for Rsbuild and Vite ([#4](https://github.com/module-federation/electron/issues/4)) ([edd080c](https://github.com/module-federation/electron/commit/edd080cfba75f9eb1829fd608ed649ca26dd8494))
|
|
16
|
+
|
|
17
|
+
## Changelog
|
package/README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
1
|
# @module-federation/electron
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Module Federation for Electron renderers built with Rsbuild or Vite. Hosts and remotes can use either bundler.
|
|
4
|
+
|
|
5
|
+
In production every federated app is served from one privileged custom protocol, `mf://local/<app-id>/`. All apps share one origin, so remote entries, manifests and chunks load without CORS setup.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @module-federation/electron
|
|
11
|
+
# plus the Module Federation plugin for each bundler you use:
|
|
12
|
+
pnpm add -D @module-federation/rsbuild-plugin # Rsbuild
|
|
13
|
+
pnpm add -D @module-federation/vite # Vite, 1.23.9 or later
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Requires Electron 30 or later and Node.js 22.18+, 24.11+ or 26+ for builds. Rsbuild 2 and Vite 7 or 8 are supported.
|
|
17
|
+
|
|
18
|
+
## Main process
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { app, BrowserWindow } from 'electron';
|
|
22
|
+
import {
|
|
23
|
+
federationUrl,
|
|
24
|
+
registerFederationScheme,
|
|
25
|
+
serveFederatedApps,
|
|
26
|
+
} from '@module-federation/electron';
|
|
27
|
+
|
|
28
|
+
registerFederationScheme(); // before `app` is ready
|
|
29
|
+
|
|
30
|
+
app.whenReady().then(() => {
|
|
31
|
+
serveFederatedApps({
|
|
32
|
+
apps: { host: '/path/to/host/dist', remote: '/path/to/remote/dist' },
|
|
33
|
+
});
|
|
34
|
+
new BrowserWindow().loadURL(federationUrl('host', 'index.html'));
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`serveFederatedApps` maps each federation `name` to its build directory and returns a function that unregisters the handler. Requests outside an app's directory get a 404.
|
|
39
|
+
|
|
40
|
+
## Rsbuild
|
|
41
|
+
|
|
42
|
+
`./rsbuild` and `./vite` re-export the URL helpers, so build configs don't load `electron`.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { defineConfig } from '@rsbuild/core';
|
|
46
|
+
import { federationUrl, pluginModuleFederationElectron } from '@module-federation/electron/rsbuild';
|
|
47
|
+
|
|
48
|
+
export default defineConfig({
|
|
49
|
+
plugins: [
|
|
50
|
+
pluginModuleFederationElectron({
|
|
51
|
+
name: 'host',
|
|
52
|
+
remotes: { remote: `remote@${federationUrl('remote', 'mf-manifest.json')}` },
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Vite
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { defineConfig } from 'vite';
|
|
62
|
+
import { federationElectron } from '@module-federation/electron/vite';
|
|
63
|
+
|
|
64
|
+
export default defineConfig({
|
|
65
|
+
plugins: [
|
|
66
|
+
federationElectron({
|
|
67
|
+
name: 'remote',
|
|
68
|
+
exposes: { './Card': './src/Card.tsx' },
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Options
|
|
75
|
+
|
|
76
|
+
Both plugins take a second argument, `{ electron: { protocol, scheme, host } }`:
|
|
77
|
+
|
|
78
|
+
- `protocol` (default `true`): set `output.assetPrefix` (Rsbuild) or `base` (Vite) to `mf://local/<app-id>/` for production builds. Dev servers, explicit values, and `protocol: false` are left alone.
|
|
79
|
+
- `scheme` / `host` (default `mf` / `local`): change the URL. Pass the same values to `registerFederationScheme` and `serveFederatedApps`.
|
|
80
|
+
|
|
81
|
+
The Rsbuild plugin also takes `{ rsbuild }`, which is passed through to `@module-federation/rsbuild-plugin`.
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
3
18
|
(()=>{
|
|
4
19
|
__webpack_require__.r = (exports1)=>{
|
|
5
20
|
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
@@ -12,7 +27,70 @@ var __webpack_require__ = {};
|
|
|
12
27
|
})();
|
|
13
28
|
var __webpack_exports__ = {};
|
|
14
29
|
__webpack_require__.r(__webpack_exports__);
|
|
15
|
-
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
DEFAULT_HOST: ()=>external_url_cjs_namespaceObject.DEFAULT_HOST,
|
|
32
|
+
DEFAULT_SCHEME: ()=>external_url_cjs_namespaceObject.DEFAULT_SCHEME,
|
|
33
|
+
federationBaseUrl: ()=>external_url_cjs_namespaceObject.federationBaseUrl,
|
|
34
|
+
federationUrl: ()=>external_url_cjs_namespaceObject.federationUrl,
|
|
35
|
+
registerFederationScheme: ()=>registerFederationScheme,
|
|
36
|
+
resolveAppFile: ()=>external_resolve_cjs_namespaceObject.resolveAppFile,
|
|
37
|
+
serveFederatedApps: ()=>serveFederatedApps,
|
|
38
|
+
toAppId: ()=>external_url_cjs_namespaceObject.toAppId
|
|
39
|
+
});
|
|
40
|
+
const external_node_url_namespaceObject = require("node:url");
|
|
41
|
+
const external_electron_namespaceObject = require("electron");
|
|
42
|
+
const external_resolve_cjs_namespaceObject = require("./resolve.cjs");
|
|
43
|
+
const external_url_cjs_namespaceObject = require("./url.cjs");
|
|
44
|
+
function registerFederationScheme(options = {}) {
|
|
45
|
+
external_electron_namespaceObject.protocol.registerSchemesAsPrivileged([
|
|
46
|
+
{
|
|
47
|
+
scheme: options.scheme ?? external_url_cjs_namespaceObject.DEFAULT_SCHEME,
|
|
48
|
+
privileges: {
|
|
49
|
+
standard: true,
|
|
50
|
+
secure: true,
|
|
51
|
+
supportFetchAPI: true,
|
|
52
|
+
corsEnabled: true,
|
|
53
|
+
stream: true,
|
|
54
|
+
codeCache: true
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
function serveFederatedApps(options) {
|
|
60
|
+
const scheme = options.scheme ?? external_url_cjs_namespaceObject.DEFAULT_SCHEME;
|
|
61
|
+
const host = options.host ?? external_url_cjs_namespaceObject.DEFAULT_HOST;
|
|
62
|
+
const apps = Object.fromEntries(Object.entries(options.apps).map(([name, dir])=>[
|
|
63
|
+
(0, external_url_cjs_namespaceObject.toAppId)(name),
|
|
64
|
+
dir
|
|
65
|
+
]));
|
|
66
|
+
external_electron_namespaceObject.protocol.handle(scheme, async (request)=>{
|
|
67
|
+
const url = new URL(request.url);
|
|
68
|
+
const file = url.host === host ? (0, external_resolve_cjs_namespaceObject.resolveAppFile)(url.pathname, apps) : void 0;
|
|
69
|
+
if (!file) return new Response('Not found', {
|
|
70
|
+
status: 404
|
|
71
|
+
});
|
|
72
|
+
return external_electron_namespaceObject.net.fetch((0, external_node_url_namespaceObject.pathToFileURL)(file).href);
|
|
73
|
+
});
|
|
74
|
+
return ()=>external_electron_namespaceObject.protocol.unhandle(scheme);
|
|
75
|
+
}
|
|
76
|
+
exports.DEFAULT_HOST = __webpack_exports__.DEFAULT_HOST;
|
|
77
|
+
exports.DEFAULT_SCHEME = __webpack_exports__.DEFAULT_SCHEME;
|
|
78
|
+
exports.federationBaseUrl = __webpack_exports__.federationBaseUrl;
|
|
79
|
+
exports.federationUrl = __webpack_exports__.federationUrl;
|
|
80
|
+
exports.registerFederationScheme = __webpack_exports__.registerFederationScheme;
|
|
81
|
+
exports.resolveAppFile = __webpack_exports__.resolveAppFile;
|
|
82
|
+
exports.serveFederatedApps = __webpack_exports__.serveFederatedApps;
|
|
83
|
+
exports.toAppId = __webpack_exports__.toAppId;
|
|
84
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
85
|
+
"DEFAULT_HOST",
|
|
86
|
+
"DEFAULT_SCHEME",
|
|
87
|
+
"federationBaseUrl",
|
|
88
|
+
"federationUrl",
|
|
89
|
+
"registerFederationScheme",
|
|
90
|
+
"resolveAppFile",
|
|
91
|
+
"serveFederatedApps",
|
|
92
|
+
"toAppId"
|
|
93
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
94
|
Object.defineProperty(exports, '__esModule', {
|
|
17
95
|
value: true
|
|
18
96
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["webpack://webpack/runtime/make_namespace_object"],"sourcesContent":["// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};"],"names":["__webpack_require__","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/index.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Electron main-process integration. Build configs should import the URL helpers\n * from `@module-federation/electron/rsbuild` or `/vite` instead: this entry imports `electron`.\n */\nimport { pathToFileURL } from 'node:url';\nimport { net, protocol } from 'electron';\nimport { resolveAppFile } from './resolve.ts';\nimport { DEFAULT_HOST, DEFAULT_SCHEME, toAppId } from './url.ts';\n\nexport { resolveAppFile } from './resolve.ts';\nexport {\n DEFAULT_HOST,\n DEFAULT_SCHEME,\n federationBaseUrl,\n federationUrl,\n toAppId,\n type FederationUrlOptions,\n} from './url.ts';\n\nexport interface RegisterSchemeOptions {\n scheme?: string;\n}\n\n/**\n * Registers the federation scheme as privileged (fetch, CORS, ESM, service workers).\n * Must be called before the `ready` event of `app`.\n */\nexport function registerFederationScheme(options: RegisterSchemeOptions = {}): void {\n protocol.registerSchemesAsPrivileged([\n {\n scheme: options.scheme ?? DEFAULT_SCHEME,\n privileges: {\n standard: true,\n secure: true,\n supportFetchAPI: true,\n corsEnabled: true,\n stream: true,\n codeCache: true,\n },\n },\n ]);\n}\n\nexport interface ServeFederatedAppsOptions {\n scheme?: string;\n host?: string;\n /** Map of federation `name` (or app id) to the directory holding its build output. */\n apps: Record<string, string>;\n}\n\n/**\n * Serves each app's build output on `<scheme>://<host>/<appId>/`.\n * Call after `app.whenReady()`. Returns a function that unregisters the handler.\n */\nexport function serveFederatedApps(options: ServeFederatedAppsOptions): () => void {\n const scheme = options.scheme ?? DEFAULT_SCHEME;\n const host = options.host ?? DEFAULT_HOST;\n const apps = Object.fromEntries(\n Object.entries(options.apps).map(([name, dir]) => [toAppId(name), dir]),\n );\n\n protocol.handle(scheme, async (request) => {\n const url = new URL(request.url);\n const file = url.host === host ? resolveAppFile(url.pathname, apps) : undefined;\n if (!file) return new Response('Not found', { status: 404 });\n return net.fetch(pathToFileURL(file).href);\n });\n\n return () => protocol.unhandle(scheme);\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","registerFederationScheme","options","protocol","DEFAULT_SCHEME","serveFederatedApps","scheme","host","DEFAULT_HOST","apps","name","dir","toAppId","request","url","URL","file","resolveAppFile","undefined","Response","net","pathToFileURL"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;ACqBO,SAASI,yBAAyBC,UAAiC,CAAC,CAAC;IAC1EC,kCAAAA,QAAAA,CAAAA,2BAAoC,CAAC;QACnC;YACE,QAAQD,QAAQ,MAAM,IAAIE,iCAAAA,cAAcA;YACxC,YAAY;gBACV,UAAU;gBACV,QAAQ;gBACR,iBAAiB;gBACjB,aAAa;gBACb,QAAQ;gBACR,WAAW;YACb;QACF;KACD;AACH;AAaO,SAASC,mBAAmBH,OAAkC;IACnE,MAAMI,SAASJ,QAAQ,MAAM,IAAIE,iCAAAA,cAAcA;IAC/C,MAAMG,OAAOL,QAAQ,IAAI,IAAIM,iCAAAA,YAAYA;IACzC,MAAMC,OAAOZ,OAAO,WAAW,CAC7BA,OAAO,OAAO,CAACK,QAAQ,IAAI,EAAE,GAAG,CAAC,CAAC,CAACQ,MAAMC,IAAI,GAAK;YAACC,IAAAA,iCAAAA,OAAAA,AAAAA,EAAQF;YAAOC;SAAI;IAGxER,kCAAAA,QAAAA,CAAAA,MAAe,CAACG,QAAQ,OAAOO;QAC7B,MAAMC,MAAM,IAAIC,IAAIF,QAAQ,GAAG;QAC/B,MAAMG,OAAOF,IAAI,IAAI,KAAKP,OAAOU,AAAAA,IAAAA,qCAAAA,cAAAA,AAAAA,EAAeH,IAAI,QAAQ,EAAEL,QAAQS;QACtE,IAAI,CAACF,MAAM,OAAO,IAAIG,SAAS,aAAa;YAAE,QAAQ;QAAI;QAC1D,OAAOC,kCAAAA,GAAAA,CAAAA,KAAS,CAACC,AAAAA,IAAAA,kCAAAA,aAAAA,AAAAA,EAAcL,MAAM,IAAI;IAC3C;IAEA,OAAO,IAAMb,kCAAAA,QAAAA,CAAAA,QAAiB,CAACG;AACjC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { resolveAppFile } from './resolve.cjs';
|
|
2
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId, type FederationUrlOptions, } from './url.cjs';
|
|
3
|
+
export interface RegisterSchemeOptions {
|
|
4
|
+
scheme?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Registers the federation scheme as privileged (fetch, CORS, ESM, service workers).
|
|
8
|
+
* Must be called before the `ready` event of `app`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerFederationScheme(options?: RegisterSchemeOptions): void;
|
|
11
|
+
export interface ServeFederatedAppsOptions {
|
|
12
|
+
scheme?: string;
|
|
13
|
+
host?: string;
|
|
14
|
+
/** Map of federation `name` (or app id) to the directory holding its build output. */
|
|
15
|
+
apps: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Serves each app's build output on `<scheme>://<host>/<appId>/`.
|
|
19
|
+
* Call after `app.whenReady()`. Returns a function that unregisters the handler.
|
|
20
|
+
*/
|
|
21
|
+
export declare function serveFederatedApps(options: ServeFederatedAppsOptions): () => void;
|
|
2
22
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,qBAA0B,GAAG,IAAI,CAclF;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,IAAI,CAejF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { resolveAppFile } from './resolve.js';
|
|
2
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId, type FederationUrlOptions, } from './url.js';
|
|
3
|
+
export interface RegisterSchemeOptions {
|
|
4
|
+
scheme?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Registers the federation scheme as privileged (fetch, CORS, ESM, service workers).
|
|
8
|
+
* Must be called before the `ready` event of `app`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function registerFederationScheme(options?: RegisterSchemeOptions): void;
|
|
11
|
+
export interface ServeFederatedAppsOptions {
|
|
12
|
+
scheme?: string;
|
|
13
|
+
host?: string;
|
|
14
|
+
/** Map of federation `name` (or app id) to the directory holding its build output. */
|
|
15
|
+
apps: Record<string, string>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Serves each app's build output on `<scheme>://<host>/<appId>/`.
|
|
19
|
+
* Call after `app.whenReady()`. Returns a function that unregisters the handler.
|
|
20
|
+
*/
|
|
21
|
+
export declare function serveFederatedApps(options: ServeFederatedAppsOptions): () => void;
|
|
2
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,qBAA0B,GAAG,IAAI,CAclF;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,IAAI,CAejF"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { net, protocol } from "electron";
|
|
3
|
+
import { resolveAppFile } from "./resolve.js";
|
|
4
|
+
import { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId } from "./url.js";
|
|
5
|
+
function registerFederationScheme(options = {}) {
|
|
6
|
+
protocol.registerSchemesAsPrivileged([
|
|
7
|
+
{
|
|
8
|
+
scheme: options.scheme ?? DEFAULT_SCHEME,
|
|
9
|
+
privileges: {
|
|
10
|
+
standard: true,
|
|
11
|
+
secure: true,
|
|
12
|
+
supportFetchAPI: true,
|
|
13
|
+
corsEnabled: true,
|
|
14
|
+
stream: true,
|
|
15
|
+
codeCache: true
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
function serveFederatedApps(options) {
|
|
21
|
+
const scheme = options.scheme ?? DEFAULT_SCHEME;
|
|
22
|
+
const host = options.host ?? DEFAULT_HOST;
|
|
23
|
+
const apps = Object.fromEntries(Object.entries(options.apps).map(([name, dir])=>[
|
|
24
|
+
toAppId(name),
|
|
25
|
+
dir
|
|
26
|
+
]));
|
|
27
|
+
protocol.handle(scheme, async (request)=>{
|
|
28
|
+
const url = new URL(request.url);
|
|
29
|
+
const file = url.host === host ? resolveAppFile(url.pathname, apps) : void 0;
|
|
30
|
+
if (!file) return new Response('Not found', {
|
|
31
|
+
status: 404
|
|
32
|
+
});
|
|
33
|
+
return net.fetch(pathToFileURL(file).href);
|
|
34
|
+
});
|
|
35
|
+
return ()=>protocol.unhandle(scheme);
|
|
36
|
+
}
|
|
37
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, registerFederationScheme, resolveAppFile, serveFederatedApps, toAppId };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Electron main-process integration. Build configs should import the URL helpers\n * from `@module-federation/electron/rsbuild` or `/vite` instead: this entry imports `electron`.\n */\nimport { pathToFileURL } from 'node:url';\nimport { net, protocol } from 'electron';\nimport { resolveAppFile } from './resolve.ts';\nimport { DEFAULT_HOST, DEFAULT_SCHEME, toAppId } from './url.ts';\n\nexport { resolveAppFile } from './resolve.ts';\nexport {\n DEFAULT_HOST,\n DEFAULT_SCHEME,\n federationBaseUrl,\n federationUrl,\n toAppId,\n type FederationUrlOptions,\n} from './url.ts';\n\nexport interface RegisterSchemeOptions {\n scheme?: string;\n}\n\n/**\n * Registers the federation scheme as privileged (fetch, CORS, ESM, service workers).\n * Must be called before the `ready` event of `app`.\n */\nexport function registerFederationScheme(options: RegisterSchemeOptions = {}): void {\n protocol.registerSchemesAsPrivileged([\n {\n scheme: options.scheme ?? DEFAULT_SCHEME,\n privileges: {\n standard: true,\n secure: true,\n supportFetchAPI: true,\n corsEnabled: true,\n stream: true,\n codeCache: true,\n },\n },\n ]);\n}\n\nexport interface ServeFederatedAppsOptions {\n scheme?: string;\n host?: string;\n /** Map of federation `name` (or app id) to the directory holding its build output. */\n apps: Record<string, string>;\n}\n\n/**\n * Serves each app's build output on `<scheme>://<host>/<appId>/`.\n * Call after `app.whenReady()`. Returns a function that unregisters the handler.\n */\nexport function serveFederatedApps(options: ServeFederatedAppsOptions): () => void {\n const scheme = options.scheme ?? DEFAULT_SCHEME;\n const host = options.host ?? DEFAULT_HOST;\n const apps = Object.fromEntries(\n Object.entries(options.apps).map(([name, dir]) => [toAppId(name), dir]),\n );\n\n protocol.handle(scheme, async (request) => {\n const url = new URL(request.url);\n const file = url.host === host ? resolveAppFile(url.pathname, apps) : undefined;\n if (!file) return new Response('Not found', { status: 404 });\n return net.fetch(pathToFileURL(file).href);\n });\n\n return () => protocol.unhandle(scheme);\n}\n"],"names":["registerFederationScheme","options","protocol","DEFAULT_SCHEME","serveFederatedApps","scheme","host","DEFAULT_HOST","apps","Object","name","dir","toAppId","request","url","URL","file","resolveAppFile","undefined","Response","net","pathToFileURL"],"mappings":";;;;AA2BO,SAASA,yBAAyBC,UAAiC,CAAC,CAAC;IAC1EC,SAAS,2BAA2B,CAAC;QACnC;YACE,QAAQD,QAAQ,MAAM,IAAIE;YAC1B,YAAY;gBACV,UAAU;gBACV,QAAQ;gBACR,iBAAiB;gBACjB,aAAa;gBACb,QAAQ;gBACR,WAAW;YACb;QACF;KACD;AACH;AAaO,SAASC,mBAAmBH,OAAkC;IACnE,MAAMI,SAASJ,QAAQ,MAAM,IAAIE;IACjC,MAAMG,OAAOL,QAAQ,IAAI,IAAIM;IAC7B,MAAMC,OAAOC,OAAO,WAAW,CAC7BA,OAAO,OAAO,CAACR,QAAQ,IAAI,EAAE,GAAG,CAAC,CAAC,CAACS,MAAMC,IAAI,GAAK;YAACC,QAAQF;YAAOC;SAAI;IAGxET,SAAS,MAAM,CAACG,QAAQ,OAAOQ;QAC7B,MAAMC,MAAM,IAAIC,IAAIF,QAAQ,GAAG;QAC/B,MAAMG,OAAOF,IAAI,IAAI,KAAKR,OAAOW,eAAeH,IAAI,QAAQ,EAAEN,QAAQU;QACtE,IAAI,CAACF,MAAM,OAAO,IAAIG,SAAS,aAAa;YAAE,QAAQ;QAAI;QAC1D,OAAOC,IAAI,KAAK,CAACC,cAAcL,MAAM,IAAI;IAC3C;IAEA,OAAO,IAAMd,SAAS,QAAQ,CAACG;AACjC"}
|
package/dist/resolve.cjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
resolveAppFile: ()=>resolveAppFile
|
|
41
|
+
});
|
|
42
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
43
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
44
|
+
function resolveAppFile(pathname, apps) {
|
|
45
|
+
const [, appId, ...rest] = decodeURIComponent(pathname).split('/');
|
|
46
|
+
if (!appId || !Object.hasOwn(apps, appId)) return;
|
|
47
|
+
const root = external_node_path_default().resolve(apps[appId]);
|
|
48
|
+
const file = external_node_path_default().resolve(root, rest.join('/') || 'index.html');
|
|
49
|
+
if (file !== root && !file.startsWith(root + external_node_path_default().sep)) return;
|
|
50
|
+
return file;
|
|
51
|
+
}
|
|
52
|
+
exports.resolveAppFile = __webpack_exports__.resolveAppFile;
|
|
53
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
54
|
+
"resolveAppFile"
|
|
55
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=resolve.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.cjs","sources":["webpack://webpack/runtime/compat_get_default_export","webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/resolve.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import path from 'node:path';\n\n/**\n * Maps a request pathname (`/<appId>/<file>`) to an absolute file path inside\n * the matching app directory. Returns `undefined` for unknown apps or for paths\n * that would escape the app directory.\n */\nexport function resolveAppFile(\n pathname: string,\n apps: Readonly<Record<string, string>>,\n): string | undefined {\n const [, appId, ...rest] = decodeURIComponent(pathname).split('/');\n if (!appId || !Object.hasOwn(apps, appId)) return undefined;\n\n const root = path.resolve(apps[appId] as string);\n const file = path.resolve(root, rest.join('/') || 'index.html');\n if (file !== root && !file.startsWith(root + path.sep)) return undefined;\n return file;\n}\n"],"names":["__webpack_require__","module","getter","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","resolveAppFile","pathname","apps","appId","rest","decodeURIComponent","root","path","file"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGN,oBAAoB,CAAC,CAACM,MAAME,QAAQ,CAACR,oBAAoB,CAAC,CAAC,UAASQ,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAJ,oBAAoB,CAAC,GAAG,CAACU,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFX,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOY,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;ACCO,SAASI,eACdC,QAAgB,EAChBC,IAAsC;IAEtC,MAAM,GAAGC,OAAO,GAAGC,KAAK,GAAGC,mBAAmBJ,UAAU,KAAK,CAAC;IAC9D,IAAI,CAACE,SAAS,CAACP,OAAO,MAAM,CAACM,MAAMC,QAAQ;IAE3C,MAAMG,OAAOC,6BAAAA,OAAY,CAACL,IAAI,CAACC,MAAM;IACrC,MAAMK,OAAOD,6BAAAA,OAAY,CAACD,MAAMF,KAAK,IAAI,CAAC,QAAQ;IAClD,IAAII,SAASF,QAAQ,CAACE,KAAK,UAAU,CAACF,OAAOC,AAAAA,6BAAAA,GAAQ,GAAG;IACxD,OAAOC;AACT"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a request pathname (`/<appId>/<file>`) to an absolute file path inside
|
|
3
|
+
* the matching app directory. Returns `undefined` for unknown apps or for paths
|
|
4
|
+
* that would escape the app directory.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveAppFile(pathname: string, apps: Readonly<Record<string, string>>): string | undefined;
|
|
7
|
+
//# sourceMappingURL=resolve.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.cts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACrC,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a request pathname (`/<appId>/<file>`) to an absolute file path inside
|
|
3
|
+
* the matching app directory. Returns `undefined` for unknown apps or for paths
|
|
4
|
+
* that would escape the app directory.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveAppFile(pathname: string, apps: Readonly<Record<string, string>>): string | undefined;
|
|
7
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../src/resolve.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACrC,MAAM,GAAG,SAAS,CAQpB"}
|
package/dist/resolve.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import node_path from "node:path";
|
|
2
|
+
function resolveAppFile(pathname, apps) {
|
|
3
|
+
const [, appId, ...rest] = decodeURIComponent(pathname).split('/');
|
|
4
|
+
if (!appId || !Object.hasOwn(apps, appId)) return;
|
|
5
|
+
const root = node_path.resolve(apps[appId]);
|
|
6
|
+
const file = node_path.resolve(root, rest.join('/') || 'index.html');
|
|
7
|
+
if (file !== root && !file.startsWith(root + node_path.sep)) return;
|
|
8
|
+
return file;
|
|
9
|
+
}
|
|
10
|
+
export { resolveAppFile };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sources":["../src/resolve.ts"],"sourcesContent":["import path from 'node:path';\n\n/**\n * Maps a request pathname (`/<appId>/<file>`) to an absolute file path inside\n * the matching app directory. Returns `undefined` for unknown apps or for paths\n * that would escape the app directory.\n */\nexport function resolveAppFile(\n pathname: string,\n apps: Readonly<Record<string, string>>,\n): string | undefined {\n const [, appId, ...rest] = decodeURIComponent(pathname).split('/');\n if (!appId || !Object.hasOwn(apps, appId)) return undefined;\n\n const root = path.resolve(apps[appId] as string);\n const file = path.resolve(root, rest.join('/') || 'index.html');\n if (file !== root && !file.startsWith(root + path.sep)) return undefined;\n return file;\n}\n"],"names":["resolveAppFile","pathname","apps","appId","rest","decodeURIComponent","Object","root","path","file"],"mappings":";AAOO,SAASA,eACdC,QAAgB,EAChBC,IAAsC;IAEtC,MAAM,GAAGC,OAAO,GAAGC,KAAK,GAAGC,mBAAmBJ,UAAU,KAAK,CAAC;IAC9D,IAAI,CAACE,SAAS,CAACG,OAAO,MAAM,CAACJ,MAAMC,QAAQ;IAE3C,MAAMI,OAAOC,UAAAA,OAAY,CAACN,IAAI,CAACC,MAAM;IACrC,MAAMM,OAAOD,UAAAA,OAAY,CAACD,MAAMH,KAAK,IAAI,CAAC,QAAQ;IAClD,IAAIK,SAASF,QAAQ,CAACE,KAAK,UAAU,CAACF,OAAOC,UAAAA,GAAQ,GAAG;IACxD,OAAOC;AACT"}
|
package/dist/rsbuild.cjs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
DEFAULT_HOST: ()=>external_url_cjs_namespaceObject.DEFAULT_HOST,
|
|
32
|
+
DEFAULT_SCHEME: ()=>external_url_cjs_namespaceObject.DEFAULT_SCHEME,
|
|
33
|
+
PLUGIN_ELECTRON_NAME: ()=>PLUGIN_ELECTRON_NAME,
|
|
34
|
+
federationBaseUrl: ()=>external_url_cjs_namespaceObject.federationBaseUrl,
|
|
35
|
+
federationUrl: ()=>external_url_cjs_namespaceObject.federationUrl,
|
|
36
|
+
pluginElectron: ()=>pluginElectron,
|
|
37
|
+
pluginModuleFederationElectron: ()=>pluginModuleFederationElectron,
|
|
38
|
+
toAppId: ()=>external_url_cjs_namespaceObject.toAppId
|
|
39
|
+
});
|
|
40
|
+
const rsbuild_plugin_namespaceObject = require("@module-federation/rsbuild-plugin");
|
|
41
|
+
const external_url_cjs_namespaceObject = require("./url.cjs");
|
|
42
|
+
const PLUGIN_ELECTRON_NAME = '@module-federation/electron:rsbuild';
|
|
43
|
+
function pluginElectron(name, options = {}) {
|
|
44
|
+
const { protocol = true, ...urlOptions } = options;
|
|
45
|
+
return {
|
|
46
|
+
name: PLUGIN_ELECTRON_NAME,
|
|
47
|
+
setup (api) {
|
|
48
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
49
|
+
if (!protocol || 'build' !== api.context.action) return config;
|
|
50
|
+
if (api.getRsbuildConfig('original').output?.assetPrefix !== void 0) return config;
|
|
51
|
+
return mergeRsbuildConfig(config, {
|
|
52
|
+
output: {
|
|
53
|
+
assetPrefix: (0, external_url_cjs_namespaceObject.federationBaseUrl)(name, urlOptions)
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function pluginModuleFederationElectron(federation, options = {}) {
|
|
61
|
+
if (!federation.name) throw new Error('[@module-federation/electron] `name` is required');
|
|
62
|
+
return [
|
|
63
|
+
(0, rsbuild_plugin_namespaceObject.pluginModuleFederation)(federation, options.rsbuild),
|
|
64
|
+
pluginElectron(federation.name, options.electron)
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
exports.DEFAULT_HOST = __webpack_exports__.DEFAULT_HOST;
|
|
68
|
+
exports.DEFAULT_SCHEME = __webpack_exports__.DEFAULT_SCHEME;
|
|
69
|
+
exports.PLUGIN_ELECTRON_NAME = __webpack_exports__.PLUGIN_ELECTRON_NAME;
|
|
70
|
+
exports.federationBaseUrl = __webpack_exports__.federationBaseUrl;
|
|
71
|
+
exports.federationUrl = __webpack_exports__.federationUrl;
|
|
72
|
+
exports.pluginElectron = __webpack_exports__.pluginElectron;
|
|
73
|
+
exports.pluginModuleFederationElectron = __webpack_exports__.pluginModuleFederationElectron;
|
|
74
|
+
exports.toAppId = __webpack_exports__.toAppId;
|
|
75
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
76
|
+
"DEFAULT_HOST",
|
|
77
|
+
"DEFAULT_SCHEME",
|
|
78
|
+
"PLUGIN_ELECTRON_NAME",
|
|
79
|
+
"federationBaseUrl",
|
|
80
|
+
"federationUrl",
|
|
81
|
+
"pluginElectron",
|
|
82
|
+
"pluginModuleFederationElectron",
|
|
83
|
+
"toAppId"
|
|
84
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=rsbuild.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsbuild.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/rsbuild.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import {\n type ModuleFederationOptions,\n pluginModuleFederation,\n} from '@module-federation/rsbuild-plugin';\nimport { type FederationUrlOptions, federationBaseUrl } from './url.ts';\nimport type { RsbuildPlugin, RsbuildPlugins } from '@rsbuild/core';\n\nexport type { ModuleFederationOptions };\nexport {\n DEFAULT_HOST,\n DEFAULT_SCHEME,\n federationBaseUrl,\n federationUrl,\n toAppId,\n type FederationUrlOptions,\n} from './url.ts';\n\nexport const PLUGIN_ELECTRON_NAME = '@module-federation/electron:rsbuild';\n\nexport interface ElectronFederationOptions extends FederationUrlOptions {\n /**\n * Point production asset URLs at the federation protocol\n * (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,\n * e.g. a CDN. An explicit `output.assetPrefix` always wins.\n * @default true\n */\n protocol?: boolean;\n}\n\nexport interface PluginOptions {\n electron?: ElectronFederationOptions;\n /** Passed through to `@module-federation/rsbuild-plugin`. */\n rsbuild?: Parameters<typeof pluginModuleFederation>[1];\n}\n\n/** Electron defaults layered on top of the Module Federation plugin. */\nexport function pluginElectron(\n name: string,\n options: ElectronFederationOptions = {},\n): RsbuildPlugin {\n const { protocol = true, ...urlOptions } = options;\n return {\n name: PLUGIN_ELECTRON_NAME,\n setup(api) {\n api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {\n if (!protocol || api.context.action !== 'build') return config;\n // `config` already has defaults merged in; check what the user actually wrote.\n if (api.getRsbuildConfig('original').output?.assetPrefix !== undefined) return config;\n return mergeRsbuildConfig(config, {\n output: { assetPrefix: federationBaseUrl(name, urlOptions) },\n });\n });\n },\n };\n}\n\n/**\n * Module Federation for an Electron renderer built with Rsbuild.\n *\n * ```ts\n * plugins: [pluginModuleFederationElectron({ name: 'host', remotes: { ... } })]\n * ```\n */\nexport function pluginModuleFederationElectron(\n federation: ModuleFederationOptions,\n options: PluginOptions = {},\n): RsbuildPlugins {\n if (!federation.name) {\n throw new Error('[@module-federation/electron] `name` is required');\n }\n return [\n pluginModuleFederation(federation, options.rsbuild),\n pluginElectron(federation.name, options.electron),\n ];\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","PLUGIN_ELECTRON_NAME","pluginElectron","name","options","protocol","urlOptions","api","config","mergeRsbuildConfig","undefined","federationBaseUrl","pluginModuleFederationElectron","federation","Error","pluginModuleFederation"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;ACWO,MAAMI,uBAAuB;AAmB7B,SAASC,eACdC,IAAY,EACZC,UAAqC,CAAC,CAAC;IAEvC,MAAM,EAAEC,WAAW,IAAI,EAAE,GAAGC,YAAY,GAAGF;IAC3C,OAAO;QACL,MAAMH;QACN,OAAMM,GAAG;YACPA,IAAI,mBAAmB,CAAC,CAACC,QAAQ,EAAEC,kBAAkB,EAAE;gBACrD,IAAI,CAACJ,YAAYE,AAAuB,YAAvBA,IAAI,OAAO,CAAC,MAAM,EAAc,OAAOC;gBAExD,IAAID,IAAI,gBAAgB,CAAC,YAAY,MAAM,EAAE,gBAAgBG,QAAW,OAAOF;gBAC/E,OAAOC,mBAAmBD,QAAQ;oBAChC,QAAQ;wBAAE,aAAaG,AAAAA,IAAAA,iCAAAA,iBAAAA,AAAAA,EAAkBR,MAAMG;oBAAY;gBAC7D;YACF;QACF;IACF;AACF;AASO,SAASM,+BACdC,UAAmC,EACnCT,UAAyB,CAAC,CAAC;IAE3B,IAAI,CAACS,WAAW,IAAI,EAClB,MAAM,IAAIC,MAAM;IAElB,OAAO;QACLC,IAAAA,+BAAAA,sBAAAA,AAAAA,EAAuBF,YAAYT,QAAQ,OAAO;QAClDF,eAAeW,WAAW,IAAI,EAAET,QAAQ,QAAQ;KACjD;AACH"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ModuleFederationOptions, pluginModuleFederation } from '@module-federation/rsbuild-plugin';
|
|
2
|
+
import { type FederationUrlOptions } from './url.cjs';
|
|
3
|
+
import type { RsbuildPlugin, RsbuildPlugins } from '@rsbuild/core';
|
|
4
|
+
export type { ModuleFederationOptions };
|
|
5
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId, type FederationUrlOptions, } from './url.cjs';
|
|
6
|
+
export declare const PLUGIN_ELECTRON_NAME = "@module-federation/electron:rsbuild";
|
|
7
|
+
export interface ElectronFederationOptions extends FederationUrlOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Point production asset URLs at the federation protocol
|
|
10
|
+
* (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,
|
|
11
|
+
* e.g. a CDN. An explicit `output.assetPrefix` always wins.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
protocol?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginOptions {
|
|
17
|
+
electron?: ElectronFederationOptions;
|
|
18
|
+
/** Passed through to `@module-federation/rsbuild-plugin`. */
|
|
19
|
+
rsbuild?: Parameters<typeof pluginModuleFederation>[1];
|
|
20
|
+
}
|
|
21
|
+
/** Electron defaults layered on top of the Module Federation plugin. */
|
|
22
|
+
export declare function pluginElectron(name: string, options?: ElectronFederationOptions): RsbuildPlugin;
|
|
23
|
+
/**
|
|
24
|
+
* Module Federation for an Electron renderer built with Rsbuild.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* plugins: [pluginModuleFederationElectron({ name: 'host', remotes: { ... } })]
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function pluginModuleFederationElectron(federation: ModuleFederationOptions, options?: PluginOptions): RsbuildPlugins;
|
|
31
|
+
//# sourceMappingURL=rsbuild.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsbuild.d.cts","sourceRoot":"","sources":["../src/rsbuild.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEnE,YAAY,EAAE,uBAAuB,EAAE,CAAC;AACxC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,oBAAoB,wCAAwC,CAAC;AAE1E,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;CACxD;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,yBAA8B,GACtC,aAAa,CAef;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,aAAkB,GAC1B,cAAc,CAQhB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ModuleFederationOptions, pluginModuleFederation } from '@module-federation/rsbuild-plugin';
|
|
2
|
+
import { type FederationUrlOptions } from './url.js';
|
|
3
|
+
import type { RsbuildPlugin, RsbuildPlugins } from '@rsbuild/core';
|
|
4
|
+
export type { ModuleFederationOptions };
|
|
5
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId, type FederationUrlOptions, } from './url.js';
|
|
6
|
+
export declare const PLUGIN_ELECTRON_NAME = "@module-federation/electron:rsbuild";
|
|
7
|
+
export interface ElectronFederationOptions extends FederationUrlOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Point production asset URLs at the federation protocol
|
|
10
|
+
* (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,
|
|
11
|
+
* e.g. a CDN. An explicit `output.assetPrefix` always wins.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
protocol?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginOptions {
|
|
17
|
+
electron?: ElectronFederationOptions;
|
|
18
|
+
/** Passed through to `@module-federation/rsbuild-plugin`. */
|
|
19
|
+
rsbuild?: Parameters<typeof pluginModuleFederation>[1];
|
|
20
|
+
}
|
|
21
|
+
/** Electron defaults layered on top of the Module Federation plugin. */
|
|
22
|
+
export declare function pluginElectron(name: string, options?: ElectronFederationOptions): RsbuildPlugin;
|
|
23
|
+
/**
|
|
24
|
+
* Module Federation for an Electron renderer built with Rsbuild.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* plugins: [pluginModuleFederationElectron({ name: 'host', remotes: { ... } })]
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function pluginModuleFederationElectron(federation: ModuleFederationOptions, options?: PluginOptions): RsbuildPlugins;
|
|
31
|
+
//# sourceMappingURL=rsbuild.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsbuild.d.ts","sourceRoot":"","sources":["../src/rsbuild.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,uBAAuB,EAC5B,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEnE,YAAY,EAAE,uBAAuB,EAAE,CAAC;AACxC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,oBAAoB,wCAAwC,CAAC;AAE1E,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,yBAAyB,CAAC;IACrC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;CACxD;AAED,wEAAwE;AACxE,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,yBAA8B,GACtC,aAAa,CAef;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,uBAAuB,EACnC,OAAO,GAAE,aAAkB,GAC1B,cAAc,CAQhB"}
|
package/dist/rsbuild.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { pluginModuleFederation } from "@module-federation/rsbuild-plugin";
|
|
2
|
+
import { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId } from "./url.js";
|
|
3
|
+
const PLUGIN_ELECTRON_NAME = '@module-federation/electron:rsbuild';
|
|
4
|
+
function pluginElectron(name, options = {}) {
|
|
5
|
+
const { protocol = true, ...urlOptions } = options;
|
|
6
|
+
return {
|
|
7
|
+
name: PLUGIN_ELECTRON_NAME,
|
|
8
|
+
setup (api) {
|
|
9
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>{
|
|
10
|
+
if (!protocol || 'build' !== api.context.action) return config;
|
|
11
|
+
if (api.getRsbuildConfig('original').output?.assetPrefix !== void 0) return config;
|
|
12
|
+
return mergeRsbuildConfig(config, {
|
|
13
|
+
output: {
|
|
14
|
+
assetPrefix: federationBaseUrl(name, urlOptions)
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function pluginModuleFederationElectron(federation, options = {}) {
|
|
22
|
+
if (!federation.name) throw new Error('[@module-federation/electron] `name` is required');
|
|
23
|
+
return [
|
|
24
|
+
pluginModuleFederation(federation, options.rsbuild),
|
|
25
|
+
pluginElectron(federation.name, options.electron)
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, PLUGIN_ELECTRON_NAME, federationBaseUrl, federationUrl, pluginElectron, pluginModuleFederationElectron, toAppId };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=rsbuild.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rsbuild.js","sources":["../src/rsbuild.ts"],"sourcesContent":["import {\n type ModuleFederationOptions,\n pluginModuleFederation,\n} from '@module-federation/rsbuild-plugin';\nimport { type FederationUrlOptions, federationBaseUrl } from './url.ts';\nimport type { RsbuildPlugin, RsbuildPlugins } from '@rsbuild/core';\n\nexport type { ModuleFederationOptions };\nexport {\n DEFAULT_HOST,\n DEFAULT_SCHEME,\n federationBaseUrl,\n federationUrl,\n toAppId,\n type FederationUrlOptions,\n} from './url.ts';\n\nexport const PLUGIN_ELECTRON_NAME = '@module-federation/electron:rsbuild';\n\nexport interface ElectronFederationOptions extends FederationUrlOptions {\n /**\n * Point production asset URLs at the federation protocol\n * (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,\n * e.g. a CDN. An explicit `output.assetPrefix` always wins.\n * @default true\n */\n protocol?: boolean;\n}\n\nexport interface PluginOptions {\n electron?: ElectronFederationOptions;\n /** Passed through to `@module-federation/rsbuild-plugin`. */\n rsbuild?: Parameters<typeof pluginModuleFederation>[1];\n}\n\n/** Electron defaults layered on top of the Module Federation plugin. */\nexport function pluginElectron(\n name: string,\n options: ElectronFederationOptions = {},\n): RsbuildPlugin {\n const { protocol = true, ...urlOptions } = options;\n return {\n name: PLUGIN_ELECTRON_NAME,\n setup(api) {\n api.modifyRsbuildConfig((config, { mergeRsbuildConfig }) => {\n if (!protocol || api.context.action !== 'build') return config;\n // `config` already has defaults merged in; check what the user actually wrote.\n if (api.getRsbuildConfig('original').output?.assetPrefix !== undefined) return config;\n return mergeRsbuildConfig(config, {\n output: { assetPrefix: federationBaseUrl(name, urlOptions) },\n });\n });\n },\n };\n}\n\n/**\n * Module Federation for an Electron renderer built with Rsbuild.\n *\n * ```ts\n * plugins: [pluginModuleFederationElectron({ name: 'host', remotes: { ... } })]\n * ```\n */\nexport function pluginModuleFederationElectron(\n federation: ModuleFederationOptions,\n options: PluginOptions = {},\n): RsbuildPlugins {\n if (!federation.name) {\n throw new Error('[@module-federation/electron] `name` is required');\n }\n return [\n pluginModuleFederation(federation, options.rsbuild),\n pluginElectron(federation.name, options.electron),\n ];\n}\n"],"names":["PLUGIN_ELECTRON_NAME","pluginElectron","name","options","protocol","urlOptions","api","config","mergeRsbuildConfig","undefined","federationBaseUrl","pluginModuleFederationElectron","federation","Error","pluginModuleFederation"],"mappings":";;AAiBO,MAAMA,uBAAuB;AAmB7B,SAASC,eACdC,IAAY,EACZC,UAAqC,CAAC,CAAC;IAEvC,MAAM,EAAEC,WAAW,IAAI,EAAE,GAAGC,YAAY,GAAGF;IAC3C,OAAO;QACL,MAAMH;QACN,OAAMM,GAAG;YACPA,IAAI,mBAAmB,CAAC,CAACC,QAAQ,EAAEC,kBAAkB,EAAE;gBACrD,IAAI,CAACJ,YAAYE,AAAuB,YAAvBA,IAAI,OAAO,CAAC,MAAM,EAAc,OAAOC;gBAExD,IAAID,IAAI,gBAAgB,CAAC,YAAY,MAAM,EAAE,gBAAgBG,QAAW,OAAOF;gBAC/E,OAAOC,mBAAmBD,QAAQ;oBAChC,QAAQ;wBAAE,aAAaG,kBAAkBR,MAAMG;oBAAY;gBAC7D;YACF;QACF;IACF;AACF;AASO,SAASM,+BACdC,UAAmC,EACnCT,UAAyB,CAAC,CAAC;IAE3B,IAAI,CAACS,WAAW,IAAI,EAClB,MAAM,IAAIC,MAAM;IAElB,OAAO;QACLC,uBAAuBF,YAAYT,QAAQ,OAAO;QAClDF,eAAeW,WAAW,IAAI,EAAET,QAAQ,QAAQ;KACjD;AACH"}
|
package/dist/url.cjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const DEFAULT_SCHEME = 'mf';
|
|
31
|
+
const DEFAULT_HOST = 'local';
|
|
32
|
+
function toAppId(name) {
|
|
33
|
+
const id = name.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
34
|
+
if (!id) throw new Error(`Cannot derive an app id from federation name "${name}"`);
|
|
35
|
+
return id;
|
|
36
|
+
}
|
|
37
|
+
function federationBaseUrl(name, options = {}) {
|
|
38
|
+
const { scheme = DEFAULT_SCHEME, host = DEFAULT_HOST } = options;
|
|
39
|
+
return `${scheme}://${host}/${toAppId(name)}/`;
|
|
40
|
+
}
|
|
41
|
+
function federationUrl(name, file, options = {}) {
|
|
42
|
+
return new URL(file.replace(/^\/+/, ''), federationBaseUrl(name, options)).href;
|
|
43
|
+
}
|
|
44
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
45
|
+
DEFAULT_HOST: DEFAULT_HOST,
|
|
46
|
+
DEFAULT_SCHEME: DEFAULT_SCHEME,
|
|
47
|
+
federationBaseUrl: federationBaseUrl,
|
|
48
|
+
federationUrl: federationUrl,
|
|
49
|
+
toAppId: toAppId
|
|
50
|
+
});
|
|
51
|
+
exports.DEFAULT_HOST = __webpack_exports__.DEFAULT_HOST;
|
|
52
|
+
exports.DEFAULT_SCHEME = __webpack_exports__.DEFAULT_SCHEME;
|
|
53
|
+
exports.federationBaseUrl = __webpack_exports__.federationBaseUrl;
|
|
54
|
+
exports.federationUrl = __webpack_exports__.federationUrl;
|
|
55
|
+
exports.toAppId = __webpack_exports__.toAppId;
|
|
56
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
57
|
+
"DEFAULT_HOST",
|
|
58
|
+
"DEFAULT_SCHEME",
|
|
59
|
+
"federationBaseUrl",
|
|
60
|
+
"federationUrl",
|
|
61
|
+
"toAppId"
|
|
62
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
63
|
+
Object.defineProperty(exports, '__esModule', {
|
|
64
|
+
value: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=url.cjs.map
|
package/dist/url.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/url.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * URL helpers shared by the main process and the bundler plugins. Must not import\n * `electron`: `./rsbuild` and `./vite` re-export these for use in build configs.\n */\n\n/** Default custom protocol scheme used to serve federated bundles inside Electron. */\nexport const DEFAULT_SCHEME = 'mf';\n\n/** Default host for the custom protocol. Every app shares it, so they share one origin. */\nexport const DEFAULT_HOST = 'local';\n\nexport interface FederationUrlOptions {\n scheme?: string;\n host?: string;\n}\n\n/**\n * Turns a Module Federation `name` (e.g. `remote_vite`) into the path segment\n * used on the custom protocol (e.g. `remote-vite`).\n */\nexport function toAppId(name: string): string {\n const id = name\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, '-')\n .replace(/^-+|-+$/g, '');\n if (!id) throw new Error(`Cannot derive an app id from federation name \"${name}\"`);\n return id;\n}\n\n/** Base URL an app is served from in production, e.g. `mf://local/remote-vite/`. */\nexport function federationBaseUrl(name: string, options: FederationUrlOptions = {}): string {\n const { scheme = DEFAULT_SCHEME, host = DEFAULT_HOST } = options;\n return `${scheme}://${host}/${toAppId(name)}/`;\n}\n\n/** URL of a file inside an app, e.g. `federationUrl('remote_vite', 'remoteEntry.js')`. */\nexport function federationUrl(\n name: string,\n file: string,\n options: FederationUrlOptions = {},\n): string {\n return new URL(file.replace(/^\\/+/, ''), federationBaseUrl(name, options)).href;\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","DEFAULT_SCHEME","DEFAULT_HOST","toAppId","name","id","Error","federationBaseUrl","options","scheme","host","federationUrl","file","URL"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;ACAO,MAAMI,iBAAiB;AAGvB,MAAMC,eAAe;AAWrB,SAASC,QAAQC,IAAY;IAClC,MAAMC,KAAKD,KACR,WAAW,GACX,OAAO,CAAC,gBAAgB,KACxB,OAAO,CAAC,YAAY;IACvB,IAAI,CAACC,IAAI,MAAM,IAAIC,MAAM,CAAC,8CAA8C,EAAEF,KAAK,CAAC,CAAC;IACjF,OAAOC;AACT;AAGO,SAASE,kBAAkBH,IAAY,EAAEI,UAAgC,CAAC,CAAC;IAChF,MAAM,EAAEC,SAASR,cAAc,EAAES,OAAOR,YAAY,EAAE,GAAGM;IACzD,OAAO,GAAGC,OAAO,GAAG,EAAEC,KAAK,CAAC,EAAEP,QAAQC,MAAM,CAAC,CAAC;AAChD;AAGO,SAASO,cACdP,IAAY,EACZQ,IAAY,EACZJ,UAAgC,CAAC,CAAC;IAElC,OAAO,IAAIK,IAAID,KAAK,OAAO,CAAC,QAAQ,KAAKL,kBAAkBH,MAAMI,UAAU,IAAI;AACjF"}
|
package/dist/url.d.cts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL helpers shared by the main process and the bundler plugins. Must not import
|
|
3
|
+
* `electron`: `./rsbuild` and `./vite` re-export these for use in build configs.
|
|
4
|
+
*/
|
|
5
|
+
/** Default custom protocol scheme used to serve federated bundles inside Electron. */
|
|
6
|
+
export declare const DEFAULT_SCHEME = "mf";
|
|
7
|
+
/** Default host for the custom protocol. Every app shares it, so they share one origin. */
|
|
8
|
+
export declare const DEFAULT_HOST = "local";
|
|
9
|
+
export interface FederationUrlOptions {
|
|
10
|
+
scheme?: string;
|
|
11
|
+
host?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Turns a Module Federation `name` (e.g. `remote_vite`) into the path segment
|
|
15
|
+
* used on the custom protocol (e.g. `remote-vite`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function toAppId(name: string): string;
|
|
18
|
+
/** Base URL an app is served from in production, e.g. `mf://local/remote-vite/`. */
|
|
19
|
+
export declare function federationBaseUrl(name: string, options?: FederationUrlOptions): string;
|
|
20
|
+
/** URL of a file inside an app, e.g. `federationUrl('remote_vite', 'remoteEntry.js')`. */
|
|
21
|
+
export declare function federationUrl(name: string, file: string, options?: FederationUrlOptions): string;
|
|
22
|
+
//# sourceMappingURL=url.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.cts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sFAAsF;AACtF,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,2FAA2F;AAC3F,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAG1F;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAER"}
|
package/dist/url.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL helpers shared by the main process and the bundler plugins. Must not import
|
|
3
|
+
* `electron`: `./rsbuild` and `./vite` re-export these for use in build configs.
|
|
4
|
+
*/
|
|
5
|
+
/** Default custom protocol scheme used to serve federated bundles inside Electron. */
|
|
6
|
+
export declare const DEFAULT_SCHEME = "mf";
|
|
7
|
+
/** Default host for the custom protocol. Every app shares it, so they share one origin. */
|
|
8
|
+
export declare const DEFAULT_HOST = "local";
|
|
9
|
+
export interface FederationUrlOptions {
|
|
10
|
+
scheme?: string;
|
|
11
|
+
host?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Turns a Module Federation `name` (e.g. `remote_vite`) into the path segment
|
|
15
|
+
* used on the custom protocol (e.g. `remote-vite`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function toAppId(name: string): string;
|
|
18
|
+
/** Base URL an app is served from in production, e.g. `mf://local/remote-vite/`. */
|
|
19
|
+
export declare function federationBaseUrl(name: string, options?: FederationUrlOptions): string;
|
|
20
|
+
/** URL of a file inside an app, e.g. `federationUrl('remote_vite', 'remoteEntry.js')`. */
|
|
21
|
+
export declare function federationUrl(name: string, file: string, options?: FederationUrlOptions): string;
|
|
22
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sFAAsF;AACtF,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,2FAA2F;AAC3F,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAG1F;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,oBAAyB,GACjC,MAAM,CAER"}
|
package/dist/url.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const DEFAULT_SCHEME = 'mf';
|
|
2
|
+
const DEFAULT_HOST = 'local';
|
|
3
|
+
function toAppId(name) {
|
|
4
|
+
const id = name.toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
5
|
+
if (!id) throw new Error(`Cannot derive an app id from federation name "${name}"`);
|
|
6
|
+
return id;
|
|
7
|
+
}
|
|
8
|
+
function federationBaseUrl(name, options = {}) {
|
|
9
|
+
const { scheme = DEFAULT_SCHEME, host = DEFAULT_HOST } = options;
|
|
10
|
+
return `${scheme}://${host}/${toAppId(name)}/`;
|
|
11
|
+
}
|
|
12
|
+
function federationUrl(name, file, options = {}) {
|
|
13
|
+
return new URL(file.replace(/^\/+/, ''), federationBaseUrl(name, options)).href;
|
|
14
|
+
}
|
|
15
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=url.js.map
|
package/dist/url.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sources":["../src/url.ts"],"sourcesContent":["/**\n * URL helpers shared by the main process and the bundler plugins. Must not import\n * `electron`: `./rsbuild` and `./vite` re-export these for use in build configs.\n */\n\n/** Default custom protocol scheme used to serve federated bundles inside Electron. */\nexport const DEFAULT_SCHEME = 'mf';\n\n/** Default host for the custom protocol. Every app shares it, so they share one origin. */\nexport const DEFAULT_HOST = 'local';\n\nexport interface FederationUrlOptions {\n scheme?: string;\n host?: string;\n}\n\n/**\n * Turns a Module Federation `name` (e.g. `remote_vite`) into the path segment\n * used on the custom protocol (e.g. `remote-vite`).\n */\nexport function toAppId(name: string): string {\n const id = name\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, '-')\n .replace(/^-+|-+$/g, '');\n if (!id) throw new Error(`Cannot derive an app id from federation name \"${name}\"`);\n return id;\n}\n\n/** Base URL an app is served from in production, e.g. `mf://local/remote-vite/`. */\nexport function federationBaseUrl(name: string, options: FederationUrlOptions = {}): string {\n const { scheme = DEFAULT_SCHEME, host = DEFAULT_HOST } = options;\n return `${scheme}://${host}/${toAppId(name)}/`;\n}\n\n/** URL of a file inside an app, e.g. `federationUrl('remote_vite', 'remoteEntry.js')`. */\nexport function federationUrl(\n name: string,\n file: string,\n options: FederationUrlOptions = {},\n): string {\n return new URL(file.replace(/^\\/+/, ''), federationBaseUrl(name, options)).href;\n}\n"],"names":["DEFAULT_SCHEME","DEFAULT_HOST","toAppId","name","id","Error","federationBaseUrl","options","scheme","host","federationUrl","file","URL"],"mappings":"AAMO,MAAMA,iBAAiB;AAGvB,MAAMC,eAAe;AAWrB,SAASC,QAAQC,IAAY;IAClC,MAAMC,KAAKD,KACR,WAAW,GACX,OAAO,CAAC,gBAAgB,KACxB,OAAO,CAAC,YAAY;IACvB,IAAI,CAACC,IAAI,MAAM,IAAIC,MAAM,CAAC,8CAA8C,EAAEF,KAAK,CAAC,CAAC;IACjF,OAAOC;AACT;AAGO,SAASE,kBAAkBH,IAAY,EAAEI,UAAgC,CAAC,CAAC;IAChF,MAAM,EAAEC,SAASR,cAAc,EAAES,OAAOR,YAAY,EAAE,GAAGM;IACzD,OAAO,GAAGC,OAAO,GAAG,EAAEC,KAAK,CAAC,EAAEP,QAAQC,MAAM,CAAC,CAAC;AAChD;AAGO,SAASO,cACdP,IAAY,EACZQ,IAAY,EACZJ,UAAgC,CAAC,CAAC;IAElC,OAAO,IAAIK,IAAID,KAAK,OAAO,CAAC,QAAQ,KAAKL,kBAAkBH,MAAMI,UAAU,IAAI;AACjF"}
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
DEFAULT_HOST: ()=>external_url_cjs_namespaceObject.DEFAULT_HOST,
|
|
32
|
+
DEFAULT_SCHEME: ()=>external_url_cjs_namespaceObject.DEFAULT_SCHEME,
|
|
33
|
+
PLUGIN_ELECTRON_NAME: ()=>PLUGIN_ELECTRON_NAME,
|
|
34
|
+
electron: ()=>electron,
|
|
35
|
+
federationBaseUrl: ()=>external_url_cjs_namespaceObject.federationBaseUrl,
|
|
36
|
+
federationElectron: ()=>federationElectron,
|
|
37
|
+
federationUrl: ()=>external_url_cjs_namespaceObject.federationUrl,
|
|
38
|
+
toAppId: ()=>external_url_cjs_namespaceObject.toAppId
|
|
39
|
+
});
|
|
40
|
+
const vite_namespaceObject = require("@module-federation/vite");
|
|
41
|
+
const external_url_cjs_namespaceObject = require("./url.cjs");
|
|
42
|
+
const PLUGIN_ELECTRON_NAME = '@module-federation/electron:vite';
|
|
43
|
+
function electron(name, options = {}) {
|
|
44
|
+
const { protocol = true, ...urlOptions } = options;
|
|
45
|
+
return {
|
|
46
|
+
name: PLUGIN_ELECTRON_NAME,
|
|
47
|
+
config (config, { command }) {
|
|
48
|
+
if (!protocol || 'build' !== command || void 0 !== config.base) return;
|
|
49
|
+
return {
|
|
50
|
+
base: (0, external_url_cjs_namespaceObject.federationBaseUrl)(name, urlOptions)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function federationElectron(options, pluginOptions = {}) {
|
|
56
|
+
if (!options.name) throw new Error('[@module-federation/electron] `name` is required');
|
|
57
|
+
return [
|
|
58
|
+
...(0, vite_namespaceObject.federation)(options),
|
|
59
|
+
electron(options.name, pluginOptions.electron)
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
exports.DEFAULT_HOST = __webpack_exports__.DEFAULT_HOST;
|
|
63
|
+
exports.DEFAULT_SCHEME = __webpack_exports__.DEFAULT_SCHEME;
|
|
64
|
+
exports.PLUGIN_ELECTRON_NAME = __webpack_exports__.PLUGIN_ELECTRON_NAME;
|
|
65
|
+
exports.electron = __webpack_exports__.electron;
|
|
66
|
+
exports.federationBaseUrl = __webpack_exports__.federationBaseUrl;
|
|
67
|
+
exports.federationElectron = __webpack_exports__.federationElectron;
|
|
68
|
+
exports.federationUrl = __webpack_exports__.federationUrl;
|
|
69
|
+
exports.toAppId = __webpack_exports__.toAppId;
|
|
70
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
71
|
+
"DEFAULT_HOST",
|
|
72
|
+
"DEFAULT_SCHEME",
|
|
73
|
+
"PLUGIN_ELECTRON_NAME",
|
|
74
|
+
"electron",
|
|
75
|
+
"federationBaseUrl",
|
|
76
|
+
"federationElectron",
|
|
77
|
+
"federationUrl",
|
|
78
|
+
"toAppId"
|
|
79
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
80
|
+
Object.defineProperty(exports, '__esModule', {
|
|
81
|
+
value: true
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=vite.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.cjs","sources":["webpack://webpack/runtime/define_property_getters","webpack://webpack/runtime/has_own_property","webpack://webpack/runtime/make_namespace_object","../src/vite.ts"],"sourcesContent":["__webpack_require__.d = (exports, getters, values) => {\n\tvar define = (defs, kind) => {\n\t\tfor(var key in defs) {\n\t\t\tif(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {\n\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });\n\t\t\t}\n\t\t}\n\t};\n\tdefine(getters, \"get\");\n\tdefine(values, \"value\");\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { federation, type ModuleFederationOptions } from '@module-federation/vite';\nimport { type FederationUrlOptions, federationBaseUrl } from './url.ts';\nimport type { Plugin, PluginOption } from 'vite';\n\nexport type { ModuleFederationOptions };\nexport {\n DEFAULT_HOST,\n DEFAULT_SCHEME,\n federationBaseUrl,\n federationUrl,\n toAppId,\n type FederationUrlOptions,\n} from './url.ts';\n\nexport const PLUGIN_ELECTRON_NAME = '@module-federation/electron:vite';\n\nexport interface ElectronFederationOptions extends FederationUrlOptions {\n /**\n * Point production asset URLs at the federation protocol\n * (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,\n * e.g. a CDN. An explicit `base` always wins.\n * @default true\n */\n protocol?: boolean;\n}\n\nexport interface PluginOptions {\n electron?: ElectronFederationOptions;\n}\n\n/** Electron defaults layered on top of the Module Federation plugin. */\nexport function electron(name: string, options: ElectronFederationOptions = {}): Plugin {\n const { protocol = true, ...urlOptions } = options;\n return {\n name: PLUGIN_ELECTRON_NAME,\n config(config, { command }) {\n if (!protocol || command !== 'build' || config.base !== undefined) return;\n return { base: federationBaseUrl(name, urlOptions) };\n },\n };\n}\n\n/**\n * Module Federation for an Electron renderer built with Vite.\n *\n * ```ts\n * plugins: [federationElectron({ name: 'host', remotes: { ... } })]\n * ```\n */\nexport function federationElectron(\n options: ModuleFederationOptions,\n pluginOptions: PluginOptions = {},\n): PluginOption[] {\n if (!options.name) {\n throw new Error('[@module-federation/electron] `name` is required');\n }\n return [...federation(options), electron(options.name, pluginOptions.electron)];\n}\n"],"names":["__webpack_require__","getters","values","define","defs","kind","key","Object","obj","prop","Symbol","PLUGIN_ELECTRON_NAME","electron","name","options","protocol","urlOptions","config","command","undefined","federationBaseUrl","federationElectron","pluginOptions","Error","federation"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC,SAASC;QAC1C,IAAIC,SAAS,CAACC,MAAMC;YACnB,IAAI,IAAIC,OAAOF,KACd,IAAGJ,oBAAoB,CAAC,CAACI,MAAME,QAAQ,CAACN,oBAAoB,CAAC,CAAC,UAASM,MACtEC,OAAO,cAAc,CAAC,UAASD,KAAK;gBAAE,YAAY;gBAAM,CAACD,KAAK,EAAED,IAAI,CAACE,IAAI;YAAC;QAG7E;QACAH,OAAOF,SAAS;QAChBE,OAAOD,QAAQ;IAChB;;;ICVAF,oBAAoB,CAAC,GAAG,CAACQ,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFT,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,MAAlB,OAAOU,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;ACQO,MAAMI,uBAAuB;AAiB7B,SAASC,SAASC,IAAY,EAAEC,UAAqC,CAAC,CAAC;IAC5E,MAAM,EAAEC,WAAW,IAAI,EAAE,GAAGC,YAAY,GAAGF;IAC3C,OAAO;QACL,MAAMH;QACN,QAAOM,MAAM,EAAE,EAAEC,OAAO,EAAE;YACxB,IAAI,CAACH,YAAYG,AAAY,YAAZA,WAAuBD,AAAgBE,WAAhBF,OAAO,IAAI,EAAgB;YACnE,OAAO;gBAAE,MAAMG,AAAAA,IAAAA,iCAAAA,iBAAAA,AAAAA,EAAkBP,MAAMG;YAAY;QACrD;IACF;AACF;AASO,SAASK,mBACdP,OAAgC,EAChCQ,gBAA+B,CAAC,CAAC;IAEjC,IAAI,CAACR,QAAQ,IAAI,EACf,MAAM,IAAIS,MAAM;IAElB,OAAO;WAAIC,AAAAA,IAAAA,qBAAAA,UAAAA,AAAAA,EAAWV;QAAUF,SAASE,QAAQ,IAAI,EAAEQ,cAAc,QAAQ;KAAE;AACjF"}
|
package/dist/vite.d.cts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ModuleFederationOptions } from '@module-federation/vite';
|
|
2
|
+
import { type FederationUrlOptions } from './url.cjs';
|
|
3
|
+
import type { Plugin, PluginOption } from 'vite';
|
|
4
|
+
export type { ModuleFederationOptions };
|
|
5
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId, type FederationUrlOptions, } from './url.cjs';
|
|
6
|
+
export declare const PLUGIN_ELECTRON_NAME = "@module-federation/electron:vite";
|
|
7
|
+
export interface ElectronFederationOptions extends FederationUrlOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Point production asset URLs at the federation protocol
|
|
10
|
+
* (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,
|
|
11
|
+
* e.g. a CDN. An explicit `base` always wins.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
protocol?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginOptions {
|
|
17
|
+
electron?: ElectronFederationOptions;
|
|
18
|
+
}
|
|
19
|
+
/** Electron defaults layered on top of the Module Federation plugin. */
|
|
20
|
+
export declare function electron(name: string, options?: ElectronFederationOptions): Plugin;
|
|
21
|
+
/**
|
|
22
|
+
* Module Federation for an Electron renderer built with Vite.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* plugins: [federationElectron({ name: 'host', remotes: { ... } })]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function federationElectron(options: ModuleFederationOptions, pluginOptions?: PluginOptions): PluginOption[];
|
|
29
|
+
//# sourceMappingURL=vite.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.cts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEjD,YAAY,EAAE,uBAAuB,EAAE,CAAC;AACxC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAEvE,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,yBAAyB,CAAC;CACtC;AAED,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B,GAAG,MAAM,CAStF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,uBAAuB,EAChC,aAAa,GAAE,aAAkB,GAChC,YAAY,EAAE,CAKhB"}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ModuleFederationOptions } from '@module-federation/vite';
|
|
2
|
+
import { type FederationUrlOptions } from './url.js';
|
|
3
|
+
import type { Plugin, PluginOption } from 'vite';
|
|
4
|
+
export type { ModuleFederationOptions };
|
|
5
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId, type FederationUrlOptions, } from './url.js';
|
|
6
|
+
export declare const PLUGIN_ELECTRON_NAME = "@module-federation/electron:vite";
|
|
7
|
+
export interface ElectronFederationOptions extends FederationUrlOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Point production asset URLs at the federation protocol
|
|
10
|
+
* (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,
|
|
11
|
+
* e.g. a CDN. An explicit `base` always wins.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
protocol?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface PluginOptions {
|
|
17
|
+
electron?: ElectronFederationOptions;
|
|
18
|
+
}
|
|
19
|
+
/** Electron defaults layered on top of the Module Federation plugin. */
|
|
20
|
+
export declare function electron(name: string, options?: ElectronFederationOptions): Plugin;
|
|
21
|
+
/**
|
|
22
|
+
* Module Federation for an Electron renderer built with Vite.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* plugins: [federationElectron({ name: 'host', remotes: { ... } })]
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function federationElectron(options: ModuleFederationOptions, pluginOptions?: PluginOptions): PluginOption[];
|
|
29
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEjD,YAAY,EAAE,uBAAuB,EAAE,CAAC;AACxC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,OAAO,EACP,KAAK,oBAAoB,GAC1B,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,oBAAoB,qCAAqC,CAAC;AAEvE,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,yBAAyB,CAAC;CACtC;AAED,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B,GAAG,MAAM,CAStF;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,uBAAuB,EAChC,aAAa,GAAE,aAAkB,GAChC,YAAY,EAAE,CAKhB"}
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { federation } from "@module-federation/vite";
|
|
2
|
+
import { DEFAULT_HOST, DEFAULT_SCHEME, federationBaseUrl, federationUrl, toAppId } from "./url.js";
|
|
3
|
+
const PLUGIN_ELECTRON_NAME = '@module-federation/electron:vite';
|
|
4
|
+
function electron(name, options = {}) {
|
|
5
|
+
const { protocol = true, ...urlOptions } = options;
|
|
6
|
+
return {
|
|
7
|
+
name: PLUGIN_ELECTRON_NAME,
|
|
8
|
+
config (config, { command }) {
|
|
9
|
+
if (!protocol || 'build' !== command || void 0 !== config.base) return;
|
|
10
|
+
return {
|
|
11
|
+
base: federationBaseUrl(name, urlOptions)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function federationElectron(options, pluginOptions = {}) {
|
|
17
|
+
if (!options.name) throw new Error('[@module-federation/electron] `name` is required');
|
|
18
|
+
return [
|
|
19
|
+
...federation(options),
|
|
20
|
+
electron(options.name, pluginOptions.electron)
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
export { DEFAULT_HOST, DEFAULT_SCHEME, PLUGIN_ELECTRON_NAME, electron, federationBaseUrl, federationElectron, federationUrl, toAppId };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","sources":["../src/vite.ts"],"sourcesContent":["import { federation, type ModuleFederationOptions } from '@module-federation/vite';\nimport { type FederationUrlOptions, federationBaseUrl } from './url.ts';\nimport type { Plugin, PluginOption } from 'vite';\n\nexport type { ModuleFederationOptions };\nexport {\n DEFAULT_HOST,\n DEFAULT_SCHEME,\n federationBaseUrl,\n federationUrl,\n toAppId,\n type FederationUrlOptions,\n} from './url.ts';\n\nexport const PLUGIN_ELECTRON_NAME = '@module-federation/electron:vite';\n\nexport interface ElectronFederationOptions extends FederationUrlOptions {\n /**\n * Point production asset URLs at the federation protocol\n * (`mf://local/<app-id>/`). Disable when the build is hosted elsewhere,\n * e.g. a CDN. An explicit `base` always wins.\n * @default true\n */\n protocol?: boolean;\n}\n\nexport interface PluginOptions {\n electron?: ElectronFederationOptions;\n}\n\n/** Electron defaults layered on top of the Module Federation plugin. */\nexport function electron(name: string, options: ElectronFederationOptions = {}): Plugin {\n const { protocol = true, ...urlOptions } = options;\n return {\n name: PLUGIN_ELECTRON_NAME,\n config(config, { command }) {\n if (!protocol || command !== 'build' || config.base !== undefined) return;\n return { base: federationBaseUrl(name, urlOptions) };\n },\n };\n}\n\n/**\n * Module Federation for an Electron renderer built with Vite.\n *\n * ```ts\n * plugins: [federationElectron({ name: 'host', remotes: { ... } })]\n * ```\n */\nexport function federationElectron(\n options: ModuleFederationOptions,\n pluginOptions: PluginOptions = {},\n): PluginOption[] {\n if (!options.name) {\n throw new Error('[@module-federation/electron] `name` is required');\n }\n return [...federation(options), electron(options.name, pluginOptions.electron)];\n}\n"],"names":["PLUGIN_ELECTRON_NAME","electron","name","options","protocol","urlOptions","config","command","undefined","federationBaseUrl","federationElectron","pluginOptions","Error","federation"],"mappings":";;AAcO,MAAMA,uBAAuB;AAiB7B,SAASC,SAASC,IAAY,EAAEC,UAAqC,CAAC,CAAC;IAC5E,MAAM,EAAEC,WAAW,IAAI,EAAE,GAAGC,YAAY,GAAGF;IAC3C,OAAO;QACL,MAAMH;QACN,QAAOM,MAAM,EAAE,EAAEC,OAAO,EAAE;YACxB,IAAI,CAACH,YAAYG,AAAY,YAAZA,WAAuBD,AAAgBE,WAAhBF,OAAO,IAAI,EAAgB;YACnE,OAAO;gBAAE,MAAMG,kBAAkBP,MAAMG;YAAY;QACrD;IACF;AACF;AASO,SAASK,mBACdP,OAAgC,EAChCQ,gBAA+B,CAAC,CAAC;IAEjC,IAAI,CAACR,QAAQ,IAAI,EACf,MAAM,IAAIS,MAAM;IAElB,OAAO;WAAIC,WAAWV;QAAUF,SAASE,QAAQ,IAAI,EAAEQ,cAAc,QAAQ;KAAE;AACjF"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/electron",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Module Federation for Electron renderers built with Rsbuild or Vite",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"electron",
|
|
7
|
+
"micro-frontends",
|
|
8
|
+
"module-federation",
|
|
9
|
+
"rsbuild",
|
|
10
|
+
"vite"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/module-federation/electron#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/module-federation/electron/issues"
|
|
15
|
+
},
|
|
6
16
|
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/module-federation/electron.git",
|
|
20
|
+
"directory": "packages/electron"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**/*",
|
|
24
|
+
"README.md",
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"LICENSE"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
7
29
|
"sideEffects": false,
|
|
8
30
|
"main": "./dist/index.cjs",
|
|
9
31
|
"module": "./dist/index.js",
|
|
@@ -19,39 +41,76 @@
|
|
|
19
41
|
"default": "./dist/index.cjs"
|
|
20
42
|
}
|
|
21
43
|
},
|
|
44
|
+
"./rsbuild": {
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/rsbuild.d.ts",
|
|
47
|
+
"default": "./dist/rsbuild.js"
|
|
48
|
+
},
|
|
49
|
+
"require": {
|
|
50
|
+
"types": "./dist/rsbuild.d.cts",
|
|
51
|
+
"default": "./dist/rsbuild.cjs"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"./vite": {
|
|
55
|
+
"import": {
|
|
56
|
+
"types": "./dist/vite.d.ts",
|
|
57
|
+
"default": "./dist/vite.js"
|
|
58
|
+
},
|
|
59
|
+
"require": {
|
|
60
|
+
"types": "./dist/vite.d.cts",
|
|
61
|
+
"default": "./dist/vite.cjs"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
22
64
|
"./package.json": "./package.json"
|
|
23
65
|
},
|
|
24
|
-
"files": [
|
|
25
|
-
"dist/**/*",
|
|
26
|
-
"README.md",
|
|
27
|
-
"CHANGELOG.md",
|
|
28
|
-
"LICENSE"
|
|
29
|
-
],
|
|
30
66
|
"publishConfig": {
|
|
31
67
|
"access": "public"
|
|
32
68
|
},
|
|
33
|
-
"repository": {
|
|
34
|
-
"type": "git",
|
|
35
|
-
"url": "git+https://github.com/module-federation/electron.git",
|
|
36
|
-
"directory": "packages/electron"
|
|
37
|
-
},
|
|
38
|
-
"bugs": {
|
|
39
|
-
"url": "https://github.com/module-federation/electron/issues"
|
|
40
|
-
},
|
|
41
|
-
"homepage": "https://github.com/module-federation/electron#readme",
|
|
42
|
-
"engines": {
|
|
43
|
-
"node": "^22.18.0 || ^24.11.0 || >=26.0.0"
|
|
44
|
-
},
|
|
45
69
|
"scripts": {
|
|
46
70
|
"build": "rslib build --lib cjs && rslib build --lib esm --no-clean",
|
|
47
71
|
"dev": "rslib build --watch",
|
|
72
|
+
"test": "rstest",
|
|
48
73
|
"pack:dry": "npm pack --dry-run",
|
|
49
74
|
"prepack": "pnpm run build",
|
|
50
75
|
"prepublishOnly": "pnpm run typecheck && pnpm run build",
|
|
51
76
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
52
77
|
},
|
|
53
78
|
"devDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
79
|
+
"@module-federation/rsbuild-plugin": "2.9.3",
|
|
80
|
+
"@module-federation/vite": "1.23.9",
|
|
81
|
+
"@rsbuild/core": "2.3.0",
|
|
82
|
+
"@rslib/core": "^1.0.5",
|
|
83
|
+
"@rstest/core": "0.12.5",
|
|
84
|
+
"@types/node": "^26.6.6",
|
|
85
|
+
"electron": "^45.2.1",
|
|
86
|
+
"typescript": "^7.0.2",
|
|
87
|
+
"vite": "^8.3.5"
|
|
88
|
+
},
|
|
89
|
+
"peerDependencies": {
|
|
90
|
+
"@module-federation/rsbuild-plugin": "^2.9.3",
|
|
91
|
+
"@module-federation/vite": "^1.23.9",
|
|
92
|
+
"@rsbuild/core": "^2.0.0",
|
|
93
|
+
"electron": ">=30",
|
|
94
|
+
"vite": "^7.0.0 || ^8.0.0"
|
|
95
|
+
},
|
|
96
|
+
"peerDependenciesMeta": {
|
|
97
|
+
"@module-federation/rsbuild-plugin": {
|
|
98
|
+
"optional": true
|
|
99
|
+
},
|
|
100
|
+
"@module-federation/vite": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"@rsbuild/core": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
106
|
+
"electron": {
|
|
107
|
+
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"vite": {
|
|
110
|
+
"optional": true
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"engines": {
|
|
114
|
+
"node": "^22.18.0 || ^24.11.0 || >=26.0.0"
|
|
56
115
|
}
|
|
57
116
|
}
|