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 { export interface NitroContext {
timing: boolean timing: boolean
inlineChunks: boolean inlineDynamicImports: boolean
minify: boolean minify: boolean
sourceMap: boolean sourceMap: boolean
externals: boolean | NodeExternalsOptions externals: boolean | NodeExternalsOptions
@ -62,18 +62,18 @@ export type NitroPreset = NitroInput | ((input: NitroInput) => NitroInput)
export function getNitroContext (nuxtOptions: NuxtOptions, input: NitroInput): NitroContext { export function getNitroContext (nuxtOptions: NuxtOptions, input: NitroInput): NitroContext {
const defaults: NitroContext = { const defaults: NitroContext = {
timing: true, timing: undefined,
inlineChunks: true, inlineDynamicImports: undefined,
minify: true, minify: undefined,
sourceMap: false, sourceMap: undefined,
externals: false, externals: undefined,
analyze: false, analyze: undefined,
entry: undefined, entry: undefined,
node: undefined, node: undefined,
preset: undefined, preset: undefined,
rollupConfig: undefined, rollupConfig: undefined,
renderer: undefined, renderer: undefined,
serveStatic: false, serveStatic: undefined,
middleware: [], middleware: [],
scannedMiddleware: [], scannedMiddleware: [],
ignore: [], ignore: [],

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,5 +2,5 @@ import { NitroPreset } from '../context'
export const node: NitroPreset = { export const node: NitroPreset = {
entry: '{{ _internal.runtimeDir }}/entries/node', 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, { export const server: NitroPreset = extendPreset(node, {
entry: '{{ _internal.runtimeDir }}/entries/server', entry: '{{ _internal.runtimeDir }}/entries/server',
externals: false,
inlineChunks: false,
serveStatic: true, serveStatic: true,
minify: false,
hooks: { hooks: {
'nitro:compiled' ({ output }: NitroContext) { 'nitro:compiled' ({ output }: NitroContext) {
consola.success('Ready to run', hl('node ' + prettyPath(output.serverDir))) 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 = { export const worker: NitroPreset = {
entry: null, // Abstract entry: null, // Abstract
node: false, node: false,
minify: true,
inlineDynamicImports: true, // iffe does not support code-splitting
hooks: { hooks: {
'nitro:rollup:before' ({ rollupConfig }: NitroContext) { 'nitro:rollup:before' ({ rollupConfig }: NitroContext) {
rollupConfig.output.format = 'iife' rollupConfig.output.format = 'iife'

View File

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