mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +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()
|
||||
|
||||
/*! @__NO_SIDE_EFFECTS__ */
|
||||
/*@__NO_SIDE_EFFECTS__*/
|
||||
export function createClientOnly<T extends ComponentOptions> (component: T) {
|
||||
if (cache.has(component)) {
|
||||
return cache.get(component)
|
||||
|
@ -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'
|
||||
|
||||
|
@ -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 =
|
||||
function defineNuxtComponent (...args: any[]): any {
|
||||
const [options, key] = args
|
||||
|
@ -43,7 +43,7 @@ export interface RouteMiddleware {
|
||||
(to: RouteLocationNormalized, from: RouteLocationNormalized): ReturnType<NavigationGuard>
|
||||
}
|
||||
|
||||
/*! @__NO_SIDE_EFFECTS__ */
|
||||
/*@__NO_SIDE_EFFECTS__*/
|
||||
export function defineNuxtRouteMiddleware (middleware: RouteMiddleware) {
|
||||
return middleware
|
||||
}
|
||||
|
@ -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<NuxtApp>('nuxt-app', {
|
||||
const nuxtAppCtx = /*@__PURE__*/ getContext<NuxtApp>('nuxt-app', {
|
||||
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] }
|
||||
}
|
||||
|
||||
/*! @__NO_SIDE_EFFECTS__ */
|
||||
/*@__NO_SIDE_EFFECTS__*/
|
||||
export function defineNuxtPlugin<T extends Record<string, unknown>> (plugin: Plugin<T> | ObjectPlugin<T>): Plugin<T> & ObjectPlugin<T> {
|
||||
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<T extends (...args: any[]) => 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
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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()) {
|
||||
|
@ -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(', ')})
|
||||
`
|
||||
}
|
||||
}
|
||||
|
@ -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 => {}
|
||||
|
Loading…
Reference in New Issue
Block a user