feat: update preset options

external tracing enabled by default for node. this change is potentially breaking demo
This commit is contained in:
Pooya Parsa 2021-02-22 13:12:59 +01:00
parent eebdb2870a
commit 8a22fa333e
12 changed files with 15 additions and 24 deletions

View File

@ -10,7 +10,7 @@ import type { ServerMiddleware } from './server/middleware'
export interface NitroContext {
timing: boolean
inlineChunks: boolean
inlineDynamicImports: boolean
minify: boolean
sourceMap: boolean
externals: boolean | NodeExternalsOptions
@ -62,18 +62,18 @@ export type NitroPreset = NitroInput | ((input: NitroInput) => NitroInput)
export function getNitroContext (nuxtOptions: NuxtOptions, input: NitroInput): NitroContext {
const defaults: NitroContext = {
timing: true,
inlineChunks: true,
minify: true,
sourceMap: false,
externals: false,
analyze: false,
timing: undefined,
inlineDynamicImports: undefined,
minify: undefined,
sourceMap: undefined,
externals: undefined,
analyze: undefined,
entry: undefined,
node: undefined,
preset: undefined,
rollupConfig: undefined,
renderer: undefined,
serveStatic: false,
serveStatic: undefined,
middleware: [],
scannedMiddleware: [],
ignore: [],

View File

@ -6,7 +6,6 @@ import { writeFile } from '../utils'
import { NitroPreset, NitroContext } from '../context'
export const azure: NitroPreset = {
inlineChunks: false,
entry: '{{ _internal.runtimeDir }}/entries/azure',
output: {
serverDir: '{{ output.dir }}/server/functions'

View File

@ -7,7 +7,6 @@ import { NitroPreset, NitroContext } from '../context'
// eslint-disable-next-line
export const azure_functions: NitroPreset = {
inlineChunks: false,
serveStatic: true,
entry: '{{ _internal.runtimeDir }}/entries/azure_functions',
hooks: {

View File

@ -5,8 +5,6 @@ import { node } from './node'
export const cli: NitroPreset = extendPreset(node, {
entry: '{{ _internal.runtimeDir }}/entries/cli',
externals: true,
inlineChunks: true,
hooks: {
'nitro:compiled' ({ output }: NitroContext) {
consola.info('Run with `node ' + prettyPath(output.serverDir) + ' [route]`')

View File

@ -7,9 +7,7 @@ export const dev: NitroPreset = extendPreset(node, {
output: {
serverDir: '{{ _nuxt.buildDir }}/nitro'
},
minify: false,
externals: { trace: false },
inlineChunks: true,
timing: false,
inlineDynamicImports: true, // externals plugin limitation
sourceMap: true
})

View File

@ -7,7 +7,6 @@ import { writeFile } from '../utils'
import { NitroPreset, NitroContext } from '../context'
export const firebase: NitroPreset = {
inlineChunks: false,
entry: '{{ _internal.runtimeDir }}/entries/firebase',
hooks: {
async 'nitro:compiled' (ctx: NitroContext) {

View File

@ -3,5 +3,5 @@ import { NitroPreset } from '../context'
export const lambda: NitroPreset = {
entry: '{{ _internal.runtimeDir }}/entries/lambda',
inlineChunks: false
externals: true
}

View File

@ -3,7 +3,6 @@ import { NitroPreset } from '../context'
import { lambda } from './lambda'
export const netlify: NitroPreset = extendPreset(lambda, {
// @ts-ignore
output: {
publicDir: '{{ _nuxt.rootDir }}/dist'
},

View File

@ -2,5 +2,5 @@ import { NitroPreset } from '../context'
export const node: NitroPreset = {
entry: '{{ _internal.runtimeDir }}/entries/node',
inlineChunks: false
externals: true
}

View File

@ -5,10 +5,7 @@ import { node } from './node'
export const server: NitroPreset = extendPreset(node, {
entry: '{{ _internal.runtimeDir }}/entries/server',
externals: false,
inlineChunks: false,
serveStatic: true,
minify: false,
hooks: {
'nitro:compiled' ({ output }: NitroContext) {
consola.success('Ready to run', hl('node ' + prettyPath(output.serverDir)))

View File

@ -3,6 +3,8 @@ import { NitroPreset, NitroContext } from '../context'
export const worker: NitroPreset = {
entry: null, // Abstract
node: false,
minify: true,
inlineDynamicImports: true, // iffe does not support code-splitting
hooks: {
'nitro:rollup:before' ({ rollupConfig }: NitroContext) {
rollupConfig.output.format = 'iife'

View File

@ -84,7 +84,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
}
return join('chunks', prefix, '[name].js')
},
inlineDynamicImports: nitroContext.inlineChunks,
inlineDynamicImports: nitroContext.inlineDynamicImports,
format: 'cjs',
exports: 'auto',
intro: '',
@ -135,7 +135,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
// Dynamic Require Support
rollupConfig.plugins.push(dynamicRequire({
dir: resolve(nitroContext._nuxt.buildDir, 'dist/server'),
inline: nitroContext.node === false || nitroContext.inlineChunks,
inline: nitroContext.node === false || nitroContext.inlineDynamicImports,
globbyOptions: {
ignore: [
'server.js'