Skip to content

Commit af3128f

Browse files
committed
feat: natives cache reuse
1 parent 8fcc3e9 commit af3128f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ const TAG = '[vite-plugin-native]'
2929
const loader1 = '@vercel/webpack-asset-relocator-loader'
3030
const NativeExt = '.native.cjs'
3131
const InteropExt = '.interop.mjs'
32+
// `nativesMap` is placed in the global scope and can be effective for multiple builds.
33+
const nativesMap = new Map<string, {
34+
built: boolean
35+
nativeFilename: string
36+
interopFilename: string
37+
}>
3238

3339
export default function native(options: NativeOptions): Plugin {
3440
const assetsDir = options.assetsDir ??= 'node_natives'
35-
const nativesMap = new Map<string, {
36-
built: boolean
37-
nativeFilename: string
38-
interopFilename: string
39-
}>
4041
// Webpack output(absolute path)
4142
let output: string
4243

0 commit comments

Comments
 (0)