-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
fix: add router UMD build for unpkg #9446
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@remix-run/router": patch | ||
| --- | ||
|
|
||
| Add UMD build for @remix-run/router |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,13 +26,7 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router DOM", version), | ||
| }, | ||
| external: [ | ||
| "history", | ||
| "react", | ||
| "react-dom", | ||
| "react-router", | ||
| "@remix-run/router", | ||
| ], | ||
| external: ["react", "react-dom", "react-router", "@remix-run/router"], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| plugins: [ | ||
| extensions({ extensions: [".ts", ".tsx"] }), | ||
| babel({ | ||
|
|
@@ -73,7 +67,7 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router DOM", version), | ||
| }, | ||
| external: ["history", "react", "react-router", "@remix-run/router"], | ||
| external: ["react", "react-router", "@remix-run/router"], | ||
| plugins: [ | ||
| extensions({ extensions: [".ts", ".tsx"] }), | ||
| babel({ | ||
|
|
@@ -101,7 +95,7 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router DOM", version), | ||
| }, | ||
| external: ["history", "react", "react-router", "@remix-run/router"], | ||
| external: ["react", "react-router", "@remix-run/router"], | ||
| plugins: [ | ||
| extensions({ extensions: [".ts", ".tsx"] }), | ||
| babel({ | ||
|
|
@@ -147,14 +141,13 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router DOM", version), | ||
| globals: { | ||
| history: "HistoryLibrary", | ||
| "@remix-run/router": "Router", | ||
| "@remix-run/router": "RemixRouter", | ||
| react: "React", | ||
| "react-router": "ReactRouter", | ||
| }, | ||
| name: "ReactRouterDOM", | ||
| }, | ||
| external: ["history", "react", "react-router", "@remix-run/router"], | ||
| external: ["react", "react-router", "@remix-run/router"], | ||
| plugins: [ | ||
| extensions({ extensions: [".ts", ".tsx"] }), | ||
| babel({ | ||
|
|
@@ -182,14 +175,13 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router DOM", version), | ||
| globals: { | ||
| history: "HistoryLibrary", | ||
| "@remix-run/router": "Router", | ||
| "@remix-run/router": "RemixRouter", | ||
| react: "React", | ||
| "react-router": "ReactRouter", | ||
| }, | ||
| name: "ReactRouterDOM", | ||
| }, | ||
| external: ["history", "react", "react-router", "@remix-run/router"], | ||
| external: ["react", "react-router", "@remix-run/router"], | ||
| plugins: [ | ||
| extensions({ extensions: [".ts", ".tsx"] }), | ||
| babel({ | ||
|
|
@@ -240,7 +232,6 @@ module.exports = function rollup() { | |
| ], | ||
| external: [ | ||
| "url", | ||
| "history", | ||
| "react", | ||
| "react-dom/server", | ||
| "react-router-dom", | ||
|
|
@@ -284,7 +275,6 @@ module.exports = function rollup() { | |
| ], | ||
| external: [ | ||
| "url", | ||
| "history", | ||
| "react", | ||
| "react-dom/server", | ||
| "react-router-dom", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router", version), | ||
| }, | ||
| external: ["history", "@remix-run/router", "react"], | ||
| external: ["@remix-run/router", "react"], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for |
||
| plugins: [ | ||
| extensions({ extensions: [".tsx", ".ts"] }), | ||
| babel({ | ||
|
|
@@ -60,7 +60,7 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router", version), | ||
| }, | ||
| external: ["history", "@remix-run/router", "react"], | ||
| external: ["@remix-run/router", "react"], | ||
| plugins: [ | ||
| extensions({ extensions: [".tsx", ".ts"] }), | ||
| babel({ | ||
|
|
@@ -93,7 +93,7 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router", version), | ||
| }, | ||
| external: ["history", "@remix-run/router", "react"], | ||
| external: ["@remix-run/router", "react"], | ||
| plugins: [ | ||
| extensions({ extensions: [".tsx", ".ts"] }), | ||
| babel({ | ||
|
|
@@ -139,13 +139,12 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router", version), | ||
| globals: { | ||
| history: "HistoryLibrary", | ||
| "@remix-run/router": "Router", | ||
| "@remix-run/router": "RemixRouter", | ||
| react: "React", | ||
| }, | ||
| name: "ReactRouter", | ||
| }, | ||
| external: ["history", "@remix-run/router", "react"], | ||
| external: ["@remix-run/router", "react"], | ||
| plugins: [ | ||
| extensions({ extensions: [".tsx", ".ts"] }), | ||
| babel({ | ||
|
|
@@ -173,13 +172,12 @@ module.exports = function rollup() { | |
| sourcemap: !PRETTY, | ||
| banner: createBanner("React Router", version), | ||
| globals: { | ||
| history: "HistoryLibrary", | ||
| "@remix-run/router": "Router", | ||
| "@remix-run/router": "RemixRouter", | ||
| react: "React", | ||
| }, | ||
| name: "ReactRouter", | ||
| }, | ||
| external: ["history", "@remix-run/router", "react"], | ||
| external: ["@remix-run/router", "react"], | ||
| plugins: [ | ||
| extensions({ extensions: [".tsx", ".ts"] }), | ||
| babel({ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| "author": "Remix Software <[email protected]>", | ||
| "sideEffects": false, | ||
| "main": "./dist/router.cjs.js", | ||
| "unpkg": "./dist/router.umd.min.js", | ||
| "module": "./dist/router.js", | ||
| "types": "./dist/index.d.ts", | ||
| "files": [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,24 @@ | ||
| const path = require("path"); | ||
|
|
||
| const babel = require("@rollup/plugin-babel").default; | ||
| const typescript = require("@rollup/plugin-typescript"); | ||
| const copy = require("rollup-plugin-copy"); | ||
| const extensions = require("rollup-plugin-extensions"); | ||
| const prettier = require("rollup-plugin-prettier"); | ||
| const typescript = require("@rollup/plugin-typescript"); | ||
| const { terser } = require("rollup-plugin-terser"); | ||
|
|
||
| const { | ||
| createBanner, | ||
| getBuildDirectories, | ||
| PRETTY, | ||
| } = require("../../rollup.utils"); | ||
| const { name, version } = require("./package.json"); | ||
|
|
||
| function getRollupConfig(format, filename, includeTypesAndCopy = false) { | ||
| function getRollupConfig( | ||
| format, | ||
| filename, | ||
| { includeTypesAndCopy, minify } = {} | ||
| ) { | ||
| const { ROOT_DIR, SOURCE_DIR, OUTPUT_DIR } = getBuildDirectories( | ||
| name, | ||
| // We don't live in a folder matching our package name | ||
|
|
@@ -25,6 +32,7 @@ function getRollupConfig(format, filename, includeTypesAndCopy = false) { | |
| format, | ||
| sourcemap: !PRETTY, | ||
| banner: createBanner("@remix-run/router", version), | ||
| ...(format === "umd" ? { name: "RemixRouter" } : {}), | ||
| }, | ||
| plugins: [ | ||
| extensions({ extensions: [".ts"] }), | ||
|
|
@@ -37,7 +45,7 @@ function getRollupConfig(format, filename, includeTypesAndCopy = false) { | |
| ], | ||
| extensions: [".ts"], | ||
| }), | ||
| ...(includeTypesAndCopy | ||
| ...(includeTypesAndCopy === true | ||
| ? [ | ||
| typescript({ | ||
| tsconfig: path.join(__dirname, "tsconfig.json"), | ||
|
|
@@ -52,14 +60,17 @@ function getRollupConfig(format, filename, includeTypesAndCopy = false) { | |
| }), | ||
| ] | ||
| : []), | ||
| ...(minify === true ? [terser()] : []), | ||
| ].concat(PRETTY ? prettier({ parser: "babel" }) : []), | ||
| }; | ||
| } | ||
|
|
||
| module.exports = function rollup() { | ||
| return [ | ||
| getRollupConfig("esm", "router.js", true), | ||
| getRollupConfig("cjs", "router.cjs.js", false), | ||
| getRollupConfig("esm", "router.js", { includeTypesAndCopy: true }), | ||
| getRollupConfig("cjs", "router.cjs.js"), | ||
| getRollupConfig("umd", "router.umd.js"), | ||
| getRollupConfig("umd", "router.umd.min.js", { minify: true }), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add dev and prod UMD builds for |
||
| ]; | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UMD name for the build is
RemixRouterfor clarity -Routerfelt a bit vague 😄