mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-24 09:28:41 +00:00
refactor: use import.meta instead of process.env
This commit is contained in:
parent
aceb4ae29a
commit
15782f7a71
@ -113,8 +113,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
// no need for reactivity
|
// no need for reactivity
|
||||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||||
let interactiveProps: Record<string, Record<string, any>> = process.client && nuxtApp.isHydrating ? toRaw(nuxtApp.payload.data[`${props.name}_${hashId.value}_interactive`].props) : {}
|
let interactiveProps: Record<string, Record<string, any>> = import.meta.client && nuxtApp.isHydrating ? toRaw(nuxtApp.payload.data[`${props.name}_${hashId.value}_interactive`].props) : {}
|
||||||
const interactiveChunksList = process.client && nuxtApp.isHydrating ? nuxtApp.payload.data[`${props.name}_${hashId.value}_interactive`].chunks : {}
|
const interactiveChunksList = import.meta.client && nuxtApp.isHydrating ? nuxtApp.payload.data[`${props.name}_${hashId.value}_interactive`].chunks : {}
|
||||||
let interactiveTeleports: Record<string, string> = {}
|
let interactiveTeleports: Record<string, string> = {}
|
||||||
const html = computed(() => {
|
const html = computed(() => {
|
||||||
const currentSlots = Object.keys(slots)
|
const currentSlots = Object.keys(slots)
|
||||||
@ -188,7 +188,7 @@ export default defineComponent({
|
|||||||
props: res.props
|
props: res.props
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.client) {
|
if (import.meta.client) {
|
||||||
await loadComponents(props.source, res.chunks)
|
await loadComponents(props.source, res.chunks)
|
||||||
interactiveProps = res.props
|
interactiveProps = res.props
|
||||||
} else {
|
} else {
|
||||||
@ -228,7 +228,7 @@ export default defineComponent({
|
|||||||
key: key.value
|
key: key.value
|
||||||
}, [h(createStaticVNode(html.value, 1))])]
|
}, [h(createStaticVNode(html.value, 1))])]
|
||||||
|
|
||||||
if (uid.value && (mounted.value || nuxtApp.isHydrating || process.server)) {
|
if (uid.value && (mounted.value || nuxtApp.isHydrating || import.meta.server)) {
|
||||||
for (const slot in slots) {
|
for (const slot in slots) {
|
||||||
if (availableSlots.value.includes(slot)) {
|
if (availableSlots.value.includes(slot)) {
|
||||||
nodes.push(createVNode(Teleport, { to: import.meta.client ? `[nuxt-ssr-component-uid='${uid.value}'] [nuxt-ssr-slot-name='${slot}']` : `uid=${uid.value};slot=${slot}` }, {
|
nodes.push(createVNode(Teleport, { to: import.meta.client ? `[nuxt-ssr-component-uid='${uid.value}'] [nuxt-ssr-slot-name='${slot}']` : `uid=${uid.value};slot=${slot}` }, {
|
||||||
@ -236,16 +236,16 @@ export default defineComponent({
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.server) {
|
if (import.meta.server) {
|
||||||
for (const [id, html] of Object.entries(interactiveTeleports)) {
|
for (const [id, html] of Object.entries(interactiveTeleports)) {
|
||||||
nodes.push(createVNode(Teleport, { to: `uid=${uid.value};client=${id}` }, {
|
nodes.push(createVNode(Teleport, { to: `uid=${uid.value};client=${id}` }, {
|
||||||
default: () => [createStaticVNode(html, 1)]
|
default: () => [createStaticVNode(html, 1)]
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (process.client && html.value.includes('nuxt-ssr-client')) {
|
if (import.meta.client && html.value.includes('nuxt-ssr-client')) {
|
||||||
for (const [id, props] of Object.entries(interactiveProps)) {
|
for (const [id, props] of Object.entries(interactiveProps)) {
|
||||||
// @ts-expect-error _ is the components default export in build chunks
|
// @ts-expect-error _ is the component's default export in build chunks
|
||||||
const component = components!.get(id.split('-')[0])!._ ?? components!.get(id.split('-')[0])!
|
const component = components!.get(id.split('-')[0])!._ ?? components!.get(id.split('-')[0])!
|
||||||
const vnode = createVNode(Teleport, { to: `[nuxt-ssr-component-uid='${uid.value}'] [nuxt-ssr-client="${id}"]` }, {
|
const vnode = createVNode(Teleport, { to: `[nuxt-ssr-component-uid='${uid.value}'] [nuxt-ssr-client="${id}"]` }, {
|
||||||
default: () => {
|
default: () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user