mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
feat: sourcemap support
This commit is contained in:
parent
0742e0ff33
commit
daf0c3e6a5
@ -17,6 +17,7 @@ export interface SigmaContext {
|
||||
timing: boolean
|
||||
inlineChunks: boolean
|
||||
minify: boolean
|
||||
sourceMap: boolean
|
||||
externals: boolean
|
||||
analyze: boolean
|
||||
entry: string
|
||||
@ -66,6 +67,7 @@ export function getsigmaContext (nuxtOptions: NuxtOptions, input: SigmaInput): S
|
||||
timing: true,
|
||||
inlineChunks: true,
|
||||
minify: true,
|
||||
sourceMap: false,
|
||||
externals: false,
|
||||
analyze: false,
|
||||
entry: undefined,
|
||||
|
@ -10,5 +10,6 @@ export const local: SigmaPreset = extendPreset(node, {
|
||||
minify: false,
|
||||
externals: 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)
|
||||
// console.log(env)
|
||||
|
||||
if (sigmaContext.sourceMap) {
|
||||
env.polyfill.push('source-map-support/register')
|
||||
}
|
||||
|
||||
const buildServerDir = join(sigmaContext._nuxt.buildDir, 'dist/server')
|
||||
const runtimeAppDir = join(sigmaContext._internal.runtimeDir, 'app')
|
||||
@ -82,7 +85,12 @@ export const getRollupConfig = (sigmaContext: SigmaContext) => {
|
||||
exports: 'auto',
|
||||
intro: '',
|
||||
outro: '',
|
||||
preferConst: true
|
||||
preferConst: true,
|
||||
sourcemap: sigmaContext.sourceMap,
|
||||
sourcemapExcludeSources: true,
|
||||
sourcemapPathTransform (relativePath, sourcemapPath) {
|
||||
return resolve(dirname(sourcemapPath), relativePath)
|
||||
}
|
||||
},
|
||||
external: env.external,
|
||||
plugins: [],
|
||||
@ -112,8 +120,10 @@ export const getRollupConfig = (sigmaContext: SigmaContext) => {
|
||||
}
|
||||
}))
|
||||
|
||||
// ESBuild (typescript)
|
||||
rollupConfig.plugins.push(esbuild({}))
|
||||
// ESBuild
|
||||
rollupConfig.plugins.push(esbuild({
|
||||
sourceMap: true
|
||||
}))
|
||||
|
||||
// Dynamic Require Support
|
||||
rollupConfig.plugins.push(dynamicRequire({
|
||||
|
@ -33,7 +33,10 @@ export function dynamicRequire ({ dir, globbyOptions, inline }: Options): Plugin
|
||||
return {
|
||||
name: PLUGIN_NAME,
|
||||
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) {
|
||||
return id === HELPER_DYNAMIC ? id : null
|
||||
|
@ -6,7 +6,8 @@ import { startService, Loader, Service, TransformResult } from 'esbuild'
|
||||
import { createFilter, FilterPattern } from '@rollup/pluginutils'
|
||||
|
||||
const defaultLoaders: { [ext: string]: Loader } = {
|
||||
'.ts': 'ts'
|
||||
'.ts': 'ts',
|
||||
'.js': 'js'
|
||||
}
|
||||
|
||||
export type Options = {
|
||||
|
@ -31,7 +31,10 @@ export function timing (_opts: Options = {}): Plugin {
|
||||
let name = chunk.fileName || ''
|
||||
name = name.replace(extname(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