diff --git a/packages/config/src/config/render.js b/packages/config/src/config/render.js index 15d82a5b53..1f9087996d 100644 --- a/packages/config/src/config/render.js +++ b/packages/config/src/config/render.js @@ -3,7 +3,8 @@ export default () => ({ bundleRenderer: { shouldPrefetch: () => false, - shouldPreload: (fileWithoutQuery, asType) => ['script', 'style'].includes(asType) + shouldPreload: (fileWithoutQuery, asType) => ['script', 'style'].includes(asType), + runInNewContext: undefined }, resourceHints: true, ssr: undefined, diff --git a/packages/config/src/options.js b/packages/config/src/options.js index 0d6b0a8ea0..3e4367b3bb 100644 --- a/packages/config/src/options.js +++ b/packages/config/src/options.js @@ -341,5 +341,11 @@ export function getNuxtConfig(_options) { consola.level = 0 } + // Use runInNewContext for dev mode by default + const { bundleRenderer } = options.render + if (typeof bundleRenderer.runInNewContext === 'undefined') { + bundleRenderer.runInNewContext = options.dev + } + return options } diff --git a/packages/vue-renderer/src/renderer.js b/packages/vue-renderer/src/renderer.js index 5442b1c998..6d1d3fa99c 100644 --- a/packages/vue-renderer/src/renderer.js +++ b/packages/vue-renderer/src/renderer.js @@ -244,7 +244,6 @@ export default class VueRenderer { const hasModules = fs.existsSync(path.resolve(this.context.options.rootDir, 'node_modules')) const rendererOptions = { - runInNewContext: false, clientManifest: this.context.resources.clientManifest, // for globally installed nuxt command, search dependencies in global dir basedir: hasModules ? this.context.options.rootDir : __dirname,