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

fix: Use lower case filenames for types so they can be imported correctly on Linux #9827

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions docs/guide/api-plugin.md
Expand Up @@ -595,9 +595,9 @@ It is possible to type custom events by extending the `CustomEventMap` interface

```ts
// events.d.ts
import 'vite/types/customEvent'
import 'vite/types/custom-event'

declare module 'vite/types/customEvent' {
declare module 'vite/types/custom-event' {
interface CustomEventMap {
'custom:foo': { msg: string }
// 'event-key': payload
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/client.d.ts
@@ -1,4 +1,4 @@
/// <reference path="./types/importMeta.d.ts" />
/// <reference path="./types/import-meta.d.ts" />

// CSS modules
type CSSModuleClasses = { readonly [key: string]: string }
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/client/client.ts
@@ -1,6 +1,6 @@
import type { ErrorPayload, HMRPayload, Update } from 'types/hmrPayload'
import type { ErrorPayload, HMRPayload, Update } from 'types/hmr-payload'
import type { ModuleNamespace, ViteHotContext } from 'types/hot'
import type { InferCustomEventPayload } from 'types/customEvent'
import type { InferCustomEventPayload } from 'types/custom-event'
import { ErrorOverlay, overlayId } from './overlay'
// eslint-disable-next-line node/no-missing-import
import '@vite/env'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/client/overlay.ts
@@ -1,4 +1,4 @@
import type { ErrorPayload } from 'types/hmrPayload'
import type { ErrorPayload } from 'types/hmr-payload'

const template = /*html*/ `
<style>
Expand Down
@@ -1,7 +1,7 @@
// 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\\";import \\"../../../../../../types/importMeta\\";
"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/import-meta\\";
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\\")});
Expand All @@ -20,7 +20,7 @@ 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\\";import \\"../../../../../../types/importMeta\\";
"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/import-meta\\";
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\\")});
Expand Down
@@ -1,4 +1,4 @@
import '../../../../../../types/importMeta'
import '../../../../../../types/import-meta'

export interface ModuleType {
name: string
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/build.ts
Expand Up @@ -19,7 +19,7 @@ import type {
import type { Terser } from 'types/terser'
import commonjsPlugin from '@rollup/plugin-commonjs'
import type { RollupCommonJSOptions } from 'types/commonjs'
import type { RollupDynamicImportVarsOptions } from 'types/dynamicImportVars'
import type { RollupDynamicImportVarsOptions } from 'types/dynamic-import-vars'
import type { TransformOptions } from 'esbuild'
import type { InlineConfig, ResolvedConfig } from './config'
import { isDepsOptimizerEnabled, resolveConfig } from './config'
Expand Down
11 changes: 7 additions & 4 deletions packages/vite/src/node/index.ts
Expand Up @@ -107,7 +107,7 @@ export type {
CustomPayload,
PrunePayload,
ErrorPayload
} from 'types/hmrPayload'
} from 'types/hmr-payload'
export type { Connect } from 'types/connect'
export type { WebSocket, WebSocketAlias } from 'types/ws'
export type { HttpProxy } from 'types/http-proxy'
Expand All @@ -118,15 +118,18 @@ export type {
} from 'types/chokidar'
export type { Terser } from 'types/terser'
export type { RollupCommonJSOptions } from 'types/commonjs'
export type { RollupDynamicImportVarsOptions } from 'types/dynamicImportVars'
export type { CustomEventMap, InferCustomEventPayload } from 'types/customEvent'
export type { RollupDynamicImportVarsOptions } from 'types/dynamic-import-vars'
export type {
CustomEventMap,
InferCustomEventPayload
} from 'types/custom-event'
export type { Matcher, AnymatchPattern, AnymatchFn } from 'types/anymatch'
export type {
ImportGlobFunction,
ImportGlobEagerFunction,
ImportGlobOptions,
KnownAsTypeMap
} from 'types/importGlob'
} from 'types/import-glob'

declare module 'rollup' {
export interface RenderedChunk {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/importMetaGlob.ts
Expand Up @@ -16,7 +16,7 @@ import { parseExpressionAt } from 'acorn'
import MagicString from 'magic-string'
import fg from 'fast-glob'
import { stringifyQuery } from 'ufo'
import type { GeneralImportGlobOptions } from 'types/importGlob'
import type { GeneralImportGlobOptions } from 'types/import-glob'
import type { Plugin } from '../plugin'
import type { ViteDevServer } from '../server'
import type { ModuleNode } from '../server/moduleGraph'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/hmr.ts
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs'
import path from 'node:path'
import type { Server } from 'node:http'
import colors from 'picocolors'
import type { Update } from 'types/hmrPayload'
import type { Update } from 'types/hmr-payload'
import type { RollupError } from 'rollup'
import { CLIENT_DIR } from '../constants'
import { createDebugger, normalizePath, unique } from '../utils'
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/middlewares/error.ts
Expand Up @@ -2,7 +2,7 @@ import colors from 'picocolors'
import type { RollupError } from 'rollup'
import type { Connect } from 'types/connect'
import strip from 'strip-ansi'
import type { ErrorPayload } from 'types/hmrPayload'
import type { ErrorPayload } from 'types/hmr-payload'
import { pad } from '../../utils'
import type { ViteDevServer } from '../..'

Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/server/ws.ts
Expand Up @@ -7,8 +7,8 @@ import colors from 'picocolors'
import type { ServerOptions, WebSocket as WebSocketRaw } from 'ws'
import { WebSocketServer as WebSocketServerRaw } from 'ws'
import type { WebSocket as WebSocketTypes } from 'types/ws'
import type { CustomPayload, ErrorPayload, HMRPayload } from 'types/hmrPayload'
import type { InferCustomEventPayload } from 'types/customEvent'
import type { CustomPayload, ErrorPayload, HMRPayload } from 'types/hmr-payload'
import type { InferCustomEventPayload } from 'types/custom-event'
import type { ResolvedConfig } from '..'
import { isObject } from '../utils'

Expand Down
Expand Up @@ -3,7 +3,7 @@ import type {
FullReloadPayload,
PrunePayload,
UpdatePayload
} from './hmrPayload'
} from './hmr-payload'

export interface CustomEventMap {
'vite:beforeUpdate': UpdatePayload
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/types/hot.d.ts
@@ -1,4 +1,4 @@
import type { InferCustomEventPayload } from './customEvent'
import type { InferCustomEventPayload } from './custom-event'

export type ModuleNamespace = Record<string, any> & {
[Symbol.toStringTag]: 'Module'
Expand Down
Expand Up @@ -18,11 +18,11 @@ interface ImportMeta {

readonly env: ImportMetaEnv

glob: import('./importGlob').ImportGlobFunction
glob: import('./import-glob').ImportGlobFunction
/**
* @deprecated Use `import.meta.glob('*', { eager: true })` instead
*/
globEager: import('./importGlob').ImportGlobEagerFunction
globEager: import('./import-glob').ImportGlobEagerFunction
}

interface ImportMetaEnv {
Expand Down
4 changes: 2 additions & 2 deletions playground/hmr/event.d.ts
@@ -1,6 +1,6 @@
import 'vite/types/customEvent'
import 'vite/types/custom-event'

declare module 'vite/types/customEvent' {
declare module 'vite/types/custom-event' {
interface CustomEventMap {
'custom:foo': { msg: string }
'custom:remote-add': { a: number; b: number }
Expand Down