-
-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathreactCompilerPreset.ts
More file actions
28 lines (27 loc) · 899 Bytes
/
reactCompilerPreset.ts
File metadata and controls
28 lines (27 loc) · 899 Bytes
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
import type {
ReactCompilerBabelPluginOptions,
RolldownBabelPreset,
} from '#optionalTypes'
export const reactCompilerPreset = (
options: ReactCompilerBabelPluginOptions = {},
): RolldownBabelPreset => ({
preset: () => ({
plugins: [['babel-plugin-react-compiler', options]],
}),
rolldown: {
filter: {
// should be lax than https://github.com/facebook/react/blob/9c0323e2cf9be543d6eaa44419598af56922603f/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts#L842-L863
code:
options.compilationMode === 'annotation'
? /['"]use memo['"]/
: /\b[A-Z]|\buse/,
},
applyToEnvironmentHook: (env) => env.config.consumer === 'client',
optimizeDeps: {
include:
options.target === '17' || options.target === '18'
? ['react-compiler-runtime']
: ['react/compiler-runtime'],
},
},
})