forked from molefrog/wouter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
52 lines (47 loc) · 1.37 KB
/
rollup.config.mjs
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
import replace from "@rollup/plugin-replace";
import { defineConfig } from "rollup";
// support for preact builds
const isPreact = String(process.env.DIR).indexOf("preact") !== -1;
if (isPreact) process.chdir("./preact");
const ESM_SOURCES = [
"index.js",
"matcher.js",
"react-deps.js",
"use-location.js",
"static-location.js",
...(isPreact
? []
: // only included in React build
["use-sync-external-store.js", "use-sync-external-store.native.js"]),
];
const OUTPUT_DIR = "cjs";
export default defineConfig([
{
input: ESM_SOURCES,
external: [
"react",
"preact",
"preact/hooks",
"use-sync-external-store/shim/index.js",
"use-sync-external-store/shim/index.native.js",
// tell Rollup not to apply any optimizations to unqualified `use-sync-external-store`
// import (see comment below)
"./use-sync-external-store",
],
output: {
dir: OUTPUT_DIR,
format: "cjs",
exports: "named",
},
plugins: [
replace({
// replaces qualified import with an unqualified one
// so that React Native's bundler can pick up the right source file
// See https://github.com/molefrog/wouter/pull/277#issuecomment-1382930657
"./use-sync-external-store.js": "./use-sync-external-store",
preventAssignment: true,
delimiters: ["", ""],
}),
],
},
]);