mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
refactor(nuxt): add additional flag to enable remote sources (#22409)
This commit is contained in:
parent
dad633b658
commit
1b1f194e64
@ -13,6 +13,9 @@ import { getFragmentHTML, getSlotProps } from './utils'
|
||||
import { useNuxtApp, useRuntimeConfig } from '#app/nuxt'
|
||||
import { useRequestEvent } from '#app/composables/ssr'
|
||||
|
||||
// @ts-expect-error virtual file
|
||||
import { remoteComponentIslands } from '#build/nuxt.config.mjs'
|
||||
|
||||
const pKey = '_islandPromises'
|
||||
const SSR_UID_RE = /nuxt-ssr-component-uid="([^"]*)"/
|
||||
const UID_ATTR = /nuxt-ssr-component-uid(="([^"]*)")?/
|
||||
@ -106,7 +109,7 @@ export default defineComponent({
|
||||
const key = `${props.name}_${hashId.value}`
|
||||
if (nuxtApp.payload.data[key] && !force) { return nuxtApp.payload.data[key] }
|
||||
|
||||
const url = props.source ? new URL(`/__nuxt_island/${key}`, props.source).href : `/__nuxt_island/${key}`
|
||||
const url = remoteComponentIslands && props.source ? new URL(`/__nuxt_island/${key}`, props.source).href : `/__nuxt_island/${key}`
|
||||
|
||||
if (process.server && process.env.prerender) {
|
||||
// Hint to Nitro to prerender the island component
|
||||
|
@ -221,7 +221,7 @@ export default defineNuxtModule<ComponentsOptions>({
|
||||
getComponents,
|
||||
mode,
|
||||
transform: typeof nuxt.options.components === 'object' && !Array.isArray(nuxt.options.components) ? nuxt.options.components.transform : undefined,
|
||||
experimentalComponentIslands: nuxt.options.experimental.componentIslands
|
||||
experimentalComponentIslands: !!nuxt.options.experimental.componentIslands
|
||||
}))
|
||||
|
||||
if (isServer && nuxt.options.experimental.componentIslands) {
|
||||
@ -265,7 +265,7 @@ export default defineNuxtModule<ComponentsOptions>({
|
||||
getComponents,
|
||||
mode,
|
||||
transform: typeof nuxt.options.components === 'object' && !Array.isArray(nuxt.options.components) ? nuxt.options.components.transform : undefined,
|
||||
experimentalComponentIslands: nuxt.options.experimental.componentIslands
|
||||
experimentalComponentIslands: !!nuxt.options.experimental.componentIslands
|
||||
}))
|
||||
|
||||
if (nuxt.options.experimental.componentIslands && mode === 'server') {
|
||||
|
@ -329,6 +329,7 @@ export const nuxtConfigTemplate = {
|
||||
...Object.entries(ctx.nuxt.options.app).map(([k, v]) => `export const ${camelCase('app-' + k)} = ${JSON.stringify(v)}`),
|
||||
`export const renderJsonPayloads = ${!!ctx.nuxt.options.experimental.renderJsonPayloads}`,
|
||||
`export const componentIslands = ${!!ctx.nuxt.options.experimental.componentIslands}`,
|
||||
`export const remoteComponentIslands = ${ctx.nuxt.options.experimental.componentIslands === 'local+remote'}`,
|
||||
`export const devPagesDir = ${ctx.nuxt.options.dev ? JSON.stringify(ctx.nuxt.options.dir.pages) : 'null'}`,
|
||||
`export const devRootDir = ${ctx.nuxt.options.dev ? JSON.stringify(ctx.nuxt.options.rootDir) : 'null'}`
|
||||
].join('\n\n')
|
||||
|
@ -137,8 +137,15 @@ export default defineUntypedSchema({
|
||||
|
||||
/**
|
||||
* Experimental component islands support with <NuxtIsland> and .island.vue files.
|
||||
* @type {true | 'local' | 'local+remote' | false}
|
||||
*/
|
||||
componentIslands: false,
|
||||
componentIslands: {
|
||||
$resolve: (val) => {
|
||||
if (typeof val === 'string') { return val }
|
||||
if (val === true) { return 'local' }
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Config schema support
|
||||
|
Loading…
Reference in New Issue
Block a user