1
1
import { createRequire } from "module" ;
2
2
import path from "path" ;
3
- import { fileURLToPath , pathToFileURL } from "url" ;
3
+ import { fileURLToPath } from "url" ;
4
4
import { describe , it , expect } from "vitest" ;
5
5
6
6
const __filename = fileURLToPath ( import . meta. url ) ;
@@ -18,10 +18,7 @@ describe("Build Test", () => {
18
18
} ) ;
19
19
20
20
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 > ;
25
22
26
23
expect ( esmModule ) . toBeDefined ( ) ;
27
24
expect ( typeof esmModule ) . toBe ( "object" ) ;
@@ -34,9 +31,7 @@ describe("Build Test", () => {
34
31
const cjsModule = require ( cjsPath ) as Record < string , unknown > ;
35
32
36
33
// 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 > ;
40
35
41
36
// Compare exports
42
37
const cjsKeys = Object . keys ( cjsModule ) . sort ( ) ;
0 commit comments