mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat: sourcemap support
This commit is contained in:
parent
0742e0ff33
commit
daf0c3e6a5
@ -17,6 +17,7 @@ export interface SigmaContext {
|
|||||||
timing: boolean
|
timing: boolean
|
||||||
inlineChunks: boolean
|
inlineChunks: boolean
|
||||||
minify: boolean
|
minify: boolean
|
||||||
|
sourceMap: boolean
|
||||||
externals: boolean
|
externals: boolean
|
||||||
analyze: boolean
|
analyze: boolean
|
||||||
entry: string
|
entry: string
|
||||||
@ -66,6 +67,7 @@ export function getsigmaContext (nuxtOptions: NuxtOptions, input: SigmaInput): S
|
|||||||
timing: true,
|
timing: true,
|
||||||
inlineChunks: true,
|
inlineChunks: true,
|
||||||
minify: true,
|
minify: true,
|
||||||
|
sourceMap: false,
|
||||||
externals: false,
|
externals: false,
|
||||||
analyze: false,
|
analyze: false,
|
||||||
entry: undefined,
|
entry: undefined,
|
||||||
|
@ -10,5 +10,6 @@ export const local: SigmaPreset = extendPreset(node, {
|
|||||||
minify: false,
|
minify: false,
|
||||||
externals: true,
|
externals: true,
|
||||||
inlineChunks: true,
|
inlineChunks: true,
|
||||||
timing: true
|
timing: false,
|
||||||
|
sourceMap: true
|
||||||
})
|
})
|
||||||
|
@ -50,7 +50,10 @@ export const getRollupConfig = (sigmaContext: SigmaContext) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const env = un.env(nodePreset, builtinPreset, sigmaContext.env)
|
const env = un.env(nodePreset, builtinPreset, sigmaContext.env)
|
||||||
// console.log(env)
|
|
||||||
|
if (sigmaContext.sourceMap) {
|
||||||
|
env.polyfill.push('source-map-support/register')
|
||||||
|
}
|
||||||
|
|
||||||
const buildServerDir = join(sigmaContext._nuxt.buildDir, 'dist/server')
|
const buildServerDir = join(sigmaContext._nuxt.buildDir, 'dist/server')
|
||||||
const runtimeAppDir = join(sigmaContext._internal.runtimeDir, 'app')
|
const runtimeAppDir = join(sigmaContext._internal.runtimeDir, 'app')
|
||||||
@ -82,7 +85,12 @@ export const getRollupConfig = (sigmaContext: SigmaContext) => {
|
|||||||
exports: 'auto',
|
exports: 'auto',
|
||||||
intro: '',
|
intro: '',
|
||||||
outro: '',
|
outro: '',
|
||||||
preferConst: true
|
preferConst: true,
|
||||||
|
sourcemap: sigmaContext.sourceMap,
|
||||||
|
sourcemapExcludeSources: true,
|
||||||
|
sourcemapPathTransform (relativePath, sourcemapPath) {
|
||||||
|
return resolve(dirname(sourcemapPath), relativePath)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
external: env.external,
|
external: env.external,
|
||||||
plugins: [],
|
plugins: [],
|
||||||
@ -112,8 +120,10 @@ export const getRollupConfig = (sigmaContext: SigmaContext) => {
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// ESBuild (typescript)
|
// ESBuild
|
||||||
rollupConfig.plugins.push(esbuild({}))
|
rollupConfig.plugins.push(esbuild({
|
||||||
|
sourceMap: true
|
||||||
|
}))
|
||||||
|
|
||||||
// Dynamic Require Support
|
// Dynamic Require Support
|
||||||
rollupConfig.plugins.push(dynamicRequire({
|
rollupConfig.plugins.push(dynamicRequire({
|
||||||
|
@ -33,7 +33,10 @@ export function dynamicRequire ({ dir, globbyOptions, inline }: Options): Plugin
|
|||||||
return {
|
return {
|
||||||
name: PLUGIN_NAME,
|
name: PLUGIN_NAME,
|
||||||
transform (code: string, _id: string) {
|
transform (code: string, _id: string) {
|
||||||
return code.replace(DYNAMIC_REQUIRE_RE, `require('${HELPER_DYNAMIC}')(`)
|
return {
|
||||||
|
code: code.replace(DYNAMIC_REQUIRE_RE, `require('${HELPER_DYNAMIC}')(`),
|
||||||
|
map: null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
resolveId (id: string) {
|
resolveId (id: string) {
|
||||||
return id === HELPER_DYNAMIC ? id : null
|
return id === HELPER_DYNAMIC ? id : null
|
||||||
|
@ -6,7 +6,8 @@ import { startService, Loader, Service, TransformResult } from 'esbuild'
|
|||||||
import { createFilter, FilterPattern } from '@rollup/pluginutils'
|
import { createFilter, FilterPattern } from '@rollup/pluginutils'
|
||||||
|
|
||||||
const defaultLoaders: { [ext: string]: Loader } = {
|
const defaultLoaders: { [ext: string]: Loader } = {
|
||||||
'.ts': 'ts'
|
'.ts': 'ts',
|
||||||
|
'.js': 'js'
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Options = {
|
export type Options = {
|
||||||
|
@ -31,7 +31,10 @@ export function timing (_opts: Options = {}): Plugin {
|
|||||||
let name = chunk.fileName || ''
|
let name = chunk.fileName || ''
|
||||||
name = name.replace(extname(name), '')
|
name = name.replace(extname(name), '')
|
||||||
const logName = name === 'index' ? 'Cold Start' : ('Load ' + name)
|
const logName = name === 'index' ? 'Cold Start' : ('Load ' + name)
|
||||||
return "'use strict';" + (chunk.isEntry ? HELPER : '') + `${TIMING}.logStart('${logName}');` + code + `;${TIMING}.logEnd('${logName}');`
|
return {
|
||||||
|
code: (chunk.isEntry ? HELPER : '') + `${TIMING}.logStart('${logName}');` + code + `;${TIMING}.logEnd('${logName}');`,
|
||||||
|
map: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user