Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schema): update webpack transformAssetUrls + pass hoistStatic to vite plugin #26563

Merged
merged 5 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/schema/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default defineBuildConfig({
'@vue/language-core',
// Implicit
'@vue/compiler-core',
'@vue/compiler-sfc',
'@vue/shared',
'untyped'
]
Expand Down
1 change: 1 addition & 0 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@vitejs/plugin-vue": "5.0.4",
"@vitejs/plugin-vue-jsx": "3.1.0",
"@vue/compiler-core": "3.4.21",
"@vue/compiler-sfc": "^3.4.21",
"@vue/language-core": "2.0.7",
"c12": "1.10.0",
"esbuild-loader": "4.1.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/schema/src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ export default defineUntypedSchema({
* Vue.js config
*/
vue: {
/** @type {typeof import('@vue/compiler-sfc').AssetURLTagConfig} */
transformAssetUrls: {
video: ['src', 'poster'],
source: ['src'],
img: ['src'],
image: ['xlink:href', 'href'],
use: ['xlink:href', 'href']
},
/**
* Options for the Vue compiler that will be passed at build time.
* @see [documentation](https://vuejs.org/api/application.html#app-config-compileroptions)
Expand Down
1 change: 1 addition & 0 deletions packages/schema/src/config/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default defineUntypedSchema({
'@unhead/vue',
'vue',
'@vue/runtime-core',
'@vue/compiler-sfc',
'@vue/runtime-dom',
'vue-router',
'@nuxt/schema',
Expand Down
6 changes: 6 additions & 0 deletions packages/schema/src/config/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,17 @@ export default defineUntypedSchema({
template: {
compilerOptions: {
$resolve: async (val, get) => val ?? (await get('vue') as Record<string, any>).compilerOptions
},
transformAssetUrls: {
$resolve: async (val, get) => val ?? (await get('vue') as Record<string, any>).transformAssetUrls
}
},
script: {
propsDestructure: {
$resolve: async (val, get) => val ?? Boolean((await get('vue') as Record<string, any>).propsDestructure)
},
hoistStatic: {
$resolve: async (val, get) => val ?? (await get('vue') as Record<string, any>).compilerOptions?.hoistStatic
}
}
},
Expand Down
16 changes: 9 additions & 7 deletions packages/schema/src/config/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defu } from 'defu'
import { defineUntypedSchema } from 'untyped'
import type { VueLoaderOptions } from 'vue-loader'

export default defineUntypedSchema({
webpack: {
Expand Down Expand Up @@ -200,14 +201,15 @@ export default defineUntypedSchema({
*/
vue: {
transformAssetUrls: {
video: 'src',
source: 'src',
object: 'src',
embed: 'src'
$resolve: async (val, get) => (val ?? (await get('vue.transformAssetUrls'))) as VueLoaderOptions['transformAssetUrls']
danielroe marked this conversation as resolved.
Show resolved Hide resolved
},
compilerOptions: { $resolve: async (val, get) => val ?? (await get('vue.compilerOptions')) },
propsDestructure: { $resolve: async (val, get) => val ?? Boolean(await get('vue.propsDestructure')) }
},
compilerOptions: {
$resolve: async (val, get) => (val ?? (await get('vue.compilerOptions'))) as VueLoaderOptions['compilerOptions']
},
propsDestructure: {
$resolve: async (val, get) => Boolean(val ?? await get('vue.propsDestructure'))
}
} satisfies { [K in keyof VueLoaderOptions]: { $resolve: (val: unknown, get: (id: string) => Promise<unknown>) => Promise<VueLoaderOptions[K]> } },

css: {
importLoaders: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export type NuxtConfigLayer = ConfigLayer<NuxtConfig & {
}>

export interface NuxtBuilder {
bundle: (nuxt: Nuxt) => Promise<void>
bundle: (nuxt: Nuxt) => Promise<void>
}

// Normalized Nuxt options available as `nuxt.options.*`
Expand Down
11 changes: 0 additions & 11 deletions packages/vite/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,6 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
}),
virtual(nuxt.vfs)
],
vue: {
template: {
transformAssetUrls: {
video: ['src', 'poster'],
source: ['src'],
img: ['src'],
image: ['xlink:href', 'href'],
use: ['xlink:href', 'href']
}
}
},
server: {
watch: { ignored: isIgnored },
fs: {
Expand Down
10 changes: 7 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.