@@ -6,13 +6,24 @@ const typescriptPaths = require('../dist').default;
66
77const transform = ( path ) => path . replace ( / \. j s $ / i, '.cjs.js' ) ;
88
9- const plugin = typescriptPaths ( { tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) } ) ;
9+ const plugin = typescriptPaths ( {
10+ tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
11+ } ) ;
1012
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+ } ) ;
1217
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+ } ) ;
1422
15- const pluginTransform = typescriptPaths ( { tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) , transform } ) ;
23+ const pluginTransform = typescriptPaths ( {
24+ tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
25+ transform,
26+ } ) ;
1627
1728const pluginPreserveExtensions = typescriptPaths ( {
1829 tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
@@ -30,39 +41,72 @@ try {
3041 strictEqual ( plugin . resolveId ( '\0@foobar' , '' ) , null ) ;
3142
3243 // 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+ ) ;
3552
3653 // 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+ ) ;
3858
3959 // resolves from a directory with index file
4060 strictEqual ( plugin . resolveId ( '@js' , '' ) , join ( __dirname , 'js' , 'index.js' ) ) ;
4161
4262 // 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+ ) ;
4467
4568 // 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+ ) ;
4773
4874 // 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+ ) ;
5079
5180 // skips non-relative paths unless enabled
5281 strictEqual ( plugin . resolveId ( 'foo/bar' , '' ) , null ) ;
5382
5483 // 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+ ) ;
5688
5789 // 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+ ) ;
5994
6095 // 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+ ) ;
62100
63101 // 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+ ) ;
66110
67111 console . log ( 'PASSED' ) ;
68112} catch ( error ) {
0 commit comments