@@ -6,27 +6,31 @@ const typescriptPaths = require('../dist').default;
66
77const transform = ( path ) => path . replace ( / \. j s $ / i, '.cjs.js' ) ;
88
9+ const tsConfigPath = process . env . WO_BASEURL
10+ ? 'tsconfig-wo-baseurl.json'
11+ : 'tsconfig.json'
12+
913const plugin = typescriptPaths ( {
10- tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
14+ tsConfigPath : resolve ( __dirname , tsConfigPath ) ,
1115} ) ;
1216
1317const pluginNonAbs = typescriptPaths ( {
14- tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
18+ tsConfigPath : resolve ( __dirname , tsConfigPath ) ,
1519 absolute : false ,
1620} ) ;
1721
1822const pluginNonRelative = typescriptPaths ( {
19- tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
23+ tsConfigPath : resolve ( __dirname , tsConfigPath ) ,
2024 nonRelative : true ,
2125} ) ;
2226
2327const pluginTransform = typescriptPaths ( {
24- tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
28+ tsConfigPath : resolve ( __dirname , tsConfigPath ) ,
2529 transform,
2630} ) ;
2731
2832const pluginPreserveExtensions = typescriptPaths ( {
29- tsConfigPath : resolve ( __dirname , 'tsconfig.json' ) ,
33+ tsConfigPath : resolve ( __dirname , tsConfigPath ) ,
3034 preserveExtensions : true ,
3135} ) ;
3236
@@ -86,11 +90,19 @@ try {
8690 // skips non-relative paths unless enabled
8791 strictEqual ( plugin . resolveId ( 'foo/bar' , '' ) , null ) ;
8892
89- // resolves non-relative from baseUrl even if no path is matched
90- strictEqual (
91- pluginNonRelative . resolveId ( 'foo/bar' , '' ) ,
92- join ( __dirname , 'foo' , 'bar.js' ) ,
93- ) ;
93+ // resolves non-relative from baseUrl even if no path is matched, baseUrl is necessary in config
94+ if ( ! process . env . WO_BASEURL ) {
95+ strictEqual (
96+ pluginNonRelative . resolveId ( 'foo/bar' , '' ) ,
97+ join ( __dirname , 'foo' , 'bar.js' ) ,
98+ ) ;
99+ } else {
100+ console . log (
101+ 'SKIP test forced nonRelative paths:\n' ,
102+ '- Irrelevant since baseUrl is not provided in this case\n' ,
103+ '- See WO_BASEURL environment variable in the test code'
104+ )
105+ }
94106
95107 // resolves as a relative path with option `absolute: false`
96108 strictEqual (
0 commit comments