feat: configure export conditions properly (#12136)
feat: nuke rollup into oblivion in favor of tsup feat: add ESM build for architect, express and node packages chore: update HMR test to ignore warning log feat: add module-sync export condition fix: react-router should not reference itself, that's weird (use tsconfig paths) chore: update e2e test warning assertion chore: add vite ignore comment for dynamic import fix: update optimizeDeps chore: add wireit for caching chore: add cache to workflows --------- Co-authored-by: Matt Brophy <matt@brophy.org>pull/12186/head
parent
5c7cc020be
commit
2d5924f567
@ -0,0 +1,12 @@
|
||||
export function createBanner(packageName: string, version: string) {
|
||||
return `/**
|
||||
* ${packageName} v${version}
|
||||
*
|
||||
* Copyright (c) Remix Software Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.md file in the root directory of this source tree.
|
||||
*
|
||||
* @license MIT
|
||||
*/`;
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
const path = require("node:path");
|
||||
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
isBareModuleId,
|
||||
getBuildDirectories,
|
||||
createBanner,
|
||||
WATCH,
|
||||
remixBabelConfig,
|
||||
} = require("../../rollup.utils");
|
||||
const { name: packageName, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
packageName,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-architect"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
external: (id) => isBareModuleId(id),
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
banner: createBanner(packageName, version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
preserveModules: true,
|
||||
exports: "auto",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts"] }),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs", "esm"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,55 +0,0 @@
|
||||
const path = require("node:path");
|
||||
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
isBareModuleId,
|
||||
getBuildDirectories,
|
||||
createBanner,
|
||||
remixBabelConfig,
|
||||
WATCH,
|
||||
} = require("../../rollup.utils");
|
||||
const { name: packageName, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
packageName,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-cloudflare"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
external: (id) => isBareModuleId(id),
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
banner: createBanner(packageName, version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
preserveModules: true,
|
||||
exports: "named",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts"] }),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs", "esm"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,78 +0,0 @@
|
||||
const path = require("node:path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
createBanner,
|
||||
isBareModuleId,
|
||||
getBuildDirectories,
|
||||
remixBabelConfig,
|
||||
WATCH,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
name,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-dev"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
external: isBareModuleId,
|
||||
input: [
|
||||
`${SOURCE_DIR}/cli/index.ts`,
|
||||
`${SOURCE_DIR}/routes.ts`,
|
||||
`${SOURCE_DIR}/vite.ts`,
|
||||
`${SOURCE_DIR}/vite/cloudflare.ts`,
|
||||
`${SOURCE_DIR}/typescript/plugin.ts`,
|
||||
],
|
||||
output: {
|
||||
banner: createBanner("@react-router/dev", version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
preserveModules: true,
|
||||
exports: "auto",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts"] }),
|
||||
copy({
|
||||
targets: [
|
||||
{ src: "LICENSE.md", dest: SOURCE_DIR },
|
||||
{ src: `${SOURCE_DIR}/vite/static`, dest: `${OUTPUT_DIR}/vite` },
|
||||
{
|
||||
src: `${SOURCE_DIR}/config/defaults`,
|
||||
dest: `${OUTPUT_DIR}/config`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
// Allow dynamic imports in CJS code to allow us to utilize
|
||||
// ESM modules as part of the compiler.
|
||||
{
|
||||
name: "dynamic-import-polyfill",
|
||||
renderDynamicImport() {
|
||||
return {
|
||||
left: "import(",
|
||||
right: ")",
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,53 @@
|
||||
import * as fsp from "fs/promises";
|
||||
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = [
|
||||
"cli/index.ts",
|
||||
"routes.ts",
|
||||
"vite.ts",
|
||||
"vite/cloudflare.ts",
|
||||
"typescript/plugin.ts",
|
||||
];
|
||||
|
||||
const external = ["./static/refresh-utils.cjs"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
external,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
name: "copy",
|
||||
async buildEnd() {
|
||||
await fsp.mkdir("dist/static", { recursive: true });
|
||||
await fsp.copyFile(
|
||||
"vite/static/refresh-utils.cjs",
|
||||
"dist/static/refresh-utils.cjs"
|
||||
);
|
||||
|
||||
await fsp.mkdir("dist/config/defaults", { recursive: true });
|
||||
const files = await fsp.readdir("config/defaults");
|
||||
for (const file of files) {
|
||||
await fsp.copyFile(
|
||||
`config/defaults/${file}`,
|
||||
`dist/config/defaults/${file}`
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
@ -1,7 +0,0 @@
|
||||
/* eslint-env node */
|
||||
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
module.exports = require("./umd/react-router-dom.production.min.js");
|
||||
} else {
|
||||
module.exports = require("./umd/react-router-dom.development.js");
|
||||
}
|
@ -1,223 +0,0 @@
|
||||
const path = require("path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const prettier = require("rollup-plugin-prettier");
|
||||
const replace = require("@rollup/plugin-replace");
|
||||
const { terser } = require("rollup-plugin-terser");
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const {
|
||||
createBanner,
|
||||
isBareModuleId,
|
||||
getBuildDirectories,
|
||||
PRETTY,
|
||||
WATCH,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(name);
|
||||
|
||||
// JS modules for bundlers
|
||||
const modules = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/index.mjs`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router DOM", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: ["babel-plugin-dev-expression"],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
}),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
verbose: true,
|
||||
}),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
];
|
||||
|
||||
// JS modules for <script type=module>
|
||||
const webModules = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/react-router-dom.development.js`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router DOM", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
"@babel/preset-modules",
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: ["babel-plugin-dev-expression"],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("development") },
|
||||
}),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/react-router-dom.production.min.js`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router DOM", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-modules",
|
||||
{
|
||||
// Don't spoof `.name` for Arrow Functions, which breaks when minified anyway.
|
||||
loose: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
"@babel/preset-react",
|
||||
{
|
||||
// Compile JSX Spread to Object.assign(), which is reliable in ESM browsers.
|
||||
useBuiltIns: true,
|
||||
},
|
||||
],
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: ["babel-plugin-dev-expression"],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("production") },
|
||||
}),
|
||||
terser({ ecma: 8, safari10: true }),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
];
|
||||
|
||||
// UMD modules for <script> tags and CommonJS (node)
|
||||
const globals = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/umd/react-router-dom.development.js`,
|
||||
format: "umd",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router DOM", version),
|
||||
globals: {
|
||||
react: "React",
|
||||
"react-router": "ReactRouter",
|
||||
},
|
||||
name: "ReactRouterDOM",
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: ["babel-plugin-dev-expression"],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("development") },
|
||||
}),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/umd/react-router-dom.production.min.js`,
|
||||
format: "umd",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
globals: {
|
||||
react: "React",
|
||||
"react-router": "ReactRouter",
|
||||
},
|
||||
name: "ReactRouterDOM",
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: ["babel-plugin-dev-expression"],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("production") },
|
||||
}),
|
||||
terser(),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
];
|
||||
|
||||
// Node entry points
|
||||
const node = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/node-main.js`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/main.js`,
|
||||
format: "cjs",
|
||||
banner: createBanner("React Router DOM", version),
|
||||
},
|
||||
plugins: [].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
];
|
||||
|
||||
return [...modules, ...webModules, ...globals, ...node];
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('rollup').InputOptions} RollupInputOptions
|
||||
* @typedef {import('rollup').OutputOptions} RollupOutputOptions
|
||||
* @typedef {import('rollup').RollupOptions} RollupOptions
|
||||
* @typedef {import('rollup').Plugin} RollupPlugin
|
||||
*/
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs", "esm"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,55 +0,0 @@
|
||||
const path = require("node:path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
isBareModuleId,
|
||||
createBanner,
|
||||
getBuildDirectories,
|
||||
remixBabelConfig,
|
||||
WATCH,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
name,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-express"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
external: (id) => isBareModuleId(id),
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
banner: createBanner(name, version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
preserveModules: true,
|
||||
exports: "auto",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts", ".tsx"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts", ".tsx"] }),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs", "esm"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,55 +0,0 @@
|
||||
const path = require("node:path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
isBareModuleId,
|
||||
createBanner,
|
||||
getBuildDirectories,
|
||||
WATCH,
|
||||
remixBabelConfig,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
name,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-fs-routes"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
external: (id) => isBareModuleId(id),
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
banner: createBanner(name, version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
preserveModules: true,
|
||||
exports: "auto",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts"] }),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,55 +0,0 @@
|
||||
const path = require("node:path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
isBareModuleId,
|
||||
createBanner,
|
||||
getBuildDirectories,
|
||||
remixBabelConfig,
|
||||
WATCH,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
name,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-node"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
external: (id) => isBareModuleId(id),
|
||||
output: {
|
||||
banner: createBanner(name, version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
preserveModules: true,
|
||||
exports: "named",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts", ".tsx"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts", ".tsx"] }),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts", "install.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs", "esm"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,55 +0,0 @@
|
||||
const path = require("node:path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
isBareModuleId,
|
||||
createBanner,
|
||||
getBuildDirectories,
|
||||
WATCH,
|
||||
remixBabelConfig,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
name,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-remix-config-routes-adapter"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
external: (id) => isBareModuleId(id),
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
banner: createBanner(name, version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
preserveModules: true,
|
||||
exports: "auto",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts"] }),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,63 +0,0 @@
|
||||
const path = require("node:path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
|
||||
const {
|
||||
createBanner,
|
||||
getBuildDirectories,
|
||||
remixBabelConfig,
|
||||
WATCH,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
/** @returns {import("rollup").RollupOptions[]} */
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(
|
||||
name,
|
||||
// We don't live in a folder matching our package name
|
||||
"react-router-serve"
|
||||
);
|
||||
|
||||
return [
|
||||
{
|
||||
external() {
|
||||
return true;
|
||||
},
|
||||
input: `${SOURCE_DIR}/cli.ts`,
|
||||
output: {
|
||||
banner: createBanner(name, version),
|
||||
dir: OUTPUT_DIR,
|
||||
format: "cjs",
|
||||
},
|
||||
plugins: [
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
extensions: [".ts"],
|
||||
...remixBabelConfig,
|
||||
}),
|
||||
typescript({
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
nodeResolve({ extensions: [".ts"] }),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
}),
|
||||
{
|
||||
name: "dynamic-import-polyfill",
|
||||
renderDynamicImport() {
|
||||
return {
|
||||
left: "import(",
|
||||
right: ")",
|
||||
};
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
};
|
@ -0,0 +1,21 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["cli.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: true,
|
||||
entry,
|
||||
format: ["cjs"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
@ -1,468 +0,0 @@
|
||||
/* eslint-disable import/no-nodejs-modules */
|
||||
const path = require("path");
|
||||
const babel = require("@rollup/plugin-babel").default;
|
||||
const copy = require("rollup-plugin-copy");
|
||||
const nodeResolve = require("@rollup/plugin-node-resolve").default;
|
||||
const prettier = require("rollup-plugin-prettier");
|
||||
const replace = require("@rollup/plugin-replace");
|
||||
const { terser } = require("rollup-plugin-terser");
|
||||
const typescript = require("@rollup/plugin-typescript");
|
||||
const {
|
||||
babelPluginReplaceVersionPlaceholder,
|
||||
createBanner,
|
||||
isBareModuleId,
|
||||
getBuildDirectories,
|
||||
validateReplacedVersion,
|
||||
PRETTY,
|
||||
WATCH,
|
||||
} = require("../../rollup.utils");
|
||||
const { name, version } = require("./package.json");
|
||||
|
||||
module.exports = function rollup() {
|
||||
const { SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories(name);
|
||||
|
||||
// JS modules for bundlers
|
||||
const modules = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/index.mjs`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
typescript({
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
tsconfig: path.join(__dirname, "tsconfig.json"),
|
||||
exclude: ["__tests__"],
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
copy({
|
||||
targets: [{ src: "LICENSE.md", dest: SOURCE_DIR }],
|
||||
verbose: true,
|
||||
}),
|
||||
validateReplacedVersion(),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/dom-export.tsx`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/dom-export.mjs`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
typescript({
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
tsconfig: path.join(__dirname, "tsconfig.dom.json"),
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/lib/types.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/lib/types.mjs`,
|
||||
format: "esm",
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
external: isBareModuleId,
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
typescript({
|
||||
// eslint-disable-next-line no-restricted-globals
|
||||
tsconfig: path.join(__dirname, "tsconfig.dom.json"),
|
||||
noEmitOnError: !WATCH,
|
||||
noForceEmit: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
// JS modules for <script type=module>
|
||||
const webModules = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/react-router.development.js`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
"@babel/preset-modules",
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("development") },
|
||||
}),
|
||||
validateReplacedVersion(),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/react-router.production.min.js`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-modules",
|
||||
{
|
||||
// Don't spoof `.name` for Arrow Functions, which breaks when minified anyway.
|
||||
loose: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
"@babel/preset-react",
|
||||
{
|
||||
// Compile JSX Spread to Object.assign(), which is reliable in ESM browsers.
|
||||
useBuiltIns: true,
|
||||
},
|
||||
],
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("production") },
|
||||
}),
|
||||
validateReplacedVersion(),
|
||||
terser({ ecma: 8, safari10: true }),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/dom-export.tsx`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/react-router-dom.development.js`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
"@babel/preset-modules",
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("development") },
|
||||
}),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/dom-export.tsx`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/react-router-dom.production.min.js`,
|
||||
format: "esm",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
[
|
||||
"@babel/preset-modules",
|
||||
{
|
||||
// Don't spoof `.name` for Arrow Functions, which breaks when minified anyway.
|
||||
loose: true,
|
||||
},
|
||||
],
|
||||
[
|
||||
"@babel/preset-react",
|
||||
{
|
||||
// Compile JSX Spread to Object.assign(), which is reliable in ESM browsers.
|
||||
useBuiltIns: true,
|
||||
},
|
||||
],
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("production") },
|
||||
}),
|
||||
terser({ ecma: 8, safari10: true }),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
];
|
||||
|
||||
// UMD modules for <script> tags and CommonJS (node)
|
||||
const globals = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/umd/react-router.development.js`,
|
||||
format: "umd",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
globals: {
|
||||
react: "React",
|
||||
},
|
||||
name: "ReactRouter",
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("development") },
|
||||
}),
|
||||
validateReplacedVersion(),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/index.ts`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/umd/react-router.production.min.js`,
|
||||
format: "umd",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
globals: {
|
||||
react: "React",
|
||||
},
|
||||
name: "ReactRouter",
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("production") },
|
||||
}),
|
||||
terser(),
|
||||
validateReplacedVersion(),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/dom-export.tsx`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/umd/react-router-dom.development.js`,
|
||||
format: "umd",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
globals: {
|
||||
react: "React",
|
||||
"react-router": "ReactRouter",
|
||||
},
|
||||
name: "ReactRouterDOMExport",
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("development") },
|
||||
}),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/dom-export.tsx`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/umd/react-router-dom.production.min.js`,
|
||||
format: "umd",
|
||||
sourcemap: !PRETTY,
|
||||
banner: createBanner("React Router", version),
|
||||
globals: {
|
||||
react: "React",
|
||||
"react-router": "ReactRouter",
|
||||
},
|
||||
name: "ReactRouterDomExport",
|
||||
},
|
||||
external: (id) => isBareModuleId(id),
|
||||
plugins: [
|
||||
nodeResolve({ extensions: [".tsx", ".ts"] }),
|
||||
babel({
|
||||
babelHelpers: "bundled",
|
||||
exclude: /node_modules/,
|
||||
presets: [
|
||||
["@babel/preset-env", { loose: true }],
|
||||
"@babel/preset-react",
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
plugins: [
|
||||
"babel-plugin-dev-expression",
|
||||
babelPluginReplaceVersionPlaceholder(),
|
||||
],
|
||||
extensions: [".ts", ".tsx"],
|
||||
}),
|
||||
replace({
|
||||
preventAssignment: true,
|
||||
values: { "process.env.NODE_ENV": JSON.stringify("production") },
|
||||
}),
|
||||
terser(),
|
||||
].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
];
|
||||
|
||||
// Node entry points
|
||||
const node = [
|
||||
{
|
||||
input: `${SOURCE_DIR}/node-main.js`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/main.js`,
|
||||
format: "cjs",
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
plugins: [].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
{
|
||||
input: `${SOURCE_DIR}/node-main-dom-export.js`,
|
||||
output: {
|
||||
file: `${OUTPUT_DIR}/main-dom-export.js`,
|
||||
format: "cjs",
|
||||
banner: createBanner("React Router", version),
|
||||
},
|
||||
plugins: [].concat(PRETTY ? prettier({ parser: "babel" }) : []),
|
||||
},
|
||||
];
|
||||
|
||||
return [...modules, ...webModules, ...globals, ...node];
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('rollup').InputOptions} RollupInputOptions
|
||||
* @typedef {import('rollup').OutputOptions} RollupOutputOptions
|
||||
* @typedef {import('rollup').RollupOptions} RollupOptions
|
||||
* @typedef {import('rollup').Plugin} RollupPlugin
|
||||
*/
|
@ -0,0 +1,44 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
// @ts-ignore - out of scope
|
||||
import { createBanner } from "../../build.utils.js";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const entry = ["index.ts", "dom-export.ts", "lib/types.ts"];
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
clean: false,
|
||||
entry,
|
||||
format: ["cjs"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
external: [
|
||||
/*.*/
|
||||
],
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
define: {
|
||||
"import.meta.hot": "undefined",
|
||||
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
|
||||
},
|
||||
},
|
||||
{
|
||||
clean: false,
|
||||
entry,
|
||||
format: ["esm"],
|
||||
outDir: "dist",
|
||||
dts: true,
|
||||
external: [
|
||||
/*.*/
|
||||
],
|
||||
banner: {
|
||||
js: createBanner(pkg.name, pkg.version),
|
||||
},
|
||||
define: {
|
||||
REACT_ROUTER_VERSION: JSON.stringify(pkg.version),
|
||||
},
|
||||
},
|
||||
]);
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue