@samitouri / QOS-React-1 / commits / 419310cd15

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

Lauren Tan committed Oct 27, 2023 at 14:07 UTC 419310cd15673d1c3d4112cbedf85ea08c1c1e61
3 files changed +34 -3
compiler/packages/babel-plugin-react-forget/package.json
+1 -1
@@ -8,7 +8,7 @@
8 "src"
9 ],
10 "scripts": {
11 - "build": "rimraf dist && tsc",
11 + "build": "rimraf dist && rollup --config --bundleConfigAsCjs",
12 "test": "concurrently -g -n snap,sprout \"yarn snap:ci\" \"yarn sprout:ci\"",
13 "jest": "tsc && ts-node \"$(yarn --silent which jest)\"",
14 "snap": "node ../snap/dist/main.js",
compiler/packages/babel-plugin-react-forget/rollup.config.js new
+32
@@ -0,0 +1,32 @@
1 +import typescript from "@rollup/plugin-typescript";
2 +import { nodeResolve } from "@rollup/plugin-node-resolve";
3 +import commonjs from "@rollup/plugin-commonjs";
4 +import json from "@rollup/plugin-json";
5 +import path from "path";
6 +import process from "process";
7 +
8 +const NO_INLINE = new Set(["@babel/generator", "@babel/types"]);
9 +
10 +export default {
11 + input: "src/index.ts",
12 + output: {
13 + file: "dist/index.js",
14 + format: "cjs",
15 + sourcemap: false,
16 + exports: "named",
17 + },
18 + plugins: [
19 + typescript({
20 + compilerOptions: {
21 + noEmit: true,
22 + },
23 + }),
24 + json(),
25 + nodeResolve({
26 + preferBuiltins: true,
27 + resolveOnly: (module) => NO_INLINE.has(module) === false,
28 + rootDir: path.join(process.cwd(), ".."),
29 + }),
30 + commonjs(),
31 + ],
32 +};
compiler/packages/babel-plugin-react-forget/tsconfig.json
+1 -2
@@ -16,8 +16,7 @@
16 "target": "ES2015",
17 // ideally turn off only during dev, or on a per-file basis
18 "noUnusedLocals": false,
19 - "sourceMap": true,
20 - "composite": true
19 + "composite": true,
20 },
21 "exclude": [
22 "node_modules",