Skip to content

Commit

Permalink
feat(css): add more stricter typing of lightningcss
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Oct 25, 2024
1 parent 53a97cf commit d2198d2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export default tseslint.config(
'less',
'sass',
'sass-embedded',
'lightningcss',
'vitest',
'unbuild',
],
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export type { Terser } from 'dep-types/terser'
export type { RollupCommonJSOptions } from 'dep-types/commonjs'
export type { RollupDynamicImportVarsOptions } from 'dep-types/dynamicImportVars'
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
export type { ModuleGraph, ModuleNode } from './server/mixedModuleGraph'
6 changes: 2 additions & 4 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type Sass from 'sass'
import type Stylus from 'stylus'
import type Less from 'less'
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 { formatMessages, transform } from 'esbuild'
import type { RawSourceMap } from '@ampproject/remapping'
Expand Down Expand Up @@ -181,9 +181,7 @@ export interface CSSModulesOptions {
}

export type ResolvedCSSOptions = Omit<CSSOptions, 'lightningcss'> & {
lightningcss?: LightningCSSOptions & {
targets: LightningCSSOptions['targets']
}
lightningcss?: LightningCSSOptions
}

export function resolveCSSOptions(
Expand Down
23 changes: 0 additions & 23 deletions packages/vite/src/types/lightningcss.d.ts

This file was deleted.

18 changes: 18 additions & 0 deletions packages/vite/types/internal/lightningcssOptions.d.ts
Original file line number Diff line number Diff line change
@@ -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'
>

0 comments on commit d2198d2

Please sign in to comment.