Skip to content

Commit

Permalink
Fully resolve module references for pnpm benefit
Browse files Browse the repository at this point in the history
There were two cases that were working only if the module was in the top
level node_modules.

There should never be a reason for typical userland tap programs to
have a direct dependency on `@tapjs/test` or any version of ts-node
unless they're using that themselves.

Fix: #974
  • Loading branch information
isaacs committed Nov 15, 2023
1 parent 788d93a commit 639f3f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/run/src/build.ts
Expand Up @@ -4,7 +4,10 @@ import { fileURLToPath } from 'node:url'
import { resolveImport } from 'resolve-import'
import { mainCommand } from './main-config.js'
const tmbin = fileURLToPath(
await resolveImport('@tapjs/test/generate-tap-test-class')
await resolveImport(
'@tapjs/test/generate-tap-test-class',
import.meta.url
)
)
const node = process.execPath

Expand Down
15 changes: 13 additions & 2 deletions src/test/scripts/build.mjs
Expand Up @@ -4,6 +4,7 @@ import { spawnSync } from 'node:child_process'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import Module from 'node:module'
import { resolveImport } from 'resolve-import'
const useImport = !!Module.register

const no = ['--no-warnings']
Expand All @@ -23,9 +24,19 @@ process.env.TS_NODE_PROJECT = tsconfig
// node version specific
/* c8 ignore start */
const tsNodeImport = useImport
? ['--import=@isaacs/ts-node-temp-fork-for-pr-2009/import']
? [
'--import=' +
(await resolveImport(
'@isaacs/ts-node-temp-fork-for-pr-2009/import',
import.meta.url
)),
]
: [
'--loader=@isaacs/ts-node-temp-fork-for-pr-2009/esm',
'--loader=' +
(await resolveImport(
'@isaacs/ts-node-temp-fork-for-pr-2009/esm',
import.meta.url
)),
'--no-warnings',
]
/* c8 ignore stop */
Expand Down

0 comments on commit 639f3f2

Please sign in to comment.