fix(nuxt): add viteServerDynamicImports as experimental flag (#6433)

This commit is contained in:
pooya parsa 2022-08-08 15:25:58 +02:00 committed by GitHub
parent 4ec68db323
commit ee36ddf516
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 10 deletions

View File

@ -30,5 +30,14 @@ export default {
* @see https://github.com/nuxt/framework/pull/5750 * @see https://github.com/nuxt/framework/pull/5750
*/ */
treeshakeClientOnly: false, treeshakeClientOnly: false,
/**
* Split server bundle into multiple chunks and dynamically import them
*
* Note: Enabling this flag can cause hydration issues in some platform.
*
* @see https://github.com/nuxt/framework/issues/6432
*/
viteServerDynamicImports: false,
} }
} }

View File

@ -46,7 +46,6 @@
"postcss-url": "^10.1.3", "postcss-url": "^10.1.3",
"rollup": "^2.77.2", "rollup": "^2.77.2",
"rollup-plugin-visualizer": "^5.7.1", "rollup-plugin-visualizer": "^5.7.1",
"std-env": "^3.1.1",
"ufo": "^0.8.5", "ufo": "^0.8.5",
"unplugin": "^0.8.1", "unplugin": "^0.8.1",
"vite": "~3.0.4", "vite": "~3.0.4",

View File

@ -2,11 +2,9 @@ import { resolveTSConfig } from 'pkg-types'
import { resolve } from 'pathe' import { resolve } from 'pathe'
import * as vite from 'vite' import * as vite from 'vite'
import vuePlugin from '@vitejs/plugin-vue' import vuePlugin from '@vitejs/plugin-vue'
import { provider } from 'std-env'
import viteJsxPlugin from '@vitejs/plugin-vue-jsx' import viteJsxPlugin from '@vitejs/plugin-vue-jsx'
import { logger, resolveModule } from '@nuxt/kit' import { logger, resolveModule } from '@nuxt/kit'
import { joinURL, withoutLeadingSlash, withTrailingSlash } from 'ufo' import { joinURL, withoutLeadingSlash, withTrailingSlash } from 'ufo'
import type { OutputOptions } from 'rollup'
import { ViteBuildContext, ViteOptions } from './vite' import { ViteBuildContext, ViteOptions } from './vite'
import { wpfs } from './utils/wpfs' import { wpfs } from './utils/wpfs'
import { cacheDirPlugin } from './plugins/cache-dir' import { cacheDirPlugin } from './plugins/cache-dir'
@ -80,7 +78,7 @@ export async function buildServer (ctx: ViteBuildContext) {
entryFileNames: 'server.mjs', entryFileNames: 'server.mjs',
preferConst: true, preferConst: true,
// TODO: https://github.com/vitejs/vite/pull/8641 // TODO: https://github.com/vitejs/vite/pull/8641
inlineDynamicImports: false, inlineDynamicImports: !ctx.nuxt.options.experimental.viteServerDynamicImports,
format: 'module' format: 'module'
}, },
onwarn (warning, rollupWarn) { onwarn (warning, rollupWarn) {
@ -112,11 +110,6 @@ export async function buildServer (ctx: ViteBuildContext) {
})) }))
} }
// Hotfix for https://github.com/nuxt/framework/issues/6204
if (provider === 'netlify') {
(serverConfig.build.rollupOptions.output as OutputOptions).inlineDynamicImports = true
}
await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true }) await ctx.nuxt.callHook('vite:extendConfig', serverConfig, { isClient: false, isServer: true })
const onBuild = () => ctx.nuxt.callHook('build:resources', wpfs) const onBuild = () => ctx.nuxt.callHook('build:resources', wpfs)

View File

@ -1886,7 +1886,6 @@ __metadata:
postcss-url: ^10.1.3 postcss-url: ^10.1.3
rollup: ^2.77.2 rollup: ^2.77.2
rollup-plugin-visualizer: ^5.7.1 rollup-plugin-visualizer: ^5.7.1
std-env: ^3.1.1
ufo: ^0.8.5 ufo: ^0.8.5
unbuild: latest unbuild: latest
unplugin: ^0.8.1 unplugin: ^0.8.1