From 7c225e52233f47b28049c04dc3fde60607d323b1 Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 19:06:47 +0800 Subject: [PATCH 01/10] chore: move back client types --- packages/vite/api-extractor.client.json | 54 ------------ packages/vite/src/client-types.d.ts | 23 ----- packages/vite/src/types/customEvent.d.ts | 16 ---- packages/vite/src/types/hmrPayload.d.ts | 61 ------------- packages/vite/src/types/hot.d.ts | 33 ------- packages/vite/src/types/importGlob.d.ts | 97 --------------------- packages/vite/src/types/importMeta.d.ts | 25 ------ packages/vite/src/types/package.json | 3 - packages/vite/types/customEvent.d.ts | 17 +++- packages/vite/types/hmrPayload.d.ts | 71 +++++++++++++--- packages/vite/types/hot.d.ts | 34 +++++++- packages/vite/types/importGlob.d.ts | 104 +++++++++++++++++++++-- packages/vite/types/importMeta.d.ts | 36 +++++--- 13 files changed, 231 insertions(+), 343 deletions(-) delete mode 100644 packages/vite/api-extractor.client.json delete mode 100644 packages/vite/src/client-types.d.ts delete mode 100644 packages/vite/src/types/customEvent.d.ts delete mode 100644 packages/vite/src/types/hmrPayload.d.ts delete mode 100644 packages/vite/src/types/hot.d.ts delete mode 100644 packages/vite/src/types/importGlob.d.ts delete mode 100644 packages/vite/src/types/importMeta.d.ts delete mode 100644 packages/vite/src/types/package.json diff --git a/packages/vite/api-extractor.client.json b/packages/vite/api-extractor.client.json deleted file mode 100644 index 81188aa4870d54..00000000000000 --- a/packages/vite/api-extractor.client.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - - "projectFolder": "./src/client", - - "mainEntryPointFilePath": "./src/client-types.d.ts", - - "dtsRollup": { - "enabled": true, - "untrimmedFilePath": "", - "publicTrimmedFilePath": "./client/types.d.ts" - }, - - "apiReport": { - "enabled": false - }, - - "docModel": { - "enabled": false - }, - - "tsdocMetadata": { - "enabled": false - }, - - "messages": { - "compilerMessageReporting": { - "default": { - "logLevel": "warning" - } - }, - - "extractorMessageReporting": { - "default": { - "logLevel": "warning", - "addToApiReportFile": true - }, - - "ae-missing-release-tag": { - "logLevel": "none" - } - }, - - "tsdocMessageReporting": { - "default": { - "logLevel": "warning" - }, - - "tsdoc-undefined-tag": { - "logLevel": "none" - } - } - } -} diff --git a/packages/vite/src/client-types.d.ts b/packages/vite/src/client-types.d.ts deleted file mode 100644 index 270a1ac29f2d8b..00000000000000 --- a/packages/vite/src/client-types.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -export type { - CustomEventMap, - InferCustomEventPayload -} from './types/customEvent' -export type { - HMRPayload, - ConnectedPayload, - UpdatePayload, - Update, - PrunePayload, - FullReloadPayload, - CustomPayload, - ErrorPayload -} from './types/hmrPayload' -export type { ModuleNamespace, ViteHotContext } from './types/hot' -export type { - ImportGlobOptions, - GeneralImportGlobOptions, - KnownAsTypeMap, - ImportGlobFunction, - ImportGlobEagerFunction -} from './types/importGlob' -export type { ImportMetaEnv, ImportMeta } from './types/importMeta' diff --git a/packages/vite/src/types/customEvent.d.ts b/packages/vite/src/types/customEvent.d.ts deleted file mode 100644 index af4db5d14fbe97..00000000000000 --- a/packages/vite/src/types/customEvent.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { - ErrorPayload, - FullReloadPayload, - PrunePayload, - UpdatePayload -} from './hmrPayload' - -export interface CustomEventMap { - 'vite:beforeUpdate': UpdatePayload - 'vite:beforePrune': PrunePayload - 'vite:beforeFullReload': FullReloadPayload - 'vite:error': ErrorPayload -} - -export type InferCustomEventPayload = - T extends keyof CustomEventMap ? CustomEventMap[T] : any diff --git a/packages/vite/src/types/hmrPayload.d.ts b/packages/vite/src/types/hmrPayload.d.ts deleted file mode 100644 index 839095009e76fb..00000000000000 --- a/packages/vite/src/types/hmrPayload.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -export type HMRPayload = - | ConnectedPayload - | UpdatePayload - | FullReloadPayload - | CustomPayload - | ErrorPayload - | PrunePayload - -export interface ConnectedPayload { - type: 'connected' -} - -export interface UpdatePayload { - type: 'update' - updates: Update[] -} - -export interface Update { - type: 'js-update' | 'css-update' - path: string - acceptedPath: string - timestamp: number - /** - * @experimental internal - */ - explicitImportRequired?: boolean | undefined -} - -export interface PrunePayload { - type: 'prune' - paths: string[] -} - -export interface FullReloadPayload { - type: 'full-reload' - path?: string -} - -export interface CustomPayload { - type: 'custom' - event: string - data?: any -} - -export interface ErrorPayload { - type: 'error' - err: { - [name: string]: any - message: string - stack: string - id?: string - frame?: string - plugin?: string - pluginCode?: string - loc?: { - file?: string - line: number - column: number - } - } -} diff --git a/packages/vite/src/types/hot.d.ts b/packages/vite/src/types/hot.d.ts deleted file mode 100644 index 985f3a47197c43..00000000000000 --- a/packages/vite/src/types/hot.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { InferCustomEventPayload } from './customEvent' - -export type ModuleNamespace = Record & { - [Symbol.toStringTag]: 'Module' -} - -export interface ViteHotContext { - readonly data: any - - accept(): void - accept(cb: (mod: ModuleNamespace | undefined) => void): void - accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void - accept( - deps: readonly string[], - cb: (mods: Array) => void - ): void - - acceptExports(exportNames: string | readonly string[]): void - acceptExports( - exportNames: string | readonly string[], - cb: (mod: ModuleNamespace | undefined) => void - ): void - - dispose(cb: (data: any) => void): void - decline(): void - invalidate(): void - - on( - event: T, - cb: (payload: InferCustomEventPayload) => void - ): void - send(event: T, data?: InferCustomEventPayload): void -} diff --git a/packages/vite/src/types/importGlob.d.ts b/packages/vite/src/types/importGlob.d.ts deleted file mode 100644 index 321e3804a7e09a..00000000000000 --- a/packages/vite/src/types/importGlob.d.ts +++ /dev/null @@ -1,97 +0,0 @@ -export interface ImportGlobOptions< - Eager extends boolean, - AsType extends string -> { - /** - * Import type for the import url. - */ - as?: AsType - /** - * Import as static or dynamic - * - * @default false - */ - eager?: Eager - /** - * Import only the specific named export. Set to `default` to import the default export. - */ - import?: string - /** - * Custom queries - */ - query?: string | Record - /** - * Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance. - * - * @default false - */ - exhaustive?: boolean -} - -export type GeneralImportGlobOptions = ImportGlobOptions - -export interface KnownAsTypeMap { - raw: string - url: string - worker: Worker -} - -export interface ImportGlobFunction { - /** - * Import a list of files with a glob pattern. - * - * Overload 1: No generic provided, infer the type from `eager` and `as` - */ - < - Eager extends boolean, - As extends string, - T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown - >( - glob: string | string[], - options?: ImportGlobOptions - ): (Eager extends true ? true : false) extends true - ? Record - : Record Promise> - /** - * Import a list of files with a glob pattern. - * - * Overload 2: Module generic provided, infer the type from `eager: false` - */ - ( - glob: string | string[], - options?: ImportGlobOptions - ): Record Promise> - /** - * Import a list of files with a glob pattern. - * - * Overload 3: Module generic provided, infer the type from `eager: true` - */ - ( - glob: string | string[], - options: ImportGlobOptions - ): Record -} - -export interface ImportGlobEagerFunction { - /** - * Eagerly import a list of files with a glob pattern. - * - * Overload 1: No generic provided, infer the type from `as` - */ - < - As extends string, - T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown - >( - glob: string | string[], - options?: Omit, 'eager'> - ): Record - /** - * Eagerly import a list of files with a glob pattern. - * - * Overload 2: Module generic provided - */ - ( - glob: string | string[], - options?: Omit, 'eager'> - ): Record -} diff --git a/packages/vite/src/types/importMeta.d.ts b/packages/vite/src/types/importMeta.d.ts deleted file mode 100644 index 794c27c73c102c..00000000000000 --- a/packages/vite/src/types/importMeta.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { ViteHotContext } from './hot' -import type { ImportGlobEagerFunction, ImportGlobFunction } from './importGlob' - -export interface ImportMetaEnv { - [key: string]: any - BASE_URL: string - MODE: string - DEV: boolean - PROD: boolean - SSR: boolean -} - -export interface ImportMeta { - url: string - - readonly hot?: ViteHotContext - - readonly env: ImportMetaEnv - - glob: ImportGlobFunction - /** - * @deprecated Use `import.meta.glob('*', { eager: true })` instead - */ - globEager: ImportGlobEagerFunction -} diff --git a/packages/vite/src/types/package.json b/packages/vite/src/types/package.json deleted file mode 100644 index 3d6a75c81455a0..00000000000000 --- a/packages/vite/src/types/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "//": "this file is just here to make pnpm happy with --frozen-lockfile" -} diff --git a/packages/vite/types/customEvent.d.ts b/packages/vite/types/customEvent.d.ts index 09fd7dc36ea481..af4db5d14fbe97 100644 --- a/packages/vite/types/customEvent.d.ts +++ b/packages/vite/types/customEvent.d.ts @@ -1 +1,16 @@ -export type { CustomEventMap, InferCustomEventPayload } from '../client/types' +import type { + ErrorPayload, + FullReloadPayload, + PrunePayload, + UpdatePayload +} from './hmrPayload' + +export interface CustomEventMap { + 'vite:beforeUpdate': UpdatePayload + 'vite:beforePrune': PrunePayload + 'vite:beforeFullReload': FullReloadPayload + 'vite:error': ErrorPayload +} + +export type InferCustomEventPayload = + T extends keyof CustomEventMap ? CustomEventMap[T] : any diff --git a/packages/vite/types/hmrPayload.d.ts b/packages/vite/types/hmrPayload.d.ts index 8bbb5e2fdf3e57..839095009e76fb 100644 --- a/packages/vite/types/hmrPayload.d.ts +++ b/packages/vite/types/hmrPayload.d.ts @@ -1,10 +1,61 @@ -export type { - HMRPayload, - ConnectedPayload, - UpdatePayload, - Update, - PrunePayload, - FullReloadPayload, - CustomPayload, - ErrorPayload -} from '../client/types' +export type HMRPayload = + | ConnectedPayload + | UpdatePayload + | FullReloadPayload + | CustomPayload + | ErrorPayload + | PrunePayload + +export interface ConnectedPayload { + type: 'connected' +} + +export interface UpdatePayload { + type: 'update' + updates: Update[] +} + +export interface Update { + type: 'js-update' | 'css-update' + path: string + acceptedPath: string + timestamp: number + /** + * @experimental internal + */ + explicitImportRequired?: boolean | undefined +} + +export interface PrunePayload { + type: 'prune' + paths: string[] +} + +export interface FullReloadPayload { + type: 'full-reload' + path?: string +} + +export interface CustomPayload { + type: 'custom' + event: string + data?: any +} + +export interface ErrorPayload { + type: 'error' + err: { + [name: string]: any + message: string + stack: string + id?: string + frame?: string + plugin?: string + pluginCode?: string + loc?: { + file?: string + line: number + column: number + } + } +} diff --git a/packages/vite/types/hot.d.ts b/packages/vite/types/hot.d.ts index 83727b7019997e..985f3a47197c43 100644 --- a/packages/vite/types/hot.d.ts +++ b/packages/vite/types/hot.d.ts @@ -1 +1,33 @@ -export type { ModuleNamespace, ViteHotContext } from '../client/types' +import type { InferCustomEventPayload } from './customEvent' + +export type ModuleNamespace = Record & { + [Symbol.toStringTag]: 'Module' +} + +export interface ViteHotContext { + readonly data: any + + accept(): void + accept(cb: (mod: ModuleNamespace | undefined) => void): void + accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void + accept( + deps: readonly string[], + cb: (mods: Array) => void + ): void + + acceptExports(exportNames: string | readonly string[]): void + acceptExports( + exportNames: string | readonly string[], + cb: (mod: ModuleNamespace | undefined) => void + ): void + + dispose(cb: (data: any) => void): void + decline(): void + invalidate(): void + + on( + event: T, + cb: (payload: InferCustomEventPayload) => void + ): void + send(event: T, data?: InferCustomEventPayload): void +} diff --git a/packages/vite/types/importGlob.d.ts b/packages/vite/types/importGlob.d.ts index 7951020049d0dc..321e3804a7e09a 100644 --- a/packages/vite/types/importGlob.d.ts +++ b/packages/vite/types/importGlob.d.ts @@ -1,7 +1,97 @@ -export type { - ImportGlobOptions, - GeneralImportGlobOptions, - KnownAsTypeMap, - ImportGlobFunction, - ImportGlobEagerFunction -} from '../client/types' +export interface ImportGlobOptions< + Eager extends boolean, + AsType extends string +> { + /** + * Import type for the import url. + */ + as?: AsType + /** + * Import as static or dynamic + * + * @default false + */ + eager?: Eager + /** + * Import only the specific named export. Set to `default` to import the default export. + */ + import?: string + /** + * Custom queries + */ + query?: string | Record + /** + * Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance. + * + * @default false + */ + exhaustive?: boolean +} + +export type GeneralImportGlobOptions = ImportGlobOptions + +export interface KnownAsTypeMap { + raw: string + url: string + worker: Worker +} + +export interface ImportGlobFunction { + /** + * Import a list of files with a glob pattern. + * + * Overload 1: No generic provided, infer the type from `eager` and `as` + */ + < + Eager extends boolean, + As extends string, + T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown + >( + glob: string | string[], + options?: ImportGlobOptions + ): (Eager extends true ? true : false) extends true + ? Record + : Record Promise> + /** + * Import a list of files with a glob pattern. + * + * Overload 2: Module generic provided, infer the type from `eager: false` + */ + ( + glob: string | string[], + options?: ImportGlobOptions + ): Record Promise> + /** + * Import a list of files with a glob pattern. + * + * Overload 3: Module generic provided, infer the type from `eager: true` + */ + ( + glob: string | string[], + options: ImportGlobOptions + ): Record +} + +export interface ImportGlobEagerFunction { + /** + * Eagerly import a list of files with a glob pattern. + * + * Overload 1: No generic provided, infer the type from `as` + */ + < + As extends string, + T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown + >( + glob: string | string[], + options?: Omit, 'eager'> + ): Record + /** + * Eagerly import a list of files with a glob pattern. + * + * Overload 2: Module generic provided + */ + ( + glob: string | string[], + options?: Omit, 'eager'> + ): Record +} diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index 97a9518f5d8e4f..794c27c73c102c 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -1,13 +1,25 @@ -import type { - ImportMeta as ViteImportMeta, - ImportMetaEnv as ViteImportMetaEnv -} from '../client/types' - -declare global { - interface GlobOptions { - as?: string - } - - interface ImportMeta extends ViteImportMeta {} - interface ImportMetaEnv extends ViteImportMetaEnv {} +import type { ViteHotContext } from './hot' +import type { ImportGlobEagerFunction, ImportGlobFunction } from './importGlob' + +export interface ImportMetaEnv { + [key: string]: any + BASE_URL: string + MODE: string + DEV: boolean + PROD: boolean + SSR: boolean +} + +export interface ImportMeta { + url: string + + readonly hot?: ViteHotContext + + readonly env: ImportMetaEnv + + glob: ImportGlobFunction + /** + * @deprecated Use `import.meta.glob('*', { eager: true })` instead + */ + globEager: ImportGlobEagerFunction } From 3fb76311fdf25ae6d7d717361fbce64e58d640ed Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 19:08:20 +0800 Subject: [PATCH 02/10] chore: rename dep-types to types --- .eslintrc.cjs | 2 +- packages/vite/src/{dep-types => types}/alias.d.ts | 0 packages/vite/src/{dep-types => types}/anymatch.d.ts | 0 packages/vite/src/{dep-types => types}/chokidar.d.ts | 0 packages/vite/src/{dep-types => types}/commonjs.d.ts | 0 packages/vite/src/{dep-types => types}/connect.d.ts | 0 packages/vite/src/{dep-types => types}/dynamicImportVars.d.ts | 0 packages/vite/src/{dep-types => types}/http-proxy.d.ts | 0 packages/vite/src/{dep-types => types}/package.json | 0 packages/vite/src/{dep-types => types}/shims.d.ts | 0 packages/vite/src/{dep-types => types}/terser.d.ts | 0 packages/vite/src/{dep-types => types}/ws.d.ts | 0 12 files changed, 1 insertion(+), 1 deletion(-) rename packages/vite/src/{dep-types => types}/alias.d.ts (100%) rename packages/vite/src/{dep-types => types}/anymatch.d.ts (100%) rename packages/vite/src/{dep-types => types}/chokidar.d.ts (100%) rename packages/vite/src/{dep-types => types}/commonjs.d.ts (100%) rename packages/vite/src/{dep-types => types}/connect.d.ts (100%) rename packages/vite/src/{dep-types => types}/dynamicImportVars.d.ts (100%) rename packages/vite/src/{dep-types => types}/http-proxy.d.ts (100%) rename packages/vite/src/{dep-types => types}/package.json (100%) rename packages/vite/src/{dep-types => types}/shims.d.ts (100%) rename packages/vite/src/{dep-types => types}/terser.d.ts (100%) rename packages/vite/src/{dep-types => types}/ws.d.ts (100%) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 2ce0e4fbf59c67..6333ec251973c0 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -131,7 +131,7 @@ module.exports = defineConfig({ } }, { - files: ['packages/vite/src/dep-types/**', '*.spec.ts'], + files: ['packages/vite/src/types/**', '*.spec.ts'], rules: { 'node/no-extraneous-import': 'off' } diff --git a/packages/vite/src/dep-types/alias.d.ts b/packages/vite/src/types/alias.d.ts similarity index 100% rename from packages/vite/src/dep-types/alias.d.ts rename to packages/vite/src/types/alias.d.ts diff --git a/packages/vite/src/dep-types/anymatch.d.ts b/packages/vite/src/types/anymatch.d.ts similarity index 100% rename from packages/vite/src/dep-types/anymatch.d.ts rename to packages/vite/src/types/anymatch.d.ts diff --git a/packages/vite/src/dep-types/chokidar.d.ts b/packages/vite/src/types/chokidar.d.ts similarity index 100% rename from packages/vite/src/dep-types/chokidar.d.ts rename to packages/vite/src/types/chokidar.d.ts diff --git a/packages/vite/src/dep-types/commonjs.d.ts b/packages/vite/src/types/commonjs.d.ts similarity index 100% rename from packages/vite/src/dep-types/commonjs.d.ts rename to packages/vite/src/types/commonjs.d.ts diff --git a/packages/vite/src/dep-types/connect.d.ts b/packages/vite/src/types/connect.d.ts similarity index 100% rename from packages/vite/src/dep-types/connect.d.ts rename to packages/vite/src/types/connect.d.ts diff --git a/packages/vite/src/dep-types/dynamicImportVars.d.ts b/packages/vite/src/types/dynamicImportVars.d.ts similarity index 100% rename from packages/vite/src/dep-types/dynamicImportVars.d.ts rename to packages/vite/src/types/dynamicImportVars.d.ts diff --git a/packages/vite/src/dep-types/http-proxy.d.ts b/packages/vite/src/types/http-proxy.d.ts similarity index 100% rename from packages/vite/src/dep-types/http-proxy.d.ts rename to packages/vite/src/types/http-proxy.d.ts diff --git a/packages/vite/src/dep-types/package.json b/packages/vite/src/types/package.json similarity index 100% rename from packages/vite/src/dep-types/package.json rename to packages/vite/src/types/package.json diff --git a/packages/vite/src/dep-types/shims.d.ts b/packages/vite/src/types/shims.d.ts similarity index 100% rename from packages/vite/src/dep-types/shims.d.ts rename to packages/vite/src/types/shims.d.ts diff --git a/packages/vite/src/dep-types/terser.d.ts b/packages/vite/src/types/terser.d.ts similarity index 100% rename from packages/vite/src/dep-types/terser.d.ts rename to packages/vite/src/types/terser.d.ts diff --git a/packages/vite/src/dep-types/ws.d.ts b/packages/vite/src/types/ws.d.ts similarity index 100% rename from packages/vite/src/dep-types/ws.d.ts rename to packages/vite/src/types/ws.d.ts From 88160d64843cd9b22d70f8fd1fcc3aa7b16db112 Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 19:09:32 +0800 Subject: [PATCH 03/10] chore: remove import-meta export --- packages/vite/client.d.ts | 2 +- packages/vite/import-meta.d.ts | 10 ---------- packages/vite/package.json | 4 ---- 3 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 packages/vite/import-meta.d.ts diff --git a/packages/vite/client.d.ts b/packages/vite/client.d.ts index 5ee6940825b119..e99b4a526b7a58 100644 --- a/packages/vite/client.d.ts +++ b/packages/vite/client.d.ts @@ -1,4 +1,4 @@ -/// +/// // CSS modules type CSSModuleClasses = { readonly [key: string]: string } diff --git a/packages/vite/import-meta.d.ts b/packages/vite/import-meta.d.ts deleted file mode 100644 index 73baf3c106c74f..00000000000000 --- a/packages/vite/import-meta.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { - ImportMeta as ViteImportMeta, - ImportMetaEnv as ViteImportMetaEnv - // eslint-disable-next-line node/no-missing-import -- use .js for `moduleResolution: "nodenext"` -} from './client/types.js' - -declare global { - interface ImportMeta extends ViteImportMeta {} - interface ImportMetaEnv extends ViteImportMetaEnv {} -} diff --git a/packages/vite/package.json b/packages/vite/package.json index 935a1dffa13461..e331d5df4a2419 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -20,9 +20,6 @@ "./client": { "types": "./client.d.ts" }, - "./import-meta": { - "types": "./import-meta.d.ts" - }, "./client/types": { "types": "./client/types.d.ts" }, @@ -33,7 +30,6 @@ "bin", "dist", "client.d.ts", - "import-meta.d.ts", "index.cjs", "src/client", "types", From c7320f491a21683866a1e519783549558214fff1 Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 19:22:47 +0800 Subject: [PATCH 04/10] chore: patch dep-types only --- packages/vite/package.json | 4 +-- packages/vite/scripts/patchTypes.ts | 41 +++++++++++------------------ pnpm-lock.yaml | 8 +++--- 3 files changed, 22 insertions(+), 31 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index e331d5df4a2419..4fa27046bc5c20 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -123,8 +123,8 @@ "strip-literal": "^0.4.2", "tsconfck": "^2.0.1", "tslib": "^2.4.0", - "dep-types": "link:./src/dep-types", - "types": "link:./src/types", + "dep-types": "link:./src/types", + "types": "link:./types", "ufo": "^0.8.5", "ws": "^8.9.0" }, diff --git a/packages/vite/scripts/patchTypes.ts b/packages/vite/scripts/patchTypes.ts index 8d86c9c7b76292..4fb1ebb66dc894 100644 --- a/packages/vite/scripts/patchTypes.ts +++ b/packages/vite/scripts/patchTypes.ts @@ -3,20 +3,19 @@ import { dirname, relative, resolve } from 'node:path' import { fileURLToPath } from 'node:url' import type { ParseResult } from '@babel/parser' import { parse } from '@babel/parser' -import type { File, StringLiteral } from '@babel/types' +import type { File } from '@babel/types' import colors from 'picocolors' import MagicString from 'magic-string' const dir = dirname(fileURLToPath(import.meta.url)) const tempDir = resolve(dir, '../temp/node') -const typesDir = resolve(dir, '../src/types') -const depTypesDir = resolve(dir, '../src/dep-types') +const depTypesDir = resolve(dir, '../src/types') // walk through the temp dts dir, find all import/export of types/*, deps-types/* // and rewrite them into relative imports - so that api-extractor actually // includes them in the rolled-up final d.ts file. walkDir(tempDir) -console.log(colors.green(colors.bold(`patched types/*, deps-types/* imports`))) +console.log(colors.green(colors.bold(`patched deps-types/* imports`))) function slash(p: string): string { return p.replace(/\\/g, '/') @@ -55,29 +54,21 @@ function rewriteFile(file: string): void { statement.type === 'ExportAllDeclaration' ) { const source = statement.source - if (source?.value.startsWith('types/')) { - rewriteSource(str, source, file, typesDir, 'types') - } else if (source?.value.startsWith('dep-types/')) { - rewriteSource(str, source, file, depTypesDir, 'dep-types') + if (source?.value.startsWith('dep-types/')) { + const absoluteTypePath = resolve( + depTypesDir, + source.value.slice('dep-types/'.length) + ) + const relativeTypePath = slash( + relative(dirname(file), absoluteTypePath) + ) + str.overwrite( + source.start!, + source.end!, + JSON.stringify(relativeTypePath) + ) } } } writeFileSync(file, str.toString()) } - -function rewriteSource( - str: MagicString, - source: StringLiteral, - rewritingFile: string, - typesDir: string, - typesDirName: string -) { - const absoluteTypePath = resolve( - typesDir, - source.value.slice(typesDirName.length + 1) - ) - const relativeTypePath = slash( - relative(dirname(rewritingFile), absoluteTypePath) - ) - str.overwrite(source.start!, source.end!, JSON.stringify(relativeTypePath)) -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3eeeda1cd37e39..87f5e56ff5c330 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -233,7 +233,7 @@ importers: cors: ^2.8.5 cross-spawn: ^7.0.3 debug: ^4.3.4 - dep-types: link:./src/dep-types + dep-types: link:./src/types dotenv: ^14.3.2 dotenv-expand: ^5.1.0 es-module-lexer: ^1.0.3 @@ -269,7 +269,7 @@ importers: strip-literal: ^0.4.2 tsconfck: ^2.0.1 tslib: ^2.4.0 - types: link:./src/types + types: link:./types ufo: ^0.8.5 ws: ^8.9.0 dependencies: @@ -300,7 +300,7 @@ importers: cors: 2.8.5 cross-spawn: 7.0.3 debug: 4.3.4 - dep-types: link:src/dep-types + dep-types: link:src/types dotenv: 14.3.2 dotenv-expand: 5.1.0 es-module-lexer: 1.0.3 @@ -331,7 +331,7 @@ importers: strip-literal: 0.4.2 tsconfck: 2.0.1 tslib: 2.4.0 - types: link:src/types + types: link:types ufo: 0.8.5 ws: 8.9.0 From 6d96fca9bbbdad3b5b77df289c1ad11877a7592f Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 19:58:03 +0800 Subject: [PATCH 05/10] chore: implement pre post patch --- packages/vite/package.json | 16 +++--- packages/vite/scripts/patchTypes.ts | 74 ------------------------- packages/vite/scripts/postPatchTypes.ts | 16 ++++++ packages/vite/scripts/prePatchTypes.ts | 23 ++++++++ packages/vite/scripts/util.ts | 72 ++++++++++++++++++++++++ 5 files changed, 118 insertions(+), 83 deletions(-) delete mode 100644 packages/vite/scripts/patchTypes.ts create mode 100644 packages/vite/scripts/postPatchTypes.ts create mode 100644 packages/vite/scripts/prePatchTypes.ts create mode 100644 packages/vite/scripts/util.ts diff --git a/packages/vite/package.json b/packages/vite/package.json index 4fa27046bc5c20..5afe0cb0ac0268 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -32,8 +32,7 @@ "client.d.ts", "index.cjs", "src/client", - "types", - "client/types.d.ts" + "types" ], "engines": { "node": "^14.18.0 || >=16.0.0" @@ -51,13 +50,12 @@ "dev": "rimraf dist && pnpm run build-bundle -w", "build": "rimraf dist && run-s build-bundle build-types", "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript", - "build-types": "run-p build-node-types build-client-types", - "build-node-types": "run-s build-node-types-temp build-node-types-patch build-node-types-roll build-node-types-check", - "build-node-types-temp": "tsc --emitDeclarationOnly --outDir temp/node -p src/node", - "build-node-types-patch": "tsx scripts/patchTypes.ts", - "build-node-types-roll": "api-extractor run && rimraf temp", - "build-node-types-check": "tsc --project tsconfig.check.json", - "build-client-types": "api-extractor run -c api-extractor.client.json", + "build-types": "run-s build-types-temp build-types-pre-patch build-types-roll build-types-post-patch build-types-check", + "build-types-temp": "tsc --emitDeclarationOnly --outDir temp/node -p src/node", + "build-types-pre-patch": "tsx scripts/prePatchTypes.ts", + "build-types-roll": "api-extractor run && rimraf temp", + "build-types-post-patch": "tsx scripts/postPatchTypes.ts", + "build-types-check": "tsc --project tsconfig.check.json", "lint": "eslint --cache --ext .ts src/**", "format": "prettier --write --cache --parser typescript \"src/**/*.ts\"", "prepublishOnly": "npm run build" diff --git a/packages/vite/scripts/patchTypes.ts b/packages/vite/scripts/patchTypes.ts deleted file mode 100644 index 4fb1ebb66dc894..00000000000000 --- a/packages/vite/scripts/patchTypes.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs' -import { dirname, relative, resolve } from 'node:path' -import { fileURLToPath } from 'node:url' -import type { ParseResult } from '@babel/parser' -import { parse } from '@babel/parser' -import type { File } from '@babel/types' -import colors from 'picocolors' -import MagicString from 'magic-string' - -const dir = dirname(fileURLToPath(import.meta.url)) -const tempDir = resolve(dir, '../temp/node') -const depTypesDir = resolve(dir, '../src/types') - -// walk through the temp dts dir, find all import/export of types/*, deps-types/* -// and rewrite them into relative imports - so that api-extractor actually -// includes them in the rolled-up final d.ts file. -walkDir(tempDir) -console.log(colors.green(colors.bold(`patched deps-types/* imports`))) - -function slash(p: string): string { - return p.replace(/\\/g, '/') -} - -function walkDir(dir: string): void { - const files = readdirSync(dir) - for (const file of files) { - const resolved = resolve(dir, file) - const isDir = statSync(resolved).isDirectory() - if (isDir) { - walkDir(resolved) - } else { - rewriteFile(resolved) - } - } -} - -function rewriteFile(file: string): void { - const content = readFileSync(file, 'utf-8') - const str = new MagicString(content) - let ast: ParseResult - try { - ast = parse(content, { - sourceType: 'module', - plugins: ['typescript', 'classProperties'] - }) - } catch (e) { - console.log(colors.red(`failed to parse ${file}`)) - throw e - } - for (const statement of ast.program.body) { - if ( - statement.type === 'ImportDeclaration' || - statement.type === 'ExportNamedDeclaration' || - statement.type === 'ExportAllDeclaration' - ) { - const source = statement.source - if (source?.value.startsWith('dep-types/')) { - const absoluteTypePath = resolve( - depTypesDir, - source.value.slice('dep-types/'.length) - ) - const relativeTypePath = slash( - relative(dirname(file), absoluteTypePath) - ) - str.overwrite( - source.start!, - source.end!, - JSON.stringify(relativeTypePath) - ) - } - } - } - writeFileSync(file, str.toString()) -} diff --git a/packages/vite/scripts/postPatchTypes.ts b/packages/vite/scripts/postPatchTypes.ts new file mode 100644 index 00000000000000..95f3fc217efcb0 --- /dev/null +++ b/packages/vite/scripts/postPatchTypes.ts @@ -0,0 +1,16 @@ +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import colors from 'picocolors' +import { rewriteImports } from './util' + +const dir = dirname(fileURLToPath(import.meta.url)) +const nodeDts = resolve(dir, '../dist/node/index.d.ts') + +// rewrite `types/*` import to relative import +rewriteImports(nodeDts, (importPath) => { + if (importPath.startsWith('types/')) { + return '../../' + importPath + } +}) + +console.log(colors.green(colors.bold(`patched types/* imports`))) diff --git a/packages/vite/scripts/prePatchTypes.ts b/packages/vite/scripts/prePatchTypes.ts new file mode 100644 index 00000000000000..eda006b476209d --- /dev/null +++ b/packages/vite/scripts/prePatchTypes.ts @@ -0,0 +1,23 @@ +import { dirname, relative, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' +import colors from 'picocolors' +import { rewriteImports, slash } from './util' + +const dir = dirname(fileURLToPath(import.meta.url)) +const tempDir = resolve(dir, '../temp/node') +const depTypesDir = resolve(dir, '../src/types') + +// walk through the temp dts dir, find all import/export of, deps-types/* +// and rewrite them into relative imports - so that api-extractor actually +// includes them in the rolled-up final d.ts file. +rewriteImports(tempDir, (importPath, currentFile) => { + if (importPath.startsWith('dep-types/')) { + const absoluteTypePath = resolve( + depTypesDir, + importPath.slice('dep-types/'.length) + ) + return slash(relative(dirname(currentFile), absoluteTypePath)) + } +}) + +console.log(colors.green(colors.bold(`patched deps-types/* imports`))) diff --git a/packages/vite/scripts/util.ts b/packages/vite/scripts/util.ts new file mode 100644 index 00000000000000..4cc867afe82801 --- /dev/null +++ b/packages/vite/scripts/util.ts @@ -0,0 +1,72 @@ +import { readFileSync, readdirSync, statSync, writeFileSync } from 'node:fs' +import { resolve } from 'node:path' +import type { ParseResult } from '@babel/parser' +import { parse } from '@babel/parser' +import type { File } from '@babel/types' +import colors from 'picocolors' +import MagicString from 'magic-string' + +export function rewriteImports( + fileOrDir: string, + rewrite: (importPath: string, currentFile: string) => string | void +): void { + walkDir(fileOrDir, (file) => { + rewriteFileImports(file, (importPath) => { + return rewrite(importPath, file) + }) + }) +} + +export function slash(p: string): string { + return p.replace(/\\/g, '/') +} + +function walkDir(dir: string, handleFile: (file: string) => void): void { + if (statSync(dir).isDirectory()) { + const files = readdirSync(dir) + for (const file of files) { + const resolved = resolve(dir, file) + walkDir(resolved, handleFile) + } + } else { + handleFile(dir) + } +} + +function rewriteFileImports( + file: string, + rewrite: (importPath: string) => string | void +): void { + const content = readFileSync(file, 'utf-8') + const str = new MagicString(content) + let ast: ParseResult + try { + ast = parse(content, { + sourceType: 'module', + plugins: ['typescript', 'classProperties'] + }) + } catch (e) { + console.log(colors.red(`failed to parse ${file}`)) + throw e + } + for (const statement of ast.program.body) { + if ( + statement.type === 'ImportDeclaration' || + statement.type === 'ExportNamedDeclaration' || + statement.type === 'ExportAllDeclaration' + ) { + const source = statement.source + if (source?.value) { + const newImportPath = rewrite(source.value) + if (newImportPath) { + str.overwrite( + source.start!, + source.end!, + JSON.stringify(newImportPath) + ) + } + } + } + } + writeFileSync(file, str.toString()) +} From 4b85ee93f8a2cf7caf1f22e8f3e4cecd71b6fb37 Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 19:59:33 +0800 Subject: [PATCH 06/10] chore: fix import meta ambient --- .eslintignore | 1 - .gitignore | 1 - .prettierignore | 1 - docs/guide/api-plugin.md | 21 ++++++------------- .../plugins/importGlob/fixture-a/index.ts | 6 +----- packages/vite/src/node/index.ts | 1 - packages/vite/types/importMeta.d.ts | 21 ++++++++++++------- playground/hmr/event.d.ts | 21 +++++++------------ 8 files changed, 28 insertions(+), 45 deletions(-) diff --git a/.eslintignore b/.eslintignore index 833faed81beb2b..2974196847e467 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ dist playground-temp temp -packages/vite/client/types.d.ts diff --git a/.gitignore b/.gitignore index 8aafb6ab143259..7f1cab0e1f4356 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ *.local *.log /.vscode/ -/packages/vite/client/types.d.ts /packages/vite/LICENSE dist dist-ssr diff --git a/.prettierignore b/.prettierignore index be3598b2ccb5b3..b1ea458b9bb9d8 100644 --- a/.prettierignore +++ b/.prettierignore @@ -9,4 +9,3 @@ playground/tsconfig-json-load-error/has-error/tsconfig.json playground/html/invalid.html playground/html/valid.html playground/worker/classic-worker.js -packages/vite/client/types.d.ts diff --git a/docs/guide/api-plugin.md b/docs/guide/api-plugin.md index 33d8ba0e9802b7..c18c6daca3263f 100644 --- a/docs/guide/api-plugin.md +++ b/docs/guide/api-plugin.md @@ -595,21 +595,12 @@ It is possible to type custom events by extending the `CustomEventMap` interface ```ts // events.d.ts -import 'vite' -import 'vite/client/types' +import 'vite/types/customEvent' -interface MyCustomEventMap { - 'custom:foo': { msg: string } - // 'event-key': payload -} - -// extend interface for server-side -declare module 'vite' { - interface CustomEventMap extends MyCustomEventMap {} -} - -// extend interface for client-side -declare module 'vite/client/types' { - interface CustomEventMap extends MyCustomEventMap {} +declare module 'vite/types/customEvent' { + interface CustomEventMap { + 'custom:foo': { msg: string } + // 'event-key': payload + } } ``` diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts index ccf47d4edca6cf..452336631be666 100644 --- a/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts +++ b/packages/vite/src/node/__tests__/plugins/importGlob/fixture-a/index.ts @@ -1,8 +1,4 @@ -import type { ImportMeta as ViteImportMeta } from 'types/importMeta' - -declare global { - interface ImportMeta extends ViteImportMeta {} -} +import 'types/importMeta' export interface ModuleType { name: string diff --git a/packages/vite/src/node/index.ts b/packages/vite/src/node/index.ts index 2bc81f001d6947..052dcf5c2491fb 100644 --- a/packages/vite/src/node/index.ts +++ b/packages/vite/src/node/index.ts @@ -103,7 +103,6 @@ export type { ErrorPayload } from 'types/hmrPayload' export type { CustomEventMap, InferCustomEventPayload } from 'types/customEvent' -// [deprecated: use vite/client/types instead] export type { ImportGlobFunction, ImportGlobEagerFunction, diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index 794c27c73c102c..390f12d735bea9 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -1,7 +1,14 @@ -import type { ViteHotContext } from './hot' -import type { ImportGlobEagerFunction, ImportGlobFunction } from './importGlob' +// This file is an augmentation to the built-in ImportMeta interface +// Thus cannot contain any top-level imports +// -export interface ImportMetaEnv { +/* eslint-disable @typescript-eslint/consistent-type-imports */ + +// Duplicate of import('../src/node/importGlob').GlobOptions in order to +// avoid breaking the production client type. Because this file is referenced +// in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist. + +interface ImportMetaEnv { [key: string]: any BASE_URL: string MODE: string @@ -10,16 +17,16 @@ export interface ImportMetaEnv { SSR: boolean } -export interface ImportMeta { +interface ImportMeta { url: string - readonly hot?: ViteHotContext + readonly hot?: import('./hot').ViteHotContext readonly env: ImportMetaEnv - glob: ImportGlobFunction + glob: import('./importGlob').ImportGlobFunction /** * @deprecated Use `import.meta.glob('*', { eager: true })` instead */ - globEager: ImportGlobEagerFunction + globEager: import('./importGlob').ImportGlobEagerFunction } diff --git a/playground/hmr/event.d.ts b/playground/hmr/event.d.ts index 5b4818294ed744..151a9cc3b861cd 100644 --- a/playground/hmr/event.d.ts +++ b/playground/hmr/event.d.ts @@ -1,16 +1,9 @@ -import 'vite' -import 'vite/client/types' +import 'vite/types/customEvent' -interface MyCustomEventMap { - 'custom:foo': { msg: string } - 'custom:remote-add': { a: number; b: number } - 'custom:remote-add-result': { result: string } -} - -declare module 'vite' { - interface CustomEventMap extends MyCustomEventMap {} -} - -declare module 'vite/client/types' { - interface CustomEventMap extends MyCustomEventMap {} +declare module 'vite/types/customEvent' { + interface CustomEventMap { + 'custom:foo': { msg: string } + 'custom:remote-add': { a: number; b: number } + 'custom:remote-add-result': { result: string } + } } From a7edf9a60624f9835a7609bee0f39a0215425184 Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 20:27:35 +0800 Subject: [PATCH 07/10] chore: cleanup --- packages/vite/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/vite/package.json b/packages/vite/package.json index 5afe0cb0ac0268..a567a7afc3790c 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -20,9 +20,6 @@ "./client": { "types": "./client.d.ts" }, - "./client/types": { - "types": "./client/types.d.ts" - }, "./dist/client/*": "./dist/client/*", "./package.json": "./package.json" }, From ba5a11fed4e76c6f1c8e114df247ce277c31f3cb Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 20:33:04 +0800 Subject: [PATCH 08/10] docs: update contributing --- CONTRIBUTING.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f2f04ce43f86c7..78271bb6768b3c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -218,10 +218,12 @@ Avoid deps with large transitive dependencies that result in bloated size compar Vite aims to be fully usable as a dependency in a TypeScript project (e.g. it should provide proper typings for VitePress), and also in `vite.config.ts`. This means technically a dependency whose types are exposed needs to be part of `dependencies` instead of `devDependencies`. However, this also means we won't be able to bundle it. -To get around this, we inline some of these dependencies' types in `packages/vite/src/dep-types`. This way, we can still expose the typing but bundle the dependency's source code. +To get around this, we inline some of these dependencies' types in `packages/vite/src/types`. This way, we can still expose the typing but bundle the dependency's source code. Use `pnpm run check-dist-types` to check that the bundled types do not rely on types in `devDependencies`. If you are adding `dependencies`, make sure to configure `tsconfig.check.json`. +For types shared between client and node, they should be added into `packages/vite/types`. These types are not bundled and are published as is (though they are still considered internal). Dependency types within this directory (e.g. `packages/vite/types/chokidar.d.ts`) are deprecated and should be added to `packages/vite/src/types` instead. + ### Think Before Adding Yet Another Option We already have many config options, and we should avoid fixing an issue by adding yet another one. Before adding an option, consider whether the problem: From 0009be264b95da8963273846a68bc138dba813a3 Mon Sep 17 00:00:00 2001 From: bluwy Date: Sun, 25 Sep 2022 20:33:56 +0800 Subject: [PATCH 09/10] test: update unit --- .../plugins/importGlob/__snapshots__/fixture.test.ts.snap | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap index f4103222acebdd..e638850c4ce0b0 100644 --- a/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap +++ b/packages/vite/src/node/__tests__/plugins/importGlob/__snapshots__/fixture.test.ts.snap @@ -1,7 +1,8 @@ // Vitest Snapshot v1 exports[`fixture > transform 1`] = ` -"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";export const basic = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")}); +"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";import \\"types/importMeta\\"; +export const basic = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")}); export const basicEager = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": __vite_glob_1_0,\\"./modules/b.ts\\": __vite_glob_1_1,\\"./modules/index.ts\\": __vite_glob_1_2}); export const ignore = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")}); export const namedEager = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": __vite_glob_3_0,\\"./modules/b.ts\\": __vite_glob_3_1,\\"./modules/index.ts\\": __vite_glob_3_2}); @@ -19,7 +20,8 @@ export const cleverCwd2 = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": ( `; exports[`fixture > transform with restoreQueryExtension 1`] = ` -"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";export const basic = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")}); +"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";import \\"types/importMeta\\"; +export const basic = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")}); export const basicEager = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": __vite_glob_1_0,\\"./modules/b.ts\\": __vite_glob_1_1,\\"./modules/index.ts\\": __vite_glob_1_2}); export const ignore = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")}); export const namedEager = /* #__PURE__ */ Object.assign({\\"./modules/a.ts\\": __vite_glob_3_0,\\"./modules/b.ts\\": __vite_glob_3_1,\\"./modules/index.ts\\": __vite_glob_3_2}); From 5366624c3eb3f98bb0cce6435343f7a21df801fa Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Sun, 25 Sep 2022 21:37:42 +0800 Subject: [PATCH 10/10] docs: remove stale comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 / green --- packages/vite/types/importMeta.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index 390f12d735bea9..da338b6833bed6 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -4,10 +4,6 @@ /* eslint-disable @typescript-eslint/consistent-type-imports */ -// Duplicate of import('../src/node/importGlob').GlobOptions in order to -// avoid breaking the production client type. Because this file is referenced -// in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist. - interface ImportMetaEnv { [key: string]: any BASE_URL: string