From db34843c424d55da7b39a35b8043bb49a1da9515 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Sat, 11 May 2024 00:19:59 -0400 Subject: [PATCH] [healthcheck] Build with rollup ghstack-source-id: cd40da2ddce047838ed031eed1c1f8e605648a78 Pull Request resolved: https://github.com/facebook/react-forget/pull/2954 --- compiler/packages/healthcheck/package.json | 3 +- .../packages/healthcheck/rollup.config.js | 70 +++++++++++++++++++ compiler/packages/healthcheck/tsconfig.json | 7 +- 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 compiler/packages/healthcheck/rollup.config.js diff --git a/compiler/packages/healthcheck/package.json b/compiler/packages/healthcheck/package.json index bed1b308e8..0dbfbc7a32 100644 --- a/compiler/packages/healthcheck/package.json +++ b/compiler/packages/healthcheck/package.json @@ -2,8 +2,9 @@ "name": "healthcheck", "version": "0.0.0", "description": "Health check script to test violations of the rules of react.", + "main": "dist/index.js", "scripts": { - "build": "rimraf dist && tsc --build", + "build": "rimraf dist && rollup --config --bundleConfigAsCjs", "test": "echo 'no tests'" }, "dependencies": { diff --git a/compiler/packages/healthcheck/rollup.config.js b/compiler/packages/healthcheck/rollup.config.js new file mode 100644 index 0000000000..0394ee9535 --- /dev/null +++ b/compiler/packages/healthcheck/rollup.config.js @@ -0,0 +1,70 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +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"; +import terser from "@rollup/plugin-terser"; +import prettier from "rollup-plugin-prettier"; +import banner2 from "rollup-plugin-banner2"; + +const NO_INLINE = new Set([]); + +const DEV_ROLLUP_CONFIG = { + input: "src/index.ts", + output: { + file: "dist/index.js", + format: "cjs", + sourcemap: false, + exports: "named", + }, + plugins: [ + typescript({ + tsconfig: "./tsconfig.json", + compilerOptions: { + noEmit: true, + }, + }), + json(), + nodeResolve({ + preferBuiltins: true, + resolveOnly: (module) => NO_INLINE.has(module) === false, + rootDir: path.join(process.cwd(), ".."), + }), + commonjs(), + terser({ + format: { + comments: false, + }, + compress: false, + mangle: false, + }), + prettier(), + banner2( + () => `/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @lightSyntaxTransform + * @noflow + * @nolint + * @preventMunge + * @preserve-invariant-messages + */ + +"use no memo"; +` + ), + ], +}; + +export default DEV_ROLLUP_CONFIG; diff --git a/compiler/packages/healthcheck/tsconfig.json b/compiler/packages/healthcheck/tsconfig.json index cf05349932..37f76b276f 100644 --- a/compiler/packages/healthcheck/tsconfig.json +++ b/compiler/packages/healthcheck/tsconfig.json @@ -1,9 +1,10 @@ { "extends": "@tsconfig/strictest/tsconfig.json", "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", - "outDir": "dist", + "module": "ES2015", + "moduleResolution": "Bundler", + "rootDir": "../", + "noEmit": true, "jsx": "react-jsxdev", "lib": ["ES2022"],