diff --git a/packages/nuxt/src/app/components/nuxt-root.vue b/packages/nuxt/src/app/components/nuxt-root.vue index 80a9d38ac1..378c8ee59c 100644 --- a/packages/nuxt/src/app/components/nuxt-root.vue +++ b/packages/nuxt/src/app/components/nuxt-root.vue @@ -24,7 +24,7 @@ const nuxtApp = useNuxtApp() const onResolve = nuxtApp.deferHydration() const url = import.meta.server ? nuxtApp.ssrContext.url : window.location.pathname -const SingleRenderer = import.meta.test && import.meta.dev && import.meta.server && url.startsWith('/__nuxt_component_test__/') && /* #__PURE__ */ defineAsyncComponent(() => import('#build/test-component-wrapper.mjs') +const SingleRenderer = import.meta.test && import.meta.dev && import.meta.server && url.startsWith('/__nuxt_component_test__/') && defineAsyncComponent(() => import('#build/test-component-wrapper.mjs') .then(r => r.default(import.meta.server ? url : window.location.href))) // Inject default route (outside of pages) as active route diff --git a/packages/nuxt/src/components/loader.ts b/packages/nuxt/src/components/loader.ts index 5e42223bb3..d219705462 100644 --- a/packages/nuxt/src/components/loader.ts +++ b/packages/nuxt/src/components/loader.ts @@ -74,12 +74,12 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => { if (lazy) { imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }])) identifier += '_lazy' - imports.add(`const ${identifier} = /*#__PURE__*/ __defineAsyncComponent(${genDynamicImport(component.filePath, { interopDefault: true })}${isClientOnly ? '.then(c => createClientOnly(c))' : ''})`) + imports.add(`const ${identifier} = __defineAsyncComponent(${genDynamicImport(component.filePath, { interopDefault: true })}${isClientOnly ? '.then(c => createClientOnly(c))' : ''})`) } else { imports.add(genImport(component.filePath, [{ name: component.export, as: identifier }])) if (isClientOnly) { - imports.add(`const ${identifier}_wrapped = /*#__PURE__*/ createClientOnly(${identifier})`) + imports.add(`const ${identifier}_wrapped = createClientOnly(${identifier})`) identifier += '_wrapped' } } diff --git a/packages/nuxt/src/components/runtime/server-component.ts b/packages/nuxt/src/components/runtime/server-component.ts index b8d7e216a3..e1f75e6a59 100644 --- a/packages/nuxt/src/components/runtime/server-component.ts +++ b/packages/nuxt/src/components/runtime/server-component.ts @@ -1,6 +1,7 @@ import { defineComponent, h } from 'vue' import NuxtIsland from '#app/components/nuxt-island' +/*! @__NO_SIDE_EFFECTS__ */ export const createServerComponent = (name: string) => { return defineComponent({ name, diff --git a/packages/nuxt/src/components/templates.ts b/packages/nuxt/src/components/templates.ts index 2847270a33..d0e250c5a7 100644 --- a/packages/nuxt/src/components/templates.ts +++ b/packages/nuxt/src/components/templates.ts @@ -90,7 +90,7 @@ export const componentsIslandsTemplate: NuxtTemplate (c) => { const exp = c.export === 'default' ? 'c.default || c' : `c['${c.export}']` const comment = createImportMagicComments(c) - return `export const ${c.pascalName} = /* #__PURE__ */ defineAsyncComponent(${genDynamicImport(c.filePath, { comment })}.then(c => ${exp}))` + return `export const ${c.pascalName} = defineAsyncComponent(${genDynamicImport(c.filePath, { comment })}.then(c => ${exp}))` } )].join('\n') } diff --git a/packages/nuxt/src/pages/runtime/composables.ts b/packages/nuxt/src/pages/runtime/composables.ts index 24714cd252..3b1ee9210c 100644 --- a/packages/nuxt/src/pages/runtime/composables.ts +++ b/packages/nuxt/src/pages/runtime/composables.ts @@ -76,5 +76,6 @@ export const definePageMeta = (meta: PageMeta): void => { * For more control, such as if you are using a custom `path` or `alias` set in the page's `definePageMeta`, you * should set `routeRules` directly within your `nuxt.config`. */ +/*! @__NO_SIDE_EFFECTS__ */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export const defineRouteRules = (rules: NitroRouteConfig): void => {} diff --git a/packages/vite/src/client.ts b/packages/vite/src/client.ts index a8dca717fa..171f314cff 100644 --- a/packages/vite/src/client.ts +++ b/packages/vite/src/client.ts @@ -15,7 +15,6 @@ import type { ViteBuildContext } from './vite' import { devStyleSSRPlugin } from './plugins/dev-ssr-css' import { runtimePathsPlugin } from './plugins/paths' import { typeCheckPlugin } from './plugins/type-check' -import { pureAnnotationsPlugin } from './plugins/pure-annotations' import { viteNodePlugin } from './vite-node' import { createViteLogger } from './utils/logger' @@ -80,11 +79,7 @@ export async function buildClient (ctx: ViteBuildContext) { runtimePathsPlugin({ sourcemap: !!ctx.nuxt.options.sourcemap.client }), - viteNodePlugin(ctx), - pureAnnotationsPlugin.vite({ - sourcemap: !!ctx.nuxt.options.sourcemap.client, - functions: ['defineComponent', 'defineAsyncComponent', 'defineNuxtLink', 'createClientOnly', 'defineNuxtPlugin', 'defineNuxtRouteMiddleware', 'defineNuxtComponent', 'useRuntimeConfig', 'defineRouteRules'] - }) + viteNodePlugin(ctx) ], appType: 'custom', server: { diff --git a/packages/vite/src/plugins/pure-annotations.ts b/packages/vite/src/plugins/pure-annotations.ts deleted file mode 100644 index 9154f54863..0000000000 --- a/packages/vite/src/plugins/pure-annotations.ts +++ /dev/null @@ -1,40 +0,0 @@ -import MagicString from 'magic-string' -import { createUnplugin } from 'unplugin' -import { stripLiteral } from 'strip-literal' -import { isJS, isVue } from '../../../nuxt/src/core/utils/plugins' - -interface PureAnnotationsOptions { - sourcemap: boolean - functions: string[] -} - -export const pureAnnotationsPlugin = createUnplugin((options: PureAnnotationsOptions) => { - const FUNCTION_RE = new RegExp(`(?