@@ -3,7 +3,7 @@ import { existsFileSync } from '../shared/fs.ts'
3
3
import type { ImportMap } from '../types.ts'
4
4
import { VERSION } from '../version.ts'
5
5
import { checksum } from './dist/wasm-checksum.js'
6
- import { default as init_wasm , transformSync } from './dist/wasm-pack.js'
6
+ import init , { transformSync } from './dist/wasm-pack.js'
7
7
8
8
export interface SWCOptions {
9
9
target ?: 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020'
@@ -29,17 +29,17 @@ interface DependencyDescriptor {
29
29
isDynamic : boolean ,
30
30
}
31
31
32
- export interface TransformRet {
32
+ export interface TransformResult {
33
33
code : string
34
- map ?: string
35
34
deps : DependencyDescriptor [ ]
36
35
inlineStyles : Record < string , { type : string , quasis : string [ ] , exprs : string [ ] } >
36
+ map ?: string
37
37
}
38
38
39
39
/**
40
40
* transpile code synchronously by swc.
41
41
*
42
- * ```javascript
42
+ * ```tsx
43
43
* transpileSync(`
44
44
* export default App() {
45
45
* return <h1>Hello World</h1>
@@ -52,8 +52,11 @@ export interface TransformRet {
52
52
* }
53
53
* })
54
54
* ```
55
+ *
56
+ * @param {string } code - code string.
57
+ * @param {object } opts - transform options.
55
58
*/
56
- export function transpileSync ( code : string , opts ?: TransformOptions ) : TransformRet {
59
+ export function transpileSync ( code : string , opts ?: TransformOptions ) : TransformResult {
57
60
return transformSync ( code , opts )
58
61
}
59
62
@@ -65,17 +68,17 @@ export const initWasm = async (denoCacheDir: string) => {
65
68
const cachePath = `${ cacheDir } /compiler.${ checksum } .wasm`
66
69
if ( existsFileSync ( cachePath ) ) {
67
70
const wasmData = await Deno . readFile ( cachePath )
68
- await init_wasm ( wasmData )
71
+ await init ( wasmData )
69
72
} else {
70
73
const { default : getWasmData } = await import ( './dist/wasm.js' )
71
74
const wasmData = getWasmData ( )
72
- await init_wasm ( wasmData )
75
+ await init ( wasmData )
73
76
await ensureDir ( cacheDir )
74
77
await Deno . writeFile ( cachePath , wasmData )
75
78
}
76
79
}
77
80
78
81
/**
79
- * wasm build checksum.
82
+ * The wasm build checksum.
80
83
*/
81
84
export const buildChecksum = checksum
0 commit comments