@@ -6,13 +6,24 @@ const typescriptPaths = require('../dist').default;
6
6
7
7
const transform = ( path ) => path . replace ( / \. j s $ / i, '.cjs.js' ) ;
8
8
9
- const plugin = typescriptPaths ( { tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) } ) ;
9
+ const plugin = typescriptPaths ( {
10
+ tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
11
+ } ) ;
10
12
11
- const pluginNonAbs = typescriptPaths ( { tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) , absolute : false } ) ;
13
+ const pluginNonAbs = typescriptPaths ( {
14
+ tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
15
+ absolute : false ,
16
+ } ) ;
12
17
13
- const pluginNonRelative = typescriptPaths ( { tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) , nonRelative : true } ) ;
18
+ const pluginNonRelative = typescriptPaths ( {
19
+ tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
20
+ nonRelative : true ,
21
+ } ) ;
14
22
15
- const pluginTransform = typescriptPaths ( { tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) , transform } ) ;
23
+ const pluginTransform = typescriptPaths ( {
24
+ tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
25
+ transform,
26
+ } ) ;
16
27
17
28
const pluginPreserveExtensions = typescriptPaths ( {
18
29
tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
@@ -30,39 +41,72 @@ try {
30
41
strictEqual ( plugin . resolveId ( '\0@foobar' , '' ) , null ) ;
31
42
32
43
// resolves with non-wildcard paths
33
- strictEqual ( plugin . resolveId ( '@foobar' , '' ) , join ( __dirname , 'foo' , 'bar.js' ) ) ;
34
- strictEqual ( plugin . resolveId ( '@foobar-react' , '' ) , join ( __dirname , 'foo' , 'bar-react.js' ) ) ;
44
+ strictEqual (
45
+ plugin . resolveId ( '@foobar' , '' ) ,
46
+ join ( __dirname , 'foo' , 'bar.js' ) ,
47
+ ) ;
48
+ strictEqual (
49
+ plugin . resolveId ( '@foobar-react' , '' ) ,
50
+ join ( __dirname , 'foo' , 'bar-react.js' ) ,
51
+ ) ;
35
52
36
53
// resolves with wildcard paths
37
- strictEqual ( plugin . resolveId ( '@bar/foo' , '' ) , join ( __dirname , 'bar' , 'foo.js' ) ) ;
54
+ strictEqual (
55
+ plugin . resolveId ( '@bar/foo' , '' ) ,
56
+ join ( __dirname , 'bar' , 'foo.js' ) ,
57
+ ) ;
38
58
39
59
// resolves from a directory with index file
40
60
strictEqual ( plugin . resolveId ( '@js' , '' ) , join ( __dirname , 'js' , 'index.js' ) ) ;
41
61
42
62
// resolves without an `@` prefix
43
- strictEqual ( plugin . resolveId ( 'bar/foo' , '' ) , join ( __dirname , 'bar' , 'foo.js' ) ) ;
63
+ strictEqual (
64
+ plugin . resolveId ( 'bar/foo' , '' ) ,
65
+ join ( __dirname , 'bar' , 'foo.js' ) ,
66
+ ) ;
44
67
45
68
// resolves with a different importer
46
- strictEqual ( plugin . resolveId ( 'bar/foo' , join ( __dirname , 'foo' , 'bar.ts' ) ) , join ( __dirname , 'bar' , 'foo.js' ) ) ;
69
+ strictEqual (
70
+ plugin . resolveId ( 'bar/foo' , join ( __dirname , 'foo' , 'bar.ts' ) ) ,
71
+ join ( __dirname , 'bar' , 'foo.js' ) ,
72
+ ) ;
47
73
48
74
// doesn't accidentally resolve relative paths that also have an alias
49
- strictEqual ( plugin . resolveId ( '../bar/foo' , join ( __dirname , 'foo' , 'bar.ts' ) ) , null ) ;
75
+ strictEqual (
76
+ plugin . resolveId ( '../bar/foo' , join ( __dirname , 'foo' , 'bar.ts' ) ) ,
77
+ null ,
78
+ ) ;
50
79
51
80
// skips non-relative paths unless enabled
52
81
strictEqual ( plugin . resolveId ( 'foo/bar' , '' ) , null ) ;
53
82
54
83
// resolves non-relative from baseUrl even if no path is matched
55
- strictEqual ( pluginNonRelative . resolveId ( 'foo/bar' , '' ) , join ( __dirname , 'foo' , 'bar.js' ) ) ;
84
+ strictEqual (
85
+ pluginNonRelative . resolveId ( 'foo/bar' , '' ) ,
86
+ join ( __dirname , 'foo' , 'bar.js' ) ,
87
+ ) ;
56
88
57
89
// resolves as a relative path with option `absolute: false`
58
- strictEqual ( pluginNonAbs . resolveId ( '@foobar' , '' ) , join ( 'test' , 'foo' , 'bar.js' ) ) ;
90
+ strictEqual (
91
+ pluginNonAbs . resolveId ( '@foobar' , '' ) ,
92
+ join ( 'test' , 'foo' , 'bar.js' ) ,
93
+ ) ;
59
94
60
95
// applies function from `transform` option
61
- strictEqual ( pluginTransform . resolveId ( '@foobar' , '' ) , join ( __dirname , 'foo' , 'bar.cjs.js' ) ) ;
96
+ strictEqual (
97
+ pluginTransform . resolveId ( '@foobar' , '' ) ,
98
+ join ( __dirname , 'foo' , 'bar.cjs.js' ) ,
99
+ ) ;
62
100
63
101
// resolves including the file extension with option `preserveExtensions: true`
64
- strictEqual ( pluginPreserveExtensions . resolveId ( '@foobar' , '' ) , join ( __dirname , 'foo' , 'bar.ts' ) ) ;
65
- strictEqual ( pluginPreserveExtensions . resolveId ( '@foobar-react' , '' ) , join ( __dirname , 'foo' , 'bar-react.tsx' ) ) ;
102
+ strictEqual (
103
+ pluginPreserveExtensions . resolveId ( '@foobar' , '' ) ,
104
+ join ( __dirname , 'foo' , 'bar.ts' ) ,
105
+ ) ;
106
+ strictEqual (
107
+ pluginPreserveExtensions . resolveId ( '@foobar-react' , '' ) ,
108
+ join ( __dirname , 'foo' , 'bar-react.tsx' ) ,
109
+ ) ;
66
110
67
111
console . log ( 'PASSED' ) ;
68
112
} catch ( error ) {
0 commit comments