Bundle babel-plugin-react-forget with rollup

Attempt to bundle the plugin with rollup instead of just tsc. I'm intentionally 
not inlining babel related modules, as we should ideally rely on the host 
environment's version instead
This commit is contained in:
Lauren Tan
2023-10-27 14:07:56 -04:00
parent 473237ba1f
commit 419310cd15
3 changed files with 34 additions and 3 deletions
@@ -8,7 +8,7 @@
"src"
],
"scripts": {
"build": "rimraf dist && tsc",
"build": "rimraf dist && rollup --config --bundleConfigAsCjs",
"test": "concurrently -g -n snap,sprout \"yarn snap:ci\" \"yarn sprout:ci\"",
"jest": "tsc && ts-node \"$(yarn --silent which jest)\"",
"snap": "node ../snap/dist/main.js",
@@ -0,0 +1,32 @@
import typescript from "@rollup/plugin-typescript";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import path from "path";
import process from "process";
const NO_INLINE = new Set(["@babel/generator", "@babel/types"]);
export default {
input: "src/index.ts",
output: {
file: "dist/index.js",
format: "cjs",
sourcemap: false,
exports: "named",
},
plugins: [
typescript({
compilerOptions: {
noEmit: true,
},
}),
json(),
nodeResolve({
preferBuiltins: true,
resolveOnly: (module) => NO_INLINE.has(module) === false,
rootDir: path.join(process.cwd(), ".."),
}),
commonjs(),
],
};
@@ -16,8 +16,7 @@
"target": "ES2015",
// ideally turn off only during dev, or on a per-file basis
"noUnusedLocals": false,
"sourceMap": true,
"composite": true
"composite": true,
},
"exclude": [
"node_modules",