File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,11 @@ const { pathToFileURL } = require('node:url')
44
55const TS_EXT_RE = / \. [ m c ] ? t s $ /
66
7- /** @type {import('tsx/cjs/api') | void } */
8- let tsx ;
7+ let tsx
98
10- /** @type {import('jiti').default | void } */
119let jiti
1210
13- /** @type {Error } */
14- let importError ;
11+ let importError
1512
1613/**
1714 * @param {string } name
@@ -31,27 +28,32 @@ async function req(name, rootFile = __filename) {
3128 }
3229
3330 if ( tsx === undefined ) {
34- tsx = await import ( 'tsx/cjs/api' ) . catch ( ( error ) => {
35- importError = error ;
36- } )
31+ tsx = await import ( 'tsx/cjs/api' ) . catch ( error => {
32+ importError = error
33+ } )
3734 }
3835
3936 if ( tsx ) {
4037 let loaded = tsx . require ( name , rootFile )
41- return ( loaded && '__esModule' in loaded ) ? loaded . default : loaded ;
38+ return loaded && '__esModule' in loaded ? loaded . default : loaded
4239 }
4340
4441 if ( jiti === undefined ) {
45- jiti = await import ( 'jiti' ) . then ( m => m . default , ( error ) => {
46- importError = importError ?? error ;
47- } )
42+ jiti = await import ( 'jiti' ) . then (
43+ m => m . default ,
44+ error => {
45+ importError = importError ?? error
46+ }
47+ )
4848 }
4949
5050 if ( jiti ) {
5151 return jiti ( rootFile , { interopDefault : true } ) ( name )
5252 }
5353
54- throw new Error ( `'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${ importError . message } ` ) ;
54+ throw new Error (
55+ `'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${ importError . message } `
56+ )
5557}
5658
5759module . exports = req
You can’t perform that action at this time.
0 commit comments