-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
35 lines (32 loc) · 1.26 KB
/
rollup.config.mjs
File metadata and controls
35 lines (32 loc) · 1.26 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
import { createESMConfig, createCJSConfig, createJsxPragmaFixPlugins, collectSourceEntries } from '../../scripts/build/rollup.base.mjs';
import pkg from './package.json' with { type: 'json' };
const input = collectSourceEntries();
// This package is framework-agnostic and uses /** @jsx createElement */ pragmas
// where `createElement` is a function passed at runtime (not React.createElement).
// SWC has a bug where the pragma name collides with the local `createElement`
// variable (from destructured params), causing it to either drop the binding or
// rename it while JSX calls still reference the bare `createElement`.
// The fix plugins strip the pragma before SWC and restore the correct references after.
const jsxFix = createJsxPragmaFixPlugins();
export default [
createESMConfig({
input,
pkg,
outputDir: 'dist/es',
preserveModules: true,
preSwcPlugins: [jsxFix.prePlugin],
plugins: [jsxFix.postPlugin],
}),
createCJSConfig({
input,
pkg,
outputDir: 'dist/cjs',
preserveModules: true,
// Replace instantsearch.js/es imports with instantsearch.js/cjs for CJS build
replaceImports: {
'instantsearch.js/es': 'instantsearch.js/cjs',
},
preSwcPlugins: [jsxFix.prePlugin],
plugins: [jsxFix.postPlugin],
}),
];