Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(nuxt): remove pure annotations plugin #24033

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nuxt/src/app/components/nuxt-root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/src/components/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt/src/components/runtime/server-component.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/components/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const componentsIslandsTemplate: NuxtTemplate<ComponentsTemplateContext>
(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')
}
Expand Down
1 change: 1 addition & 0 deletions packages/nuxt/src/pages/runtime/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {}
7 changes: 1 addition & 6 deletions packages/vite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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: {
Expand Down
40 changes: 0 additions & 40 deletions packages/vite/src/plugins/pure-annotations.ts

This file was deleted.

8 changes: 1 addition & 7 deletions packages/vite/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { ViteConfig } from '@nuxt/schema'
import type { ViteBuildContext } from './vite'
import { createViteLogger } from './utils/logger'
import { initViteNodeServer } from './vite-node'
import { pureAnnotationsPlugin } from './plugins/pure-annotations'
import { writeManifest } from './manifest'
import { transpile } from './utils/transpile'

Expand Down Expand Up @@ -101,12 +100,7 @@ export async function buildServer (ctx: ViteBuildContext) {
preTransformRequests: false,
hmr: false
},
plugins: [
pureAnnotationsPlugin.vite({
sourcemap: !!ctx.nuxt.options.sourcemap.server,
functions: ['defineComponent', 'defineAsyncComponent', 'defineNuxtLink', 'createClientOnly', 'defineNuxtPlugin', 'defineNuxtRouteMiddleware', 'defineNuxtComponent', 'useRuntimeConfig', 'defineRouteRules']
})
]
plugins: []
} satisfies vite.InlineConfig, ctx.nuxt.options.vite.$server || {}))

if (!ctx.nuxt.options.dev) {
Expand Down