Skip to content

Commit

Permalink
fix(nitro): pass sourcemap option through to rollup plugins (#2387)
Browse files Browse the repository at this point in the history
Co-authored-by: Matteo Rigoni <matteo.rigoni@atoms.studio>
  • Loading branch information
danielroe and Rigo-m authored Dec 17, 2021
1 parent bc9817c commit 2122f5c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/rollup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
outro: '',
preferConst: true,
sanitizeFileName: sanitizeFilePath,
sourcemap: nitroContext.sourceMap,
sourcemap: !!nitroContext.sourceMap,
sourcemapExcludeSources: true,
sourcemapPathTransform (relativePath, sourcemapPath) {
return resolve(dirname(sourcemapPath), relativePath)
Expand Down Expand Up @@ -149,7 +149,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {

// https://github.com/rollup/plugins/tree/master/packages/replace
rollupConfig.plugins.push(replace({
// @ts-ignore https://github.com/rollup/plugins/pull/810
sourceMap: !!nitroContext.sourceMap,
preventAssignment: true,
values: {
'process.env.NODE_ENV': nitroContext._nuxt.dev ? '"development"' : '"production"',
Expand All @@ -172,7 +172,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
// ESBuild
rollupConfig.plugins.push(esbuild({
target: 'es2019',
sourceMap: true,
sourceMap: !!nitroContext.sourceMap,
...nitroContext.esbuild?.options
}))

Expand Down Expand Up @@ -298,6 +298,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {

// https://github.com/rollup/plugins/tree/master/packages/commonjs
rollupConfig.plugins.push(commonjs({
sourceMap: !!nitroContext.sourceMap,
esmExternals: id => !id.startsWith('unenv/'),
requireReturnsDefault: 'auto'
}))
Expand All @@ -306,7 +307,12 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
rollupConfig.plugins.push(json())

// https://github.com/rollup/plugins/tree/master/packages/inject
rollupConfig.plugins.push(inject(env.inject))
rollupConfig.plugins.push(inject({
// TODO: https://github.com/rollup/plugins/pull/1066
// @ts-ignore
sourceMap: !!nitroContext.sourceMap,
...env.inject
}))

// https://github.com/TrySound/rollup-plugin-terser
// https://github.com/terser/terser#minify-nitroContext
Expand Down

0 comments on commit 2122f5c

Please sign in to comment.