forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
75 lines (71 loc) · 2.13 KB
/
rollup.config.js
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
const path = require("path");
const babel = require("@rollup/plugin-babel").default;
const copy = require("rollup-plugin-copy");
const prettier = require("rollup-plugin-prettier");
const typescript = require("@rollup/plugin-typescript");
const {
createBanner,
getBuildDirectories,
PRETTY,
} = require("../../rollup.utils");
const { name, version } = require("./package.json");
module.exports = function rollup() {
const { ROOT_DIR, SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(name);
const modules = [
{
input: `${SOURCE_DIR}/index.tsx`,
output: {
file: `${OUTPUT_DIR}/index.js`,
format: "esm",
sourcemap: !PRETTY,
banner: createBanner("React Router Native", version),
},
external: [
"@babel/runtime/helpers/esm/extends",
"@babel/runtime/helpers/esm/objectWithoutPropertiesLoose",
"@ungap/url-search-params",
"history",
"react",
"react-native",
"react-router",
"@remix-run/router",
],
plugins: [
babel({
babelHelpers: "bundled",
exclude: /node_modules/,
presets: [
[
"module:metro-react-native-babel-preset",
{
disableImportExportTransform: true,
enableBabelRuntime: false,
},
],
"@babel/preset-typescript",
],
plugins: ["babel-plugin-dev-expression"],
extensions: [".ts", ".tsx"],
}),
typescript({
tsconfig: path.join(__dirname, "tsconfig.json"),
exclude: ["__tests__"],
noEmitOnError: true,
}),
copy({
targets: [
{ src: path.join(ROOT_DIR, "LICENSE.md"), dest: SOURCE_DIR },
],
verbose: true,
}),
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
},
];
return modules;
};
/**
* @typedef {import('rollup').InputOptions} RollupInputOptions
* @typedef {import('rollup').OutputOptions} RollupOutputOptions
* @typedef {import('rollup').RollupOptions} RollupOptions
* @typedef {import('rollup').Plugin} RollupPlugin
*/