From a4d095872783ab54354cd219a5ac4c7864018ccc Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Tue, 7 May 2024 22:55:54 +0200 Subject: [PATCH] fix(nuxt): remove unused prop in `NuxtTeleportIslandComponent` (#27093) --- .../nuxt-teleport-island-component.ts | 8 -- .../nuxt/src/components/islandsTransform.ts | 9 +- packages/nuxt/src/components/module.ts | 2 - packages/nuxt/test/islandTransform.test.ts | 90 +++++-------------- 4 files changed, 25 insertions(+), 84 deletions(-) diff --git a/packages/nuxt/src/app/components/nuxt-teleport-island-component.ts b/packages/nuxt/src/app/components/nuxt-teleport-island-component.ts index 002a2441a0e4..31b2c0718b21 100644 --- a/packages/nuxt/src/app/components/nuxt-teleport-island-component.ts +++ b/packages/nuxt/src/app/components/nuxt-teleport-island-component.ts @@ -27,14 +27,6 @@ export default defineComponent({ type: Boolean, default: false, }, - /** - * ONLY used in dev mode since we use build:manifest result in production - * do not pass any value in production - */ - rootDir: { - type: String, - default: null, - }, }, setup (props, { slots }) { const nuxtApp = useNuxtApp() diff --git a/packages/nuxt/src/components/islandsTransform.ts b/packages/nuxt/src/components/islandsTransform.ts index 46a9f31d3ddd..6e018dc1679c 100644 --- a/packages/nuxt/src/components/islandsTransform.ts +++ b/packages/nuxt/src/components/islandsTransform.ts @@ -13,12 +13,6 @@ import { isVue } from '../core/utils' interface ServerOnlyComponentTransformPluginOptions { getComponents: () => Component[] - /** - * passed down to `NuxtTeleportIslandComponent` - * should be done only in dev mode as we use build:manifest result in production - */ - rootDir?: string - isDev?: boolean /** * allow using `nuxt-client` attribute on components */ @@ -43,7 +37,6 @@ function wrapWithVForDiv (code: string, vfor: string): string { export const islandsTransform = createUnplugin((options: ServerOnlyComponentTransformPluginOptions, meta) => { const isVite = meta.framework === 'vite' - const { isDev, rootDir } = options return { name: 'server-only-component-transform', enforce: 'pre', @@ -115,7 +108,7 @@ export const islandsTransform = createUnplugin((options: ServerOnlyComponentTran startTag = startTag.replaceAll(EXTRACTED_ATTRS_RE, '') } - s.appendLeft(startingIndex + loc[0].start, ``) + s.appendLeft(startingIndex + loc[0].start, ``) s.overwrite(startingIndex + loc[0].start, startingIndex + loc[0].end, startTag) s.appendRight(startingIndex + loc[1].end, '') } diff --git a/packages/nuxt/src/components/module.ts b/packages/nuxt/src/components/module.ts index 1a2b52439435..82e227a2ad65 100644 --- a/packages/nuxt/src/components/module.ts +++ b/packages/nuxt/src/components/module.ts @@ -260,8 +260,6 @@ export default defineNuxtModule({ if (isServer) { config.plugins.push(islandsTransform.vite({ getComponents, - rootDir: nuxt.options.rootDir, - isDev: nuxt.options.dev, selectiveClient, })) } diff --git a/packages/nuxt/test/islandTransform.test.ts b/packages/nuxt/test/islandTransform.test.ts index 519373867a3f..8c814544091f 100644 --- a/packages/nuxt/test/islandTransform.test.ts +++ b/packages/nuxt/test/islandTransform.test.ts @@ -23,11 +23,9 @@ const pluginWebpack = islandsTransform.raw({ selectiveClient: true, }, { framework: 'webpack', webpack: { compiler: {} as any } }) -const viteTransform = async (source: string, id: string, isDev = false, selectiveClient = false) => { +const viteTransform = async (source: string, id: string, selectiveClient = false) => { const vitePlugin = islandsTransform.raw({ getComponents, - rootDir: '/root', - isDev, selectiveClient, }, { framework: 'vite' }) as Plugin @@ -193,7 +191,7 @@ describe('islandTransform - server and island components', () => { - `, 'WithVif.vue', false, true) + `, 'WithVif.vue', true) expect(normalizeLineEndings(result)).toMatchInlineSnapshot(` " - `, 'hello.server.vue', true, true) - - expect(normalizeLineEndings(result)).toMatchInlineSnapshot(` - " - - - " - `) - // root-dir prop should never be used in production - expect(result).toContain('root-dir="/root"') - }) - - it('test transform with vite in prod', async () => { + it('test transform with vite', async () => { const result = await viteTransform(` - `, 'hello.server.vue', false, true) + `, 'hello.server.vue', true) expect(result).toMatchInlineSnapshot(` " "