mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(nuxt): use consistent annotations for tree-shaking (#24514)
This commit is contained in:
parent
0f705f3d4a
commit
09161d005d
@ -23,7 +23,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const cache = new WeakMap()
|
const cache = new WeakMap()
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export function createClientOnly<T extends ComponentOptions> (component: T) {
|
export function createClientOnly<T extends ComponentOptions> (component: T) {
|
||||||
if (cache.has(component)) {
|
if (cache.has(component)) {
|
||||||
return cache.get(component)
|
return cache.get(component)
|
||||||
|
@ -50,7 +50,7 @@ export type NuxtLinkProps = {
|
|||||||
ariaCurrentValue?: string
|
ariaCurrentValue?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export function defineNuxtLink (options: NuxtLinkOptions) {
|
export function defineNuxtLink (options: NuxtLinkOptions) {
|
||||||
const componentName = options.componentName || 'NuxtLink'
|
const componentName = options.componentName || 'NuxtLink'
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ async function runLegacyAsyncData (res: Record<string, any> | Promise<Record<str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export const defineNuxtComponent: typeof defineComponent =
|
export const defineNuxtComponent: typeof defineComponent =
|
||||||
function defineNuxtComponent (...args: any[]): any {
|
function defineNuxtComponent (...args: any[]): any {
|
||||||
const [options, key] = args
|
const [options, key] = args
|
||||||
|
@ -43,7 +43,7 @@ export interface RouteMiddleware {
|
|||||||
(to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>
|
(to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export function defineNuxtRouteMiddleware (middleware: RouteMiddleware) {
|
export function defineNuxtRouteMiddleware (middleware: RouteMiddleware) {
|
||||||
return middleware
|
return middleware
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import type { NuxtError } from '../app/composables/error'
|
|||||||
import type { AsyncDataRequestStatus } from '../app/composables/asyncData'
|
import type { AsyncDataRequestStatus } from '../app/composables/asyncData'
|
||||||
import type { NuxtAppManifestMeta } from '../app/composables/manifest'
|
import type { NuxtAppManifestMeta } from '../app/composables/manifest'
|
||||||
|
|
||||||
const nuxtAppCtx = /* #__PURE__ */ getContext<NuxtApp>('nuxt-app', {
|
const nuxtAppCtx = /*@__PURE__*/ getContext<NuxtApp>('nuxt-app', {
|
||||||
asyncContext: !!process.env.NUXT_ASYNC_CONTEXT && process.server
|
asyncContext: !!process.env.NUXT_ASYNC_CONTEXT && process.server
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -346,14 +346,14 @@ export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array<Plugin & Ob
|
|||||||
if (errors.length) { throw errors[0] }
|
if (errors.length) { throw errors[0] }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export function defineNuxtPlugin<T extends Record<string, unknown>> (plugin: Plugin<T> | ObjectPlugin<T>): Plugin<T> & ObjectPlugin<T> {
|
export function defineNuxtPlugin<T extends Record<string, unknown>> (plugin: Plugin<T> | ObjectPlugin<T>): Plugin<T> & ObjectPlugin<T> {
|
||||||
if (typeof plugin === 'function') { return plugin }
|
if (typeof plugin === 'function') { return plugin }
|
||||||
delete plugin.name
|
delete plugin.name
|
||||||
return Object.assign(plugin.setup || (() => {}), plugin, { [NuxtPluginIndicator]: true } as const)
|
return Object.assign(plugin.setup || (() => {}), plugin, { [NuxtPluginIndicator]: true } as const)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export const definePayloadPlugin = defineNuxtPlugin
|
export const definePayloadPlugin = defineNuxtPlugin
|
||||||
|
|
||||||
export function isNuxtPlugin (plugin: unknown) {
|
export function isNuxtPlugin (plugin: unknown) {
|
||||||
@ -376,7 +376,7 @@ export function callWithNuxt<T extends (...args: any[]) => any> (nuxt: NuxtApp |
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
/**
|
/**
|
||||||
* Returns the current Nuxt instance.
|
* Returns the current Nuxt instance.
|
||||||
*/
|
*/
|
||||||
@ -399,7 +399,7 @@ export function useNuxtApp (): NuxtApp {
|
|||||||
return nuxtAppInstance
|
return nuxtAppInstance
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export function useRuntimeConfig (): RuntimeConfig {
|
export function useRuntimeConfig (): RuntimeConfig {
|
||||||
return useNuxtApp().$config
|
return useNuxtApp().$config
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { defineComponent, h } from 'vue'
|
import { defineComponent, h } from 'vue'
|
||||||
import NuxtIsland from '#app/components/nuxt-island'
|
import NuxtIsland from '#app/components/nuxt-island'
|
||||||
|
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
export const createServerComponent = (name: string) => {
|
export const createServerComponent = (name: string) => {
|
||||||
return defineComponent({
|
return defineComponent({
|
||||||
name,
|
name,
|
||||||
|
@ -32,7 +32,7 @@ export const TreeShakeComposablesPlugin = createUnplugin((options: TreeShakeComp
|
|||||||
const s = new MagicString(code)
|
const s = new MagicString(code)
|
||||||
const strippedCode = stripLiteral(code)
|
const strippedCode = stripLiteral(code)
|
||||||
for (const match of strippedCode.matchAll(COMPOSABLE_RE_GLOBAL) || []) {
|
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()) {
|
if (s.hasChanged()) {
|
||||||
|
@ -304,7 +304,7 @@ if (import.meta.hot) {
|
|||||||
|
|
||||||
${app.configs.map((id: string, index: number) => `import ${`cfg${index}`} from ${JSON.stringify(id)}`).join('\n')}
|
${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(', ')})
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
* 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`.
|
* should set `routeRules` directly within your `nuxt.config`.
|
||||||
*/
|
*/
|
||||||
/*! @__NO_SIDE_EFFECTS__ */
|
/*@__NO_SIDE_EFFECTS__*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export const defineRouteRules = (rules: NitroRouteConfig): void => {}
|
export const defineRouteRules = (rules: NitroRouteConfig): void => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user