-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
rollup.config.js
90 lines (85 loc) · 2.23 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import resolve from "@rollup/plugin-node-resolve"
import babel from "@rollup/plugin-babel"
import commonjs from "@rollup/plugin-commonjs"
import json from "@rollup/plugin-json"
import replace from "@rollup/plugin-replace";
import autoExternal from "rollup-plugin-auto-external"
import internal from "rollup-plugin-internal"
import path from "path"
// Rollup hoists Ink's dynamic require of react-devtools-core which causes
// a window not found error so we exclude Ink's devtools file for now.
function excludeDevTools() {
const re = /ink/
return {
name: `ignoreDevTools`,
load(id) {
if (id.match(re)) {
if (path.parse(id).name === `devtools`) {
return { code: `` }
}
}
},
}
}
const extensions = [`.mjs`, `.js`, `.json`, `.node`, `.ts`, `.tsx`]
export default {
input: `src/reporter/loggers/ink/index.tsx`,
output: {
file: `lib/reporter/loggers/ink/index.js`,
format: `cjs`,
},
cache: false,
plugins: [
replace({
values: {
"process.env.NODE_ENV": JSON.stringify(`production`)
}
}),
excludeDevTools(),
json(),
babel({
extensions,
babelHelpers: `bundled`,
skipPreflightCheck: true,
exclude: `node_modules/**`,
babelrc: false,
presets: [
[
"@babel/env",
{
"modules": false,
"shippedProposals": true,
"targets": { "node": "18.0.0" }
}
],
"@babel/preset-react"
],
plugins: ["@babel/plugin-transform-runtime", "@sigmacomputing/babel-plugin-lodash"],
overrides: [
{
"test": ["**/*.ts", "**/*.tsx"],
"plugins": [["@babel/plugin-transform-typescript", { "isTSX": true }]]
}
]
}),
resolve({
extensions,
dedupe: [ `react`, `ink` ]
}),
commonjs(),
autoExternal(),
internal([
`react`,
`ink`,
`ink-spinner`
]),
],
external: [
`yoga-layout-prebuilt`,
// Next one deserve explanation: ... it's because ink logger imports
// getStore, onLogAction from higher up (../../redux). But we don't want
// two copies of it - one bundled and one not, because it would result
// in multiple store copies
`../../redux`
]
}