diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bbd9fc2..0f8923e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout the repository uses: actions/checkout@v4 - name: Install pnpm - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v3 with: version: 9 - name: Install Node.js diff --git a/src/req.js b/src/req.js index e7a56ef..bd7cb39 100644 --- a/src/req.js +++ b/src/req.js @@ -8,7 +8,7 @@ let tsx let jiti -let importError +let importError = [] /** * @param {string} name @@ -28,9 +28,11 @@ async function req(name, rootFile = __filename) { } if (tsx === undefined) { - tsx = await import('tsx/cjs/api').catch(error => { - importError = error - }) + try { + tsx = await import('tsx/cjs/api') + } catch (error) { + importError.push(error) + } } if (tsx) { @@ -39,12 +41,11 @@ async function req(name, rootFile = __filename) { } if (jiti === undefined) { - jiti = await import('jiti').then( - m => m.default, - error => { - importError = importError ?? error - } - ) + try { + jiti = (await import('jiti')).default + } catch (error) { + importError.push(error) + } } if (jiti) { @@ -52,7 +53,9 @@ async function req(name, rootFile = __filename) { } throw new Error( - `'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${importError.message}` + `'tsx' or 'jiti' is required for the TypeScript configuration files. Make sure it is installed\nError: ${importError + .map(error => error.message) + .join('\n')}` ) } diff --git a/tsconfig.json b/tsconfig.json index 33c587d..6a4ef44 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "Preserve", + "module": "node16", "esModuleInterop": true, "allowJs": true, "noEmit": true