perf(kit,nuxt,schema,vite,webpack): use explicit exports (#27998)

This commit is contained in:
Daniel Roe 2024-07-03 17:46:42 +01:00 committed by GitHub
parent 7b98c27ebc
commit 128edc76fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 52 additions and 39 deletions

View File

@ -1,28 +1,35 @@
// Module
export * from './module/define'
export * from './module/install'
export * from './module/compatibility'
export { defineNuxtModule } from './module/define'
export { getDirectory, installModule, loadNuxtModuleInstance, normalizeModuleTranspilePath } from './module/install'
export { getNuxtModuleVersion, hasNuxtModule, hasNuxtModuleCompatibility } from './module/compatibility'
// Loader
export * from './loader/config'
export * from './loader/schema'
export * from './loader/nuxt'
export { loadNuxtConfig } from './loader/config'
export type { LoadNuxtConfigOptions } from './loader/config'
export { extendNuxtSchema } from './loader/schema'
export { buildNuxt, loadNuxt } from './loader/nuxt'
export type { LoadNuxtOptions } from './loader/nuxt'
// Utils
export * from './imports'
export { addImports, addImportsDir, addImportsSources } from './imports'
export { updateRuntimeConfig, useRuntimeConfig } from './runtime-config'
export * from './build'
export * from './compatibility'
export * from './components'
export * from './context'
export { addBuildPlugin, addVitePlugin, addWebpackPlugin, extendViteConfig, extendWebpackConfig } from './build'
export type { ExtendConfigOptions, ExtendViteConfigOptions, ExtendWebpackConfigOptions } from './build'
export { assertNuxtCompatibility, checkNuxtCompatibility, getNuxtVersion, hasNuxtCompatibility, isNuxtMajorVersion, normalizeSemanticVersion, isNuxt2, isNuxt3 } from './compatibility'
export { addComponent, addComponentsDir } from './components'
export type { AddComponentOptions } from './components'
export { nuxtCtx, tryUseNuxt, useNuxt } from './context'
export { isIgnored, resolveIgnorePatterns } from './ignore'
export * from './layout'
export * from './pages'
export * from './plugin'
export * from './resolve'
export * from './nitro'
export { addLayout } from './layout'
export { addRouteMiddleware, extendPages, extendRouteRules } from './pages'
export type { AddRouteMiddlewareOptions, ExtendRouteRulesOptions } from './pages'
export { addPlugin, addPluginTemplate, normalizePlugin } from './plugin'
export type { AddPluginOptions } from './plugin'
export { createResolver, findPath, resolveAlias, resolveFiles, resolveNuxtModule, resolvePath } from './resolve'
export type { ResolvePathOptions, Resolver } from './resolve'
export { addServerHandler, addDevServerHandler, addServerPlugin, addPrerenderRoutes, useNitro, addServerImports, addServerImportsDir, addServerScanDir } from './nitro'
export { addTemplate, addTypeTemplate, normalizeTemplate, updateTemplates, writeTypes } from './template'
export * from './logger'
export { logger, useLogger } from './logger'
// Internal Utils
// TODO

View File

@ -1,11 +1,14 @@
export * from './nuxt'
export { applyPlugin, applyPlugins, callWithNuxt, createNuxtApp, defineAppConfig, defineNuxtPlugin, definePayloadPlugin, isNuxtPlugin, registerPluginHooks, tryUseNuxtApp, useNuxtApp, useRuntimeConfig } from './nuxt'
export type { CreateOptions, NuxtApp, NuxtPayload, NuxtPluginIndicator, NuxtSSRContext, ObjectPlugin, Plugin, PluginEnvContext, PluginMeta, ResolvedPluginMeta, RuntimeNuxtHooks } from './nuxt'
export * from './composables/index'
export { defineNuxtComponent, useAsyncData, useLazyAsyncData, useNuxtData, refreshNuxtData, clearNuxtData, useHydration, callOnce, useState, clearNuxtState, clearError, createError, isNuxtError, showError, useError, useFetch, useLazyFetch, useCookie, refreshCookie, onPrehydrate, prerenderRoutes, useRequestHeaders, useRequestEvent, useRequestFetch, setResponseStatus, onNuxtReady, abortNavigation, addRouteMiddleware, defineNuxtRouteMiddleware, onBeforeRouteLeave, onBeforeRouteUpdate, setPageLayout, navigateTo, useRoute, useRouter, preloadComponents, prefetchComponents, preloadRouteComponents, isPrerendered, loadPayload, preloadPayload, definePayloadReducer, definePayloadReviver, getAppManifest, getRouteRules, reloadNuxtApp, useRequestURL, usePreviewMode, useId, useRouteAnnouncer, useHead, useSeoMeta, useServerSeoMeta } from './composables/index'
export type { AddRouteMiddlewareOptions, AsyncData, AsyncDataOptions, AsyncDataRequestStatus, CookieOptions, CookieRef, FetchResult, NuxtAppManifest, NuxtAppManifestMeta, NuxtError, ReloadNuxtAppOptions, RouteMiddleware, UseFetchOptions } from './composables/index'
export * from './components/index'
export * from './config'
export * from './compat/idle-callback'
export * from './types'
export { defineNuxtLink } from './components/index'
export type { NuxtLinkOptions, NuxtLinkProps } from './components/index'
export { _getAppConfig, updateAppConfig, useAppConfig } from './config'
export { cancelIdleCallback, requestIdleCallback } from './compat/idle-callback'
export type { NuxtAppLiterals, NuxtIslandContext, NuxtIslandResponse, NuxtRenderHTMLContext, PageMeta } from './types'
export const isVue2 = false
export const isVue3 = true

View File

@ -1,5 +1,5 @@
export * from './names'
export * from './plugins'
export { getNameFromPath, hasSuffix, resolveComponentNameSegments } from './names'
export { isJS, isVue } from './plugins'
export function uniqueBy<T, K extends keyof T> (arr: T[], key: K) {
if (arr.length < 2) {

View File

@ -1,2 +1,2 @@
export * from './core/nuxt'
export * from './core/builder'
export { createNuxt, loadNuxt } from './core/nuxt'
export { build } from './core/builder'

View File

@ -1 +1,2 @@
export * from './composables'
export { definePageMeta, defineRouteRules } from './composables'
export type { PageMeta } from './composables'

View File

@ -1,13 +1,13 @@
// Types
export * from './types/compatibility'
export * from './types/components'
export * from './types/config'
export * from './types/hooks'
export * from './types/imports'
export * from './types/head'
export * from './types/module'
export * from './types/nuxt'
export * from './types/router'
export type { NuxtCompatibility, NuxtCompatibilityIssue, NuxtCompatibilityIssues } from './types/compatibility'
export type { Component, ComponentMeta, ComponentsDir, ComponentsOptions, ScanDir } from './types/components'
export type { AppConfig, AppConfigInput, CustomAppConfig, NuxtAppConfig, NuxtBuilder, NuxtConfig, NuxtConfigLayer, NuxtOptions, PublicRuntimeConfig, RuntimeConfig, RuntimeValue, SchemaDefinition, UpperSnakeCase, ViteConfig } from './types/config'
export type { GenerateAppOptions, HookResult, ImportPresetWithDeprecation, NuxtAnalyzeMeta, NuxtHookName, NuxtHooks, NuxtLayout, NuxtMiddleware, NuxtPage, TSReference, VueTSConfig, WatchEvent } from './types/hooks'
export type { ImportsOptions } from './types/imports'
export type { AppHeadMetaObject, MetaObject, MetaObjectRaw, HeadAugmentations } from './types/head'
export type { ModuleDefinition, ModuleMeta, ModuleOptions, ModuleSetupInstallResult, ModuleSetupReturn, NuxtModule, ResolvedModuleOptions } from './types/module'
export type { Nuxt, NuxtApp, NuxtPlugin, NuxtPluginTemplate, NuxtTemplate, NuxtTypeTemplate, ResolvedNuxtTemplate } from './types/nuxt'
export type { RouterConfig, RouterConfigSerializable, RouterOptions } from './types/router'
// Schema
export { default as NuxtConfigSchema } from './config/index'

View File

@ -1 +1,2 @@
export * from './vite'
export { bundle } from './vite'
export type { ViteBuildContext } from './vite'

View File

@ -1 +1 @@
export * from './webpack'
export { bundle } from './webpack'

View File

@ -5,6 +5,7 @@ import { registerEndpoint } from '@nuxt/test-utils/runtime'
vi.mock('#app/compat/idle-callback', () => ({
requestIdleCallback: (cb: Function) => cb(),
cancelIdleCallback: () => {},
}))
const timestamp = Date.now()