main
js 45 lines 1.26 KB
Raw
1 'use strict';
2
3 const path = require('path');
4
5 module.exports = {
6 name: 'rsc',
7 target: 'node',
8 entry: './src/entry-rsc.js',
9 output: {
10 path: path.resolve(__dirname, 'build'),
11 filename: 'rsc-bundle.js',
12 library: {type: 'commonjs2'},
13 clean: true,
14 },
15 resolve: {
16 // This is the key: react-server condition makes `react` resolve to the
17 // server variant that supports async components, server references, etc.
18 conditionNames: ['react-server', 'node', 'require'],
19 extensions: ['.js', '.jsx'],
20 },
21 module: {
22 rules: [
23 {
24 // Custom loader that replaces 'use client' modules with client
25 // reference proxies. Must run before babel.
26 enforce: 'pre',
27 test: /\.jsx?$/,
28 exclude: /node_modules/,
29 loader: path.resolve(__dirname, 'rsc-client-ref-loader.js'),
30 },
31 {
32 test: /\.jsx?$/,
33 exclude: /node_modules/,
34 loader: require.resolve('babel-loader'),
35 options: {
36 presets: [['@babel/preset-react', {runtime: 'automatic'}]],
37 },
38 },
39 ],
40 },
41 // Production mode but no minification — we want optimized code paths
42 // but readable profiles and a fair comparison between approaches.
43 mode: 'production',
44 optimization: {minimize: false},
45 };