From 09161d005da48b0ba82308093e509a53d9a8b899 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 29 Nov 2023 00:20:54 +0100 Subject: [PATCH] fix(nuxt): use consistent annotations for tree-shaking (#24514) --- packages/nuxt/src/app/components/client-only.ts | 2 +- packages/nuxt/src/app/components/nuxt-link.ts | 2 +- packages/nuxt/src/app/composables/component.ts | 2 +- packages/nuxt/src/app/composables/router.ts | 2 +- packages/nuxt/src/app/nuxt.ts | 10 +++++----- .../nuxt/src/components/runtime/server-component.ts | 2 +- packages/nuxt/src/core/plugins/tree-shake.ts | 2 +- packages/nuxt/src/core/templates.ts | 2 +- packages/nuxt/src/pages/runtime/composables.ts | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/nuxt/src/app/components/client-only.ts b/packages/nuxt/src/app/components/client-only.ts index 9dd40cced8..1840127d5d 100644 --- a/packages/nuxt/src/app/components/client-only.ts +++ b/packages/nuxt/src/app/components/client-only.ts @@ -23,7 +23,7 @@ export default defineComponent({ const cache = new WeakMap() -/*! @__NO_SIDE_EFFECTS__ */ +/*@__NO_SIDE_EFFECTS__*/ export function createClientOnly (component: T) { if (cache.has(component)) { return cache.get(component) diff --git a/packages/nuxt/src/app/components/nuxt-link.ts b/packages/nuxt/src/app/components/nuxt-link.ts index d2ee73ca47..6735c84b02 100644 --- a/packages/nuxt/src/app/components/nuxt-link.ts +++ b/packages/nuxt/src/app/components/nuxt-link.ts @@ -50,7 +50,7 @@ export type NuxtLinkProps = { ariaCurrentValue?: string } -/*! @__NO_SIDE_EFFECTS__ */ +/*@__NO_SIDE_EFFECTS__*/ export function defineNuxtLink (options: NuxtLinkOptions) { const componentName = options.componentName || 'NuxtLink' diff --git a/packages/nuxt/src/app/composables/component.ts b/packages/nuxt/src/app/composables/component.ts index 5bfcc992ea..31e43f8c6e 100644 --- a/packages/nuxt/src/app/composables/component.ts +++ b/packages/nuxt/src/app/composables/component.ts @@ -27,7 +27,7 @@ async function runLegacyAsyncData (res: Record | Promise } -/*! @__NO_SIDE_EFFECTS__ */ +/*@__NO_SIDE_EFFECTS__*/ export function defineNuxtRouteMiddleware (middleware: RouteMiddleware) { return middleware } diff --git a/packages/nuxt/src/app/nuxt.ts b/packages/nuxt/src/app/nuxt.ts index 606e4b303f..9053881a2c 100644 --- a/packages/nuxt/src/app/nuxt.ts +++ b/packages/nuxt/src/app/nuxt.ts @@ -18,7 +18,7 @@ import type { NuxtError } from '../app/composables/error' import type { AsyncDataRequestStatus } from '../app/composables/asyncData' import type { NuxtAppManifestMeta } from '../app/composables/manifest' -const nuxtAppCtx = /* #__PURE__ */ getContext('nuxt-app', { +const nuxtAppCtx = /*@__PURE__*/ getContext('nuxt-app', { asyncContext: !!process.env.NUXT_ASYNC_CONTEXT && process.server }) @@ -346,14 +346,14 @@ export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array> (plugin: Plugin | ObjectPlugin): Plugin & ObjectPlugin { if (typeof plugin === 'function') { return plugin } delete plugin.name return Object.assign(plugin.setup || (() => {}), plugin, { [NuxtPluginIndicator]: true } as const) } -/*! @__NO_SIDE_EFFECTS__ */ +/*@__NO_SIDE_EFFECTS__*/ export const definePayloadPlugin = defineNuxtPlugin export function isNuxtPlugin (plugin: unknown) { @@ -376,7 +376,7 @@ export function callWithNuxt any> (nuxt: NuxtApp | } } -/*! @__NO_SIDE_EFFECTS__ */ +/*@__NO_SIDE_EFFECTS__*/ /** * Returns the current Nuxt instance. */ @@ -399,7 +399,7 @@ export function useNuxtApp (): NuxtApp { return nuxtAppInstance } -/*! @__NO_SIDE_EFFECTS__ */ +/*@__NO_SIDE_EFFECTS__*/ export function useRuntimeConfig (): RuntimeConfig { return useNuxtApp().$config } diff --git a/packages/nuxt/src/components/runtime/server-component.ts b/packages/nuxt/src/components/runtime/server-component.ts index e1f75e6a59..88b8ece949 100644 --- a/packages/nuxt/src/components/runtime/server-component.ts +++ b/packages/nuxt/src/components/runtime/server-component.ts @@ -1,7 +1,7 @@ import { defineComponent, h } from 'vue' import NuxtIsland from '#app/components/nuxt-island' -/*! @__NO_SIDE_EFFECTS__ */ +/*@__NO_SIDE_EFFECTS__*/ export const createServerComponent = (name: string) => { return defineComponent({ name, diff --git a/packages/nuxt/src/core/plugins/tree-shake.ts b/packages/nuxt/src/core/plugins/tree-shake.ts index e64bb95729..35030990ca 100644 --- a/packages/nuxt/src/core/plugins/tree-shake.ts +++ b/packages/nuxt/src/core/plugins/tree-shake.ts @@ -32,7 +32,7 @@ export const TreeShakeComposablesPlugin = createUnplugin((options: TreeShakeComp const s = new MagicString(code) const strippedCode = stripLiteral(code) for (const match of strippedCode.matchAll(COMPOSABLE_RE_GLOBAL) || []) { - s.overwrite(match.index!, match.index! + match[0].length, `${match[1]} /*#__PURE__*/ false && ${match[2]}`) + s.overwrite(match.index!, match.index! + match[0].length, `${match[1]} false && /*@__PURE__*/ ${match[2]}`) } if (s.hasChanged()) { diff --git a/packages/nuxt/src/core/templates.ts b/packages/nuxt/src/core/templates.ts index ef5fba6b04..c503ecfec0 100644 --- a/packages/nuxt/src/core/templates.ts +++ b/packages/nuxt/src/core/templates.ts @@ -304,7 +304,7 @@ if (import.meta.hot) { ${app.configs.map((id: string, index: number) => `import ${`cfg${index}`} from ${JSON.stringify(id)}`).join('\n')} -export default /* #__PURE__ */ defuFn(${app.configs.map((_id: string, index: number) => `cfg${index}`).concat(['inlineConfig']).join(', ')}) +export default /*@__PURE__*/ defuFn(${app.configs.map((_id: string, index: number) => `cfg${index}`).concat(['inlineConfig']).join(', ')}) ` } } diff --git a/packages/nuxt/src/pages/runtime/composables.ts b/packages/nuxt/src/pages/runtime/composables.ts index 19c6112a44..dd3603b827 100644 --- a/packages/nuxt/src/pages/runtime/composables.ts +++ b/packages/nuxt/src/pages/runtime/composables.ts @@ -78,6 +78,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__ */ +/*@__NO_SIDE_EFFECTS__*/ // eslint-disable-next-line @typescript-eslint/no-unused-vars export const defineRouteRules = (rules: NitroRouteConfig): void => {}