11import { createRequire } from "module" ;
22import path from "path" ;
3- import { fileURLToPath , pathToFileURL } from "url" ;
3+ import { fileURLToPath } from "url" ;
44import { describe , it , expect } from "vitest" ;
55
66const __filename = fileURLToPath ( import . meta. url ) ;
@@ -18,10 +18,7 @@ describe("Build Test", () => {
1818 } ) ;
1919
2020 it ( "should successfully import ESM module" , async ( ) => {
21- const esmPath = path . resolve ( __dirname , "../../dist/lib.js" ) ;
22- const esmFileURL = pathToFileURL ( esmPath ) . href ;
23-
24- const esmModule = ( await import ( esmFileURL ) ) as Record < string , unknown > ;
21+ const esmModule = ( await import ( "../../dist/lib.js" ) ) as Record < string , unknown > ;
2522
2623 expect ( esmModule ) . toBeDefined ( ) ;
2724 expect ( typeof esmModule ) . toBe ( "object" ) ;
@@ -34,9 +31,7 @@ describe("Build Test", () => {
3431 const cjsModule = require ( cjsPath ) as Record < string , unknown > ;
3532
3633 // Import ESM module
37- const esmPath = path . resolve ( __dirname , "../../dist/lib.js" ) ;
38- const esmFileURL = pathToFileURL ( esmPath ) . href ;
39- const esmModule = ( await import ( esmFileURL ) ) as Record < string , unknown > ;
34+ const esmModule = ( await import ( "../../dist/lib.js" ) ) as Record < string , unknown > ;
4035
4136 // Compare exports
4237 const cjsKeys = Object . keys ( cjsModule ) . sort ( ) ;
0 commit comments