File tree 2 files changed +19
-2
lines changed
vite-plugin-tsconfig-paths 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { createRequire } from "module"
2
+ import path from "node:path"
3
+ import { fileURLToPath , pathToFileURL } from "node:url"
4
+
5
+ function getPathURL ( basename ) {
6
+ return pathToFileURL (
7
+ path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , basename ) ,
8
+ )
9
+ }
2
10
3
11
test ( "load CommonJS module" , ( ) => {
4
- const require = createRequire ( import . meta . url )
12
+ const require = createRequire ( getPathURL ( "index.js" ) )
5
13
const fn = require ( "." )
6
14
expect ( fn ) . toHaveProperty ( "name" , "TsPathsResolvePlugin" )
15
+ expect ( fn [ "default" ] ) . toHaveProperty ( "name" , "TsPathsResolvePlugin" )
7
16
} )
8
17
9
18
test ( "load ES module" , async ( ) => {
Original file line number Diff line number Diff line change 1
1
import { createRequire } from "module"
2
+ import path from "node:path"
3
+ import { fileURLToPath , pathToFileURL } from "node:url"
2
4
5
+ function getPathURL ( basename ) {
6
+ return pathToFileURL (
7
+ path . join ( path . dirname ( fileURLToPath ( import . meta. url ) ) , basename ) ,
8
+ )
9
+ }
3
10
test ( "load CommonJS module" , ( ) => {
4
- const require = createRequire ( import . meta . url )
11
+ const require = createRequire ( getPathURL ( "index.js" ) )
5
12
const fn = require ( "." )
6
13
expect ( fn ) . toHaveProperty ( "name" , "tsConfigPaths" )
14
+ expect ( fn [ "default" ] ) . toHaveProperty ( "name" , "tsConfigPaths" )
7
15
} )
8
16
9
17
test ( "load ES module" , async ( ) => {
You can’t perform that action at this time.
0 commit comments