Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
feat(vite): upgrade to vite 4 (#9238)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 12, 2022
1 parent 6d0c491 commit 5afcaca
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 464 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -36,7 +36,7 @@
"nuxt": "workspace:*",
"nuxt3": "workspace:nuxt@*",
"unbuild": "^1.0.2",
"vite": "^3.2.5",
"vite": "^4.0.0",
"vue": "3.2.45"
},
"devDependencies": {
Expand Down Expand Up @@ -72,7 +72,7 @@
"typescript": "^4.9.4",
"ufo": "^1.0.1",
"unbuild": "^1.0.2",
"vite": "^3.2.5",
"vite": "^4.0.0",
"vitest": "^0.25.7",
"vue-tsc": "^1.0.13"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/package.json
Expand Up @@ -61,7 +61,7 @@
"knitwork": "^1.0.0",
"magic-string": "^0.27.0",
"mlly": "^1.0.0",
"nitropack": "^1.0.0",
"nitropack": "npm:nitropack-edge@2.0.0-27847479.5831707",
"nuxi": "3.0.0",
"ohash": "^1.0.0",
"ofetch": "^1.0.0",
Expand Down
7 changes: 6 additions & 1 deletion packages/nuxt/src/app/components/layout.ts
Expand Up @@ -77,7 +77,12 @@ export default defineComponent({

// We avoid rendering layout transition if there is no layout to render
return _wrapIf(Transition, hasLayout && transitionProps, {
default: () => _wrapIf(LayoutLoader, hasLayout && { key: layout.value, name: layout.value, hasTransition: process.dev ? !!transitionProps : undefined, ...context.attrs }, context.slots).default()
default: () => _wrapIf(LayoutLoader, hasLayout && {
key: layout.value,
name: layout.value,
...(process.dev ? { hasTransition: !!transitionProps } : {}),
...context.attrs
}, context.slots).default()
}).default()
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/nuxt/src/core/nitro.ts
Expand Up @@ -91,7 +91,6 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
...nuxt.options.experimental.externalVue
? {}
: {

'vue/compiler-sfc': 'vue/compiler-sfc',
'vue/server-renderer': 'vue/server-renderer',
vue: await resolvePath(`vue/dist/vue.cjs${nuxt.options.dev ? '' : '.prod'}.js`)
Expand Down Expand Up @@ -121,6 +120,7 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
__VUE_PROD_DEVTOOLS__: false
},
rollupConfig: {
output: {},
plugins: []
}
})
Expand All @@ -141,6 +141,8 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
}

// Register nuxt protection patterns
nitroConfig.rollupConfig!.plugins = await nitroConfig.rollupConfig!.plugins || []
nitroConfig.rollupConfig!.plugins = Array.isArray(nitroConfig.rollupConfig!.plugins) ? nitroConfig.rollupConfig!.plugins : [nitroConfig.rollupConfig!.plugins]
nitroConfig.rollupConfig!.plugins!.push(
ImportProtectionPlugin.rollup({
rootDir: nuxt.options.rootDir,
Expand Down
6 changes: 3 additions & 3 deletions packages/schema/package.json
Expand Up @@ -17,10 +17,10 @@
"@types/lodash.template": "^4",
"@types/semver": "^7",
"@unhead/schema": "^1.0.13",
"@vitejs/plugin-vue": "^3.2.0",
"nitropack": "^1.0.0",
"@vitejs/plugin-vue": "^4.0.0",
"nitropack": "npm:nitropack-edge@2.0.0-27847479.5831707",
"unbuild": "latest",
"vite": "~3.2.5"
"vite": "~4.0.0"
},
"dependencies": {
"c12": "^1.1.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/vite/package.json
Expand Up @@ -21,8 +21,8 @@
"dependencies": {
"@nuxt/kit": "3.0.0",
"@rollup/plugin-replace": "^5.0.1",
"@vitejs/plugin-vue": "^3.2.0",
"@vitejs/plugin-vue-jsx": "^2.1.1",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"autoprefixer": "^10.4.13",
"chokidar": "^3.5.3",
"cssnano": "^5.1.14",
Expand All @@ -44,11 +44,11 @@
"postcss": "^8.4.20",
"postcss-import": "^15.1.0",
"postcss-url": "^10.1.3",
"rollup": "^2.79.1",
"rollup": "^3.7.3",
"rollup-plugin-visualizer": "^5.8.3",
"ufo": "^1.0.1",
"unplugin": "^1.0.1",
"vite": "~3.2.5",
"vite": "~4.0.0",
"vite-node": "^0.25.7",
"vite-plugin-checker": "^0.5.2",
"vue-bundle-renderer": "^1.0.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/vite/src/server.ts
Expand Up @@ -83,10 +83,10 @@ export async function buildServer (ctx: ViteBuildContext) {
external: ['#internal/nitro', ...ctx.nuxt.options.experimental.externalVue ? ['vue', 'vue-router'] : []],
output: {
entryFileNames: 'server.mjs',
preferConst: true,
// TODO: https://github.com/vitejs/vite/pull/8641
inlineDynamicImports: !ctx.nuxt.options.experimental.viteServerDynamicImports,
format: 'module'
format: 'module',
generatedCode: {
constBindings: true
}
},
onwarn (warning, rollupWarn) {
if (warning.code && ['UNUSED_EXTERNAL_IMPORT'].includes(warning.code)) {
Expand Down

0 comments on commit 5afcaca

Please sign in to comment.