From 8a22fa333ef00994ea44c85a7b9ba37fd02270cf Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 22 Feb 2021 13:12:59 +0100 Subject: [PATCH] feat: update preset options external tracing enabled by default for node. this change is potentially breaking demo --- packages/nitro/src/context.ts | 16 ++++++++-------- packages/nitro/src/presets/azure.ts | 1 - packages/nitro/src/presets/azure_functions.ts | 1 - packages/nitro/src/presets/cli.ts | 2 -- packages/nitro/src/presets/dev.ts | 4 +--- packages/nitro/src/presets/firebase.ts | 1 - packages/nitro/src/presets/lambda.ts | 2 +- packages/nitro/src/presets/netlify.ts | 1 - packages/nitro/src/presets/node.ts | 2 +- packages/nitro/src/presets/server.ts | 3 --- packages/nitro/src/presets/worker.ts | 2 ++ packages/nitro/src/rollup/config.ts | 4 ++-- 12 files changed, 15 insertions(+), 24 deletions(-) diff --git a/packages/nitro/src/context.ts b/packages/nitro/src/context.ts index f683e6b52f..cf8862df39 100644 --- a/packages/nitro/src/context.ts +++ b/packages/nitro/src/context.ts @@ -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: [], diff --git a/packages/nitro/src/presets/azure.ts b/packages/nitro/src/presets/azure.ts index 4f2bff248d..3f26610e58 100644 --- a/packages/nitro/src/presets/azure.ts +++ b/packages/nitro/src/presets/azure.ts @@ -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' diff --git a/packages/nitro/src/presets/azure_functions.ts b/packages/nitro/src/presets/azure_functions.ts index 3ba08dac28..fe664de2a8 100644 --- a/packages/nitro/src/presets/azure_functions.ts +++ b/packages/nitro/src/presets/azure_functions.ts @@ -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: { diff --git a/packages/nitro/src/presets/cli.ts b/packages/nitro/src/presets/cli.ts index 96c9045147..376cc67a0e 100644 --- a/packages/nitro/src/presets/cli.ts +++ b/packages/nitro/src/presets/cli.ts @@ -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]`') diff --git a/packages/nitro/src/presets/dev.ts b/packages/nitro/src/presets/dev.ts index 151e6e56b5..c74ad616bd 100644 --- a/packages/nitro/src/presets/dev.ts +++ b/packages/nitro/src/presets/dev.ts @@ -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 }) diff --git a/packages/nitro/src/presets/firebase.ts b/packages/nitro/src/presets/firebase.ts index 536aa577fb..4a5a9f2a5e 100644 --- a/packages/nitro/src/presets/firebase.ts +++ b/packages/nitro/src/presets/firebase.ts @@ -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) { diff --git a/packages/nitro/src/presets/lambda.ts b/packages/nitro/src/presets/lambda.ts index 318b3b5c01..36b6158fa3 100644 --- a/packages/nitro/src/presets/lambda.ts +++ b/packages/nitro/src/presets/lambda.ts @@ -3,5 +3,5 @@ import { NitroPreset } from '../context' export const lambda: NitroPreset = { entry: '{{ _internal.runtimeDir }}/entries/lambda', - inlineChunks: false + externals: true } diff --git a/packages/nitro/src/presets/netlify.ts b/packages/nitro/src/presets/netlify.ts index a707563e9c..b1e2919426 100644 --- a/packages/nitro/src/presets/netlify.ts +++ b/packages/nitro/src/presets/netlify.ts @@ -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' }, diff --git a/packages/nitro/src/presets/node.ts b/packages/nitro/src/presets/node.ts index 8e6719960b..a3230d6be3 100644 --- a/packages/nitro/src/presets/node.ts +++ b/packages/nitro/src/presets/node.ts @@ -2,5 +2,5 @@ import { NitroPreset } from '../context' export const node: NitroPreset = { entry: '{{ _internal.runtimeDir }}/entries/node', - inlineChunks: false + externals: true } diff --git a/packages/nitro/src/presets/server.ts b/packages/nitro/src/presets/server.ts index 7439b3c25e..468ea4081f 100644 --- a/packages/nitro/src/presets/server.ts +++ b/packages/nitro/src/presets/server.ts @@ -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))) diff --git a/packages/nitro/src/presets/worker.ts b/packages/nitro/src/presets/worker.ts index e235567080..2e082ea141 100644 --- a/packages/nitro/src/presets/worker.ts +++ b/packages/nitro/src/presets/worker.ts @@ -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' diff --git a/packages/nitro/src/rollup/config.ts b/packages/nitro/src/rollup/config.ts index 33db6b65d9..b293d3b59f 100644 --- a/packages/nitro/src/rollup/config.ts +++ b/packages/nitro/src/rollup/config.ts @@ -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'