Skip to content

Commit

Permalink
build: add sourcemaps (#6823)
Browse files Browse the repository at this point in the history
  • Loading branch information
justingrant authored and timdorr committed Jul 10, 2019
1 parent bd20643 commit 7ccbd7e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
2 changes: 2 additions & 0 deletions packages/react-router-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"esm",
"index.js",
"matchRoutes.js",
"modules/*.js",
"modules/utils/*.js",
"renderRoutes.js",
"warnAboutDeprecatedCJSRequire.js",
"umd"
Expand Down
24 changes: 19 additions & 5 deletions packages/react-router-config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ function isBareModuleId(id) {
const cjs = [
{
input: "modules/index.js",
output: { file: `cjs/${pkg.name}.js`, format: "cjs", esModule: false },
output: {
file: `cjs/${pkg.name}.js`,
sourcemap: true,
format: "cjs",
esModule: false
},
external: isBareModuleId,
plugins: [
babel({ exclude: /node_modules/ }),
babel({ exclude: /node_modules/, sourceMaps: true }),
replace({ "process.env.NODE_ENV": JSON.stringify("development") })
]
},
{
input: "modules/index.js",
output: { file: `cjs/${pkg.name}.min.js`, format: "cjs" },
output: { file: `cjs/${pkg.name}.min.js`, sourcemap: true, format: "cjs" },
external: isBareModuleId,
plugins: [
babel({ exclude: /node_modules/ }),
babel({ exclude: /node_modules/, sourceMaps: true }),
replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
uglify()
]
Expand All @@ -38,11 +43,12 @@ const cjs = [
const esm = [
{
input: "modules/index.js",
output: { file: `esm/${pkg.name}.js`, format: "esm" },
output: { file: `esm/${pkg.name}.js`, sourcemap: true, format: "esm" },
external: isBareModuleId,
plugins: [
babel({
exclude: /node_modules/,
sourceMaps: true,
runtimeHelpers: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
Expand All @@ -58,6 +64,9 @@ const umd = [
input: "modules/index.js",
output: {
file: `umd/${pkg.name}.js`,
sourcemap: true,
sourcemapPathTransform: relativePath =>
relativePath.replace(/^.*?\/node_modules/, "../../node_modules"),
format: "umd",
name: "ReactRouterConfig",
globals
Expand All @@ -67,6 +76,7 @@ const umd = [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
nodeResolve(),
Expand All @@ -79,6 +89,9 @@ const umd = [
input: "modules/index.js",
output: {
file: `umd/${pkg.name}.min.js`,
sourcemap: true,
sourcemapPathTransform: relativePath =>
relativePath.replace(/^.*?\/node_modules/, "../../node_modules"),
format: "umd",
name: "ReactRouterConfig",
globals
Expand All @@ -88,6 +101,7 @@ const umd = [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
nodeResolve(),
Expand Down
2 changes: 2 additions & 0 deletions packages/react-router-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"index.js",
"generatePath.js",
"matchPath.js",
"modules/*.js",
"modules/utils/*.js",
"withRouter.js",
"warnAboutDeprecatedCJSRequire.js",
"umd"
Expand Down
24 changes: 19 additions & 5 deletions packages/react-router-dom/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ function isBareModuleId(id) {
const cjs = [
{
input: "modules/index.js",
output: { file: `cjs/${pkg.name}.js`, format: "cjs", esModule: false },
output: {
file: `cjs/${pkg.name}.js`,
sourcemap: true,
format: "cjs",
esModule: false
},
external: isBareModuleId,
plugins: [
babel({ exclude: /node_modules/ }),
babel({ exclude: /node_modules/, sourceMaps: true }),
replace({ "process.env.NODE_ENV": JSON.stringify("development") })
]
},
{
input: "modules/index.js",
output: { file: `cjs/${pkg.name}.min.js`, format: "cjs" },
output: { file: `cjs/${pkg.name}.min.js`, sourcemap: true, format: "cjs" },
external: isBareModuleId,
plugins: [
babel({ exclude: /node_modules/ }),
babel({ exclude: /node_modules/, sourceMaps: true }),
replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
uglify()
]
Expand All @@ -38,12 +43,13 @@ const cjs = [
const esm = [
{
input: "modules/index.js",
output: { file: `esm/${pkg.name}.js`, format: "esm" },
output: { file: `esm/${pkg.name}.js`, sourcemap: true, format: "esm" },
external: isBareModuleId,
plugins: [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
sizeSnapshot()
Expand All @@ -58,6 +64,9 @@ const umd = [
input: "modules/index.js",
output: {
file: `umd/${pkg.name}.js`,
sourcemap: true,
sourcemapPathTransform: relativePath =>
relativePath.replace(/^.*?\/node_modules/, "../../node_modules"),
format: "umd",
name: "ReactRouterDOM",
globals
Expand All @@ -67,6 +76,7 @@ const umd = [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
nodeResolve(),
Expand All @@ -86,6 +96,9 @@ const umd = [
input: "modules/index.js",
output: {
file: `umd/${pkg.name}.min.js`,
sourcemap: true,
sourcemapPathTransform: relativePath =>
relativePath.replace(/^.*?\/node_modules/, "../../node_modules"),
format: "umd",
name: "ReactRouterDOM",
globals
Expand All @@ -95,6 +108,7 @@ const umd = [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
nodeResolve(),
Expand Down
2 changes: 2 additions & 0 deletions packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"index.js",
"generatePath.js",
"matchPath.js",
"modules/*.js",
"modules/utils/*.js",
"withRouter.js",
"warnAboutDeprecatedCJSRequire.js",
"umd"
Expand Down
24 changes: 19 additions & 5 deletions packages/react-router/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ function isBareModuleId(id) {
const cjs = [
{
input: "modules/index.js",
output: { file: `cjs/${pkg.name}.js`, format: "cjs", esModule: false },
output: {
file: `cjs/${pkg.name}.js`,
sourcemap: true,
format: "cjs",
esModule: false
},
external: isBareModuleId,
plugins: [
babel({ exclude: /node_modules/ }),
babel({ exclude: /node_modules/, sourceMaps: true }),
replace({
"process.env.NODE_ENV": JSON.stringify("development"),
"process.env.BUILD_FORMAT": JSON.stringify("cjs")
Expand All @@ -28,10 +33,10 @@ const cjs = [
},
{
input: "modules/index.js",
output: { file: `cjs/${pkg.name}.min.js`, format: "cjs" },
output: { file: `cjs/${pkg.name}.min.js`, sourcemap: true, format: "cjs" },
external: isBareModuleId,
plugins: [
babel({ exclude: /node_modules/ }),
babel({ exclude: /node_modules/, sourceMaps: true }),
replace({
"process.env.NODE_ENV": JSON.stringify("production"),
"process.env.BUILD_FORMAT": JSON.stringify("cjs")
Expand All @@ -44,12 +49,13 @@ const cjs = [
const esm = [
{
input: "modules/index.js",
output: { file: `esm/${pkg.name}.js`, format: "esm" },
output: { file: `esm/${pkg.name}.js`, sourcemap: true, format: "esm" },
external: isBareModuleId,
plugins: [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
replace({ "process.env.BUILD_FORMAT": JSON.stringify("esm") }),
Expand All @@ -65,6 +71,9 @@ const umd = [
input: "modules/index.js",
output: {
file: `umd/${pkg.name}.js`,
sourcemap: true,
sourcemapPathTransform: relativePath =>
relativePath.replace(/^.*?\/node_modules/, "../../node_modules"),
format: "umd",
name: "ReactRouter",
globals
Expand All @@ -74,6 +83,7 @@ const umd = [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
nodeResolve(),
Expand All @@ -94,6 +104,9 @@ const umd = [
input: "modules/index.js",
output: {
file: `umd/${pkg.name}.min.js`,
sourcemap: true,
sourcemapPathTransform: relativePath =>
relativePath.replace(/^.*?\/node_modules/, "../../node_modules"),
format: "umd",
name: "ReactRouter",
globals
Expand All @@ -103,6 +116,7 @@ const umd = [
babel({
exclude: /node_modules/,
runtimeHelpers: true,
sourceMaps: true,
plugins: [["@babel/transform-runtime", { useESModules: true }]]
}),
nodeResolve(),
Expand Down

0 comments on commit 7ccbd7e

Please sign in to comment.