11import { createRequire } from "module" ;
22import path from "path" ;
3- import { fileURLToPath } from "url" ;
3+ import { fileURLToPath , pathToFileURL } from "url" ;
44import { describe , it , expect } from "vitest" ;
55
66const __filename = fileURLToPath ( import . meta. url ) ;
@@ -19,8 +19,9 @@ describe("Build Test", () => {
1919
2020 it ( "should successfully import ESM module" , async ( ) => {
2121 const esmPath = path . resolve ( __dirname , "../../dist/lib.js" ) ;
22+ const esmFileURL = pathToFileURL ( esmPath ) . href ;
2223
23- const esmModule = ( await import ( esmPath ) ) as Record < string , unknown > ;
24+ const esmModule = ( await import ( esmFileURL ) ) as Record < string , unknown > ;
2425
2526 expect ( esmModule ) . toBeDefined ( ) ;
2627 expect ( typeof esmModule ) . toBe ( "object" ) ;
@@ -34,7 +35,8 @@ describe("Build Test", () => {
3435
3536 // Import ESM module
3637 const esmPath = path . resolve ( __dirname , "../../dist/lib.js" ) ;
37- const esmModule = ( await import ( esmPath ) ) as Record < string , unknown > ;
38+ const esmFileURL = pathToFileURL ( esmPath ) . href ;
39+ const esmModule = ( await import ( esmFileURL ) ) as Record < string , unknown > ;
3840
3941 // Compare exports
4042 const cjsKeys = Object . keys ( cjsModule ) . sort ( ) ;
0 commit comments