@module-federation/rsbuild-plugin 0.0.0-docs-remove-invalid-lark-link-20251205062649
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 +72 -0
- package/dist/LICENSE +21 -0
- package/dist/cli/index.d.ts +31 -0
- package/dist/constant.d.ts +9 -0
- package/dist/constant.js +59 -0
- package/dist/constant.mjs +10 -0
- package/dist/index.js +486 -0
- package/dist/index.mjs +422 -0
- package/dist/logger.d.ts +2 -0
- package/dist/utils/addDataFetchExposes.d.ts +2 -0
- package/dist/utils/autoDeleteSplitChunkCacheGroups.d.ts +6 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/manifest.d.ts +11 -0
- package/dist/utils/ssr.d.ts +48 -0
- package/dist/utils.js +264 -0
- package/dist/utils.mjs +186 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# @module-federation/rsbuild-plugin
|
|
2
|
+
|
|
3
|
+
## Example
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
npm install @module-federation/rsbuild-plugin -D
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install @module-federation/enhanced
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Rsbuild App
|
|
14
|
+
``` js
|
|
15
|
+
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
|
|
16
|
+
import { defineConfig } from '@rsbuild/core';
|
|
17
|
+
import { pluginReact } from '@rsbuild/plugin-react';
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
server: {
|
|
21
|
+
port: 2000,
|
|
22
|
+
},
|
|
23
|
+
plugins: [
|
|
24
|
+
pluginReact(),
|
|
25
|
+
pluginModuleFederation({
|
|
26
|
+
name: 'federation_consumer',
|
|
27
|
+
remotes: {
|
|
28
|
+
remote1: 'remote1@http://localhost:2001/mf-manifest.json',
|
|
29
|
+
},
|
|
30
|
+
shared: ['react', 'react-dom'],
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Rslib Module
|
|
37
|
+
``` js
|
|
38
|
+
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
|
|
39
|
+
import { defineConfig } from '@rslib/core';
|
|
40
|
+
|
|
41
|
+
export default defineConfig({
|
|
42
|
+
lib: [
|
|
43
|
+
// ...
|
|
44
|
+
{
|
|
45
|
+
format: 'mf',
|
|
46
|
+
output: {
|
|
47
|
+
distPath: {
|
|
48
|
+
root: './dist/mf',
|
|
49
|
+
},
|
|
50
|
+
assetPrefix: 'http://localhost:3001/mf',
|
|
51
|
+
},
|
|
52
|
+
plugins: [
|
|
53
|
+
// ...
|
|
54
|
+
pluginModuleFederation({
|
|
55
|
+
name: 'rslib_provider',
|
|
56
|
+
exposes: {
|
|
57
|
+
'.': './src/index.tsx',
|
|
58
|
+
},
|
|
59
|
+
shared: {
|
|
60
|
+
react: {
|
|
61
|
+
singleton: true,
|
|
62
|
+
},
|
|
63
|
+
'react-dom': {
|
|
64
|
+
singleton: true,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
```
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Bytedance, Inc. and its affiliates.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ModuleFederationPlugin, PLUGIN_NAME } from '@module-federation/enhanced/rspack';
|
|
2
|
+
import { SSR_DIR, StatsAssetResource } from '../utils';
|
|
3
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
4
|
+
import type { RsbuildPlugin, Rspack } from '@rsbuild/core';
|
|
5
|
+
type ModuleFederationOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
|
+
type RSBUILD_PLUGIN_OPTIONS = {
|
|
7
|
+
ssr?: boolean;
|
|
8
|
+
ssrDir?: string;
|
|
9
|
+
environment?: string;
|
|
10
|
+
};
|
|
11
|
+
type ExposedAPIType = {
|
|
12
|
+
options: {
|
|
13
|
+
nodePlugin?: ModuleFederationPlugin;
|
|
14
|
+
browserPlugin?: ModuleFederationPlugin;
|
|
15
|
+
rspressSSGPlugin?: ModuleFederationPlugin;
|
|
16
|
+
distOutputDir?: string;
|
|
17
|
+
browserEnvironmentName?: string;
|
|
18
|
+
nodeEnvironmentName?: string;
|
|
19
|
+
};
|
|
20
|
+
assetResources: Record<string, StatsAssetResource>;
|
|
21
|
+
isSSRConfig: typeof isSSRConfig;
|
|
22
|
+
isRspressSSGConfig: typeof isRspressSSGConfig;
|
|
23
|
+
};
|
|
24
|
+
export type { ModuleFederationOptions, ExposedAPIType };
|
|
25
|
+
declare const RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = "rsbuild:module-federation-enhanced";
|
|
26
|
+
export { RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, PLUGIN_NAME, SSR_DIR };
|
|
27
|
+
export declare function isMFFormat(bundlerConfig: Rspack.Configuration): boolean;
|
|
28
|
+
declare const isSSRConfig: (bundlerConfigName?: string) => boolean;
|
|
29
|
+
declare const isRspressSSGConfig: (bundlerConfigName?: string) => bundlerConfigName is "node";
|
|
30
|
+
export declare const pluginModuleFederation: (moduleFederationOptions: ModuleFederationOptions, rsbuildOptions?: RSBUILD_PLUGIN_OPTIONS) => RsbuildPlugin;
|
|
31
|
+
export { createModuleFederationConfig } from '@module-federation/sdk';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_ASSET_PREFIX = "/";
|
|
2
|
+
export declare const DATA_FETCH_IDENTIFIER = "data";
|
|
3
|
+
export declare const DATA_FETCH_CLIENT_SUFFIX = ".client";
|
|
4
|
+
export declare const CALL_NAME_MAP: {
|
|
5
|
+
RSPRESS: string;
|
|
6
|
+
RSLIB: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const RSPRESS_BUNDLER_CONFIG_NAME = "node";
|
|
9
|
+
export declare const RSPRESS_SSR_DIR = "ssr";
|
package/dist/constant.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
CALL_NAME_MAP: ()=>CALL_NAME_MAP,
|
|
28
|
+
DATA_FETCH_CLIENT_SUFFIX: ()=>DATA_FETCH_CLIENT_SUFFIX,
|
|
29
|
+
DATA_FETCH_IDENTIFIER: ()=>DATA_FETCH_IDENTIFIER,
|
|
30
|
+
DEFAULT_ASSET_PREFIX: ()=>DEFAULT_ASSET_PREFIX,
|
|
31
|
+
RSPRESS_BUNDLER_CONFIG_NAME: ()=>RSPRESS_BUNDLER_CONFIG_NAME,
|
|
32
|
+
RSPRESS_SSR_DIR: ()=>RSPRESS_SSR_DIR
|
|
33
|
+
});
|
|
34
|
+
const DEFAULT_ASSET_PREFIX = '/';
|
|
35
|
+
const DATA_FETCH_IDENTIFIER = 'data';
|
|
36
|
+
const DATA_FETCH_CLIENT_SUFFIX = '.client';
|
|
37
|
+
const CALL_NAME_MAP = {
|
|
38
|
+
RSPRESS: 'rspress',
|
|
39
|
+
RSLIB: 'rslib'
|
|
40
|
+
};
|
|
41
|
+
const RSPRESS_BUNDLER_CONFIG_NAME = 'node';
|
|
42
|
+
const RSPRESS_SSR_DIR = 'ssr';
|
|
43
|
+
exports.CALL_NAME_MAP = __webpack_exports__.CALL_NAME_MAP;
|
|
44
|
+
exports.DATA_FETCH_CLIENT_SUFFIX = __webpack_exports__.DATA_FETCH_CLIENT_SUFFIX;
|
|
45
|
+
exports.DATA_FETCH_IDENTIFIER = __webpack_exports__.DATA_FETCH_IDENTIFIER;
|
|
46
|
+
exports.DEFAULT_ASSET_PREFIX = __webpack_exports__.DEFAULT_ASSET_PREFIX;
|
|
47
|
+
exports.RSPRESS_BUNDLER_CONFIG_NAME = __webpack_exports__.RSPRESS_BUNDLER_CONFIG_NAME;
|
|
48
|
+
exports.RSPRESS_SSR_DIR = __webpack_exports__.RSPRESS_SSR_DIR;
|
|
49
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
50
|
+
"CALL_NAME_MAP",
|
|
51
|
+
"DATA_FETCH_CLIENT_SUFFIX",
|
|
52
|
+
"DATA_FETCH_IDENTIFIER",
|
|
53
|
+
"DEFAULT_ASSET_PREFIX",
|
|
54
|
+
"RSPRESS_BUNDLER_CONFIG_NAME",
|
|
55
|
+
"RSPRESS_SSR_DIR"
|
|
56
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
57
|
+
Object.defineProperty(exports, '__esModule', {
|
|
58
|
+
value: true
|
|
59
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const DEFAULT_ASSET_PREFIX = '/';
|
|
2
|
+
const DATA_FETCH_IDENTIFIER = 'data';
|
|
3
|
+
const DATA_FETCH_CLIENT_SUFFIX = '.client';
|
|
4
|
+
const CALL_NAME_MAP = {
|
|
5
|
+
RSPRESS: 'rspress',
|
|
6
|
+
RSLIB: 'rslib'
|
|
7
|
+
};
|
|
8
|
+
const RSPRESS_BUNDLER_CONFIG_NAME = 'node';
|
|
9
|
+
const RSPRESS_SSR_DIR = 'ssr';
|
|
10
|
+
export { CALL_NAME_MAP, DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER, DEFAULT_ASSET_PREFIX, RSPRESS_BUNDLER_CONFIG_NAME, RSPRESS_SSR_DIR };
|