File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { Buffer } from 'node:buffer'
2
2
import { readFile } from 'node:fs/promises'
3
- import { transform } from 'lightningcss'
4
3
import type { Options } from './options'
5
4
6
5
const postfixRE = / [ # ? ] .* $ / s
7
6
function cleanUrl ( url : string ) : string {
8
7
return url . replace ( postfixRE , '' )
9
8
}
10
9
11
- export function transformCss (
10
+ export async function transformCss (
12
11
id : string ,
13
12
code : string ,
14
13
options : Options [ 'options' ] ,
15
- ) : { code : string ; map ?: string } {
14
+ ) : Promise < { code : string ; map ?: string } > {
16
15
const filename = cleanUrl ( id )
16
+ const { transform } = await import ( 'lightningcss' )
17
17
const res = transform ( {
18
18
...options ,
19
19
filename,
@@ -32,6 +32,7 @@ export async function transformCssModule(
32
32
const actualId = id . replace ( / \? c s s _ m o d u l e $ / , '' )
33
33
const code = await readFile ( actualId , 'utf-8' )
34
34
const filename = cleanUrl ( actualId )
35
+ const { transform } = await import ( 'lightningcss' )
35
36
const res = transform ( {
36
37
cssModules : true ,
37
38
...options ,
You can’t perform that action at this time.
0 commit comments