mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Also build react-forget-runtime with rollup
This adds rollup to the runtime and adds a new plugin to add the license banner + inject the `"use no memo"` directive. We need to inject it there as rollup currently strips out unknown directives during bundling.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
"@tsconfig/strictest": "^2.0.5",
|
||||
"concurrently": "^7.4.0",
|
||||
"rollup": "^4.13.2",
|
||||
"rollup-plugin-banner2": "^1.2.3",
|
||||
"rollup-plugin-license": "^3.3.1",
|
||||
"rollup-plugin-prettier": "^4.1.1",
|
||||
"typescript": "^5.4.3"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "rimraf dist && rollup --config --bundleConfigAsCjs",
|
||||
"test": "echo 'no tests'"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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 banner2 from "rollup-plugin-banner2";
|
||||
|
||||
const NO_INLINE = new Set(["react"]);
|
||||
|
||||
const PROD_ROLLUP_CONFIG = {
|
||||
input: "src/index.ts",
|
||||
output: {
|
||||
file: "dist/index.js",
|
||||
format: "cjs",
|
||||
sourcemap: true,
|
||||
},
|
||||
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,
|
||||
},
|
||||
}),
|
||||
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";` // DO NOT REMOVE
|
||||
),
|
||||
],
|
||||
};
|
||||
|
||||
export default PROD_ROLLUP_CONFIG;
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"extends": "@tsconfig/strictest/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "CommonJS",
|
||||
"module": "ES2015",
|
||||
"moduleResolution": "Bundler",
|
||||
"declaration": true,
|
||||
"outDir": "dist",
|
||||
"jsx": "react-jsxdev",
|
||||
|
||||
@@ -7536,6 +7536,13 @@ magic-string@0.30.5, magic-string@~0.30.0:
|
||||
dependencies:
|
||||
"@jridgewell/sourcemap-codec" "^1.4.15"
|
||||
|
||||
magic-string@^0.25.7:
|
||||
version "0.25.9"
|
||||
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c"
|
||||
integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==
|
||||
dependencies:
|
||||
sourcemap-codec "^1.4.8"
|
||||
|
||||
magic-string@^0.30.3:
|
||||
version "0.30.8"
|
||||
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.8.tgz#14e8624246d2bedba70d5462aa99ac9681844613"
|
||||
@@ -8553,6 +8560,13 @@ rimraf@^3.0.0, rimraf@^3.0.2:
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
rollup-plugin-banner2@^1.2.3:
|
||||
version "1.2.3"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-banner2/-/rollup-plugin-banner2-1.2.3.tgz#4aa454e41a80623180164625368ec0321641a0ef"
|
||||
integrity sha512-lhpPoDTRZMIvSK1AppGNDIZ4fnQuW4WuENuswSUzvXhTR596zWNOmCaCYoqD15QixnjnG+wT+jauLEK5qGRPZg==
|
||||
dependencies:
|
||||
magic-string "^0.25.7"
|
||||
|
||||
rollup-plugin-license@^3.3.1:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-license/-/rollup-plugin-license-3.3.1.tgz#73b68e33477524198d6f3f9befc905f59bf37c53"
|
||||
@@ -8840,6 +8854,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
|
||||
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
|
||||
|
||||
sourcemap-codec@^1.4.8:
|
||||
version "1.4.8"
|
||||
resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4"
|
||||
integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==
|
||||
|
||||
spawn-command@^0.0.2-1:
|
||||
version "0.0.2-1"
|
||||
resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2-1.tgz#62f5e9466981c1b796dc5929937e11c9c6921bd0"
|
||||
|
||||
Reference in New Issue
Block a user