-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathrspack.node.config.js
More file actions
81 lines (80 loc) · 2.41 KB
/
Copy pathrspack.node.config.js
File metadata and controls
81 lines (80 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const {
ModuleFederationPlugin,
} = require('@module-federation/enhanced/rspack');
const path = require('node:path');
/**
* Node-targeted remote build used by Rstest's Module Federation test.
* This differs from the browser build (rspack.config.js):
* - target: async-node
* - includes a Node runtime plugin so remote chunks can be loaded over HTTP
* - outputs to dist-node (served on a separate port from the browser remote)
*/
module.exports = {
entry: './index.js',
mode: 'development',
devtool: 'hidden-source-map',
target: 'async-node',
output: {
// The Node remote runtime resolves chunk URLs relative to the remoteEntry URL
// when publicPath is explicitly set. `auto` can throw in non-browser contexts.
publicPath: 'http://localhost:3001/',
clean: true,
path: path.resolve(__dirname, 'dist-node'),
},
resolve: {
extensions: ['.jsx', '.js', '.json', '.wasm'],
},
experiments: {
css: true,
},
module: {
rules: [
{
test: /\.(jpg|png|gif|jpeg)$/,
type: 'asset/resource',
},
{
test: /\.(js|jsx)$/,
use: {
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'ecmascript',
jsx: true,
},
transform: {
react: {
runtime: 'automatic',
},
},
},
},
},
},
],
},
plugins: [
new ModuleFederationPlugin({
name: 'component_app',
filename: 'remoteEntry.js',
// This remote is consumed by Rstest using `remoteType: 'script'` while tests
// run under JSDOM. We force the MF runtime to use its Node loader (vm eval),
// so the remoteEntry must export through CommonJS for the loader to return
// the container interface (get/init).
library: { type: 'commonjs-module', name: 'component_app' },
// Required for async-node remotes that load chunks over HTTP in Node.
runtimePlugins: ['@module-federation/node/runtimePlugin'],
exposes: {
'./Button': './src/Button.jsx',
'./Dialog': './src/Dialog.jsx',
'./Logo': './src/Logo.jsx',
'./ToolTip': './src/ToolTip.jsx',
},
shared: {
react: { singleton: true, requiredVersion: '19.2.3' },
'react-dom': { singleton: true, requiredVersion: '19.2.3' },
},
}),
],
};