Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External react/jsx-runtime #499

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

165 changes: 119 additions & 46 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,132 @@ const ProdReact = require("react/cjs/react.production.min.js");
function createDevConfig(format) {
const dir = format === "module" ? "esm" : format;

return {
input: `src/development.js`,
output: {
format,
file: `${dir}/react.development.js`,
sourcemap: true,
banner: `/* react@${DevReact.version} development version */`,
exports: "named",
return [
{
input: `src/development.js`,
output: {
format,
file: `${dir}/react@${DevReact.version}.development.js`,
sourcemap: true,
banner: `/* react@${DevReact.version} development version */`,
exports: "named",
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"development"',
},
}),
],
},
{
input: `src/jsx-dev-runtime.development.js`,
output: {
format,
file: `${dir}/react/jsx-dev-runtime@${DevReact.version}.development.js`,
sourcemap: true,
banner: `/* react/jsx-dev-runtime@${DevReact.version} development version */`,
exports: "named",
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"development"',
},
}),
],
},
{
input: `src/jsx-runtime.development.js`,
output: {
format,
file: `${dir}/react/jsx-runtime@${DevReact.version}.development.js`,
sourcemap: true,
banner: `/* react/jsx-runtime@${DevReact.version} development version */`,
exports: "named",
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"development"',
},
}),
],
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"development"',
},
}),
],
};
];
}

function createProdConfig(format) {
return {
input: `src/production.js`,
output: {
format,
file: `${format}/react.production.min.js`,
sourcemap: true,
banner: `/* react@${ProdReact.version} production version */`,
exports: "named",
return [
{
input: `src/production.js`,
output: {
format,
file: `${format}/react@${ProdReact.version}.production.min.js`,
sourcemap: true,
banner: `/* react@${ProdReact.version} production version */`,
exports: "named",
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"production"',
},
}),
],
},
{
input: `src/jsx-dev-runtime.production.js`,
output: {
format,
file: `${format}/react/jsx-dev-runtime@${DevReact.version}.production.js`,
sourcemap: true,
banner: `/* react/jsx-dev-runtime@${DevReact.version} production version */`,
exports: "named",
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"production"',
},
}),
],
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"production"',
},
}),
terser({
output: {
comments(node, comment) {
return comment.value.trim().startsWith("react@");
{
input: `src/jsx-runtime.production.js`,
output: {
format,
file: `${format}/react/jsx-runtime@${DevReact.version}.production.js`,
sourcemap: true,
banner: `/* react/jsx-runtime@${DevReact.version} production version */`,
exports: "named",
},
plugins: [
commonjs(),
resolve(),
replace({
values: {
"process.env.NODE_ENV": '"production"',
},
},
}),
],
};
}),
],
},
];
}

export default [
createDevConfig("esm"),
createDevConfig("system"),
createProdConfig("esm"),
createProdConfig("system"),
...createDevConfig("esm"),
...createDevConfig("system"),
...createProdConfig("esm"),
...createProdConfig("system"),
];
11 changes: 11 additions & 0 deletions src/jsx-dev-runtime.development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import ReactJSXDev from "react/cjs/react-jsx-dev-runtime.development.js";
import ReactJSX from "react/cjs/react-jsx-runtime.development.js";

export default ReactJSXDev;

if(!ReactJSXDev.jsx) ReactJSXDev.jsx = ReactJSX.jsx;
if(!ReactJSXDev.jsxs) ReactJSXDev.jsxs = ReactJSX.jsxs;

export const __esmModule = true;

export const { Fragment, jsxDEV, jsx, jsxs } = ReactJSXDev;
11 changes: 11 additions & 0 deletions src/jsx-dev-runtime.production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import ReactJSXDev from "react/cjs/react-jsx-dev-runtime.production.min.js";
import ReactJSX from "react/cjs/react-jsx-runtime.production.min.js";

export default ReactJSXDev;

export const __esmModule = true;

if(!ReactJSXDev.jsx) ReactJSXDev.jsx = ReactJSX.jsx;
if(!ReactJSXDev.jsxs) ReactJSXDev.jsxs = ReactJSX.jsxs;

export const { Fragment, jsxDEV, jsx, jsxs } = ReactJSXDev;
6 changes: 6 additions & 0 deletions src/jsx-runtime.development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ReactJSX from "react/cjs/react-jsx-runtime.development.js";

export default ReactJSX;
export const __esmModule = true;

export const { Fragment, jsx, jsxs } = ReactJSX;
6 changes: 6 additions & 0 deletions src/jsx-runtime.production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ReactJSX from "react/cjs/react-jsx-runtime.production.min.js";

export default ReactJSX;
export const __esmModule = true;

export const { Fragment, jsx, jsxs } = ReactJSX;