File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
packages/esbuild-plugin-node/src Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,8 @@ function isBuiltIn(path: string, extractedModule: ExtractedModule): boolean {
208208 ) ;
209209}
210210
211+ const moduleVersionByPackageJsonPath = new Map < string , string > ( ) ;
212+
211213async function getModuleVersion ( {
212214 extractedModule,
213215 resolveDir,
@@ -217,17 +219,20 @@ async function getModuleVersion({
217219 resolveDir : string ;
218220 build : PluginBuild ;
219221} ) {
220- const { path : packageJsonPath } = await build . resolve (
221- `${ extractedModule . package } /package.json` ,
222- {
223- resolveDir,
224- kind : 'require-resolve' ,
225- }
226- ) ;
222+ const path = `${ extractedModule . package } /package.json` ;
223+ const contents = moduleVersionByPackageJsonPath . get ( path ) ;
224+ if ( contents ) return contents ;
225+
226+ const { path : packageJsonPath } = await build . resolve ( path , {
227+ resolveDir,
228+ kind : 'require-resolve' ,
229+ } ) ;
227230 if ( ! packageJsonPath ) return ;
228231
229232 const packageJsonContents = await readFile ( packageJsonPath ) ;
230- return JSON . parse ( packageJsonContents . toString ( ) ) . version ;
233+ const moduleVersion = JSON . parse ( packageJsonContents . toString ( ) ) . version ;
234+ moduleVersionByPackageJsonPath . set ( path , moduleVersion ) ;
235+ return moduleVersion ;
231236}
232237
233238function getInstrumentation ( {
You can’t perform that action at this time.
0 commit comments