mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
feat(css): add more stricter typing of lightningcss (#18460)
This commit is contained in:
parent
3a27f627df
commit
b9b925eb3f
@ -90,6 +90,7 @@ export default tseslint.config(
|
|||||||
'less',
|
'less',
|
||||||
'sass',
|
'sass',
|
||||||
'sass-embedded',
|
'sass-embedded',
|
||||||
|
'lightningcss',
|
||||||
'vitest',
|
'vitest',
|
||||||
'unbuild',
|
'unbuild',
|
||||||
],
|
],
|
||||||
|
@ -219,7 +219,7 @@ export type { Terser } from 'dep-types/terser'
|
|||||||
export type { RollupCommonJSOptions } from 'dep-types/commonjs'
|
export type { RollupCommonJSOptions } from 'dep-types/commonjs'
|
||||||
export type { RollupDynamicImportVarsOptions } from 'dep-types/dynamicImportVars'
|
export type { RollupDynamicImportVarsOptions } from 'dep-types/dynamicImportVars'
|
||||||
export type { Matcher, AnymatchPattern, AnymatchFn } from 'dep-types/anymatch'
|
export type { Matcher, AnymatchPattern, AnymatchFn } from 'dep-types/anymatch'
|
||||||
export type { LightningCSSOptions } from 'dep-types/lightningcss'
|
export type { LightningCSSOptions } from 'types/internal/lightningcssOptions'
|
||||||
|
|
||||||
// Backward compatibility
|
// Backward compatibility
|
||||||
export type { ModuleGraph, ModuleNode } from './server/mixedModuleGraph'
|
export type { ModuleGraph, ModuleNode } from './server/mixedModuleGraph'
|
||||||
|
@ -21,7 +21,7 @@ import type Sass from 'sass'
|
|||||||
import type Stylus from 'stylus'
|
import type Stylus from 'stylus'
|
||||||
import type Less from 'less'
|
import type Less from 'less'
|
||||||
import type { Alias } from 'dep-types/alias'
|
import type { Alias } from 'dep-types/alias'
|
||||||
import type { LightningCSSOptions } from 'dep-types/lightningcss'
|
import type { LightningCSSOptions } from 'types/internal/lightningcssOptions'
|
||||||
import type { TransformOptions } from 'esbuild'
|
import type { TransformOptions } from 'esbuild'
|
||||||
import { formatMessages, transform } from 'esbuild'
|
import { formatMessages, transform } from 'esbuild'
|
||||||
import type { RawSourceMap } from '@ampproject/remapping'
|
import type { RawSourceMap } from '@ampproject/remapping'
|
||||||
@ -181,9 +181,7 @@ export interface CSSModulesOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & {
|
export type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & {
|
||||||
lightningcss?: LightningCSSOptions & {
|
lightningcss?: LightningCSSOptions
|
||||||
targets: LightningCSSOptions['targets']
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolveCSSOptions(
|
export function resolveCSSOptions(
|
||||||
|
23
packages/vite/src/types/lightningcss.d.ts
vendored
23
packages/vite/src/types/lightningcss.d.ts
vendored
@ -1,23 +0,0 @@
|
|||||||
import type {
|
|
||||||
CSSModulesConfig,
|
|
||||||
Drafts,
|
|
||||||
NonStandard,
|
|
||||||
PseudoClasses,
|
|
||||||
Targets,
|
|
||||||
} from 'lightningcss'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options are spread, so you can also use options that are not typed here like
|
|
||||||
* visitor (not exposed because it would impact too much the bundle size)
|
|
||||||
*/
|
|
||||||
export type LightningCSSOptions = {
|
|
||||||
targets?: Targets
|
|
||||||
include?: number
|
|
||||||
exclude?: number
|
|
||||||
drafts?: Drafts
|
|
||||||
nonStandard?: NonStandard
|
|
||||||
pseudoClasses?: PseudoClasses
|
|
||||||
unusedSymbols?: string[]
|
|
||||||
cssModules?: CSSModulesConfig
|
|
||||||
errorRecovery?: boolean
|
|
||||||
}
|
|
18
packages/vite/types/internal/lightningcssOptions.d.ts
vendored
Normal file
18
packages/vite/types/internal/lightningcssOptions.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||||
|
|
||||||
|
// @ts-ignore `sass` may not be installed
|
||||||
|
import type Lightningcss from 'lightningcss'
|
||||||
|
|
||||||
|
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
||||||
|
|
||||||
|
export type LightningCSSOptions = Omit<
|
||||||
|
Lightningcss.BundleAsyncOptions<Lightningcss.CustomAtRules>,
|
||||||
|
| 'filename'
|
||||||
|
| 'resolver'
|
||||||
|
| 'minify'
|
||||||
|
| 'sourceMap'
|
||||||
|
| 'analyzeDependencies'
|
||||||
|
// properties not overridden by Vite, but does not make sense to set by end users
|
||||||
|
| 'inputSourceMap'
|
||||||
|
| 'projectRoot'
|
||||||
|
>
|
Loading…
Reference in New Issue
Block a user