Repository navigation
Commit 1472f3e
committed
test: cover ESM-syntax dependency with omitted "type" field
## Problem
Issue [#761](#761) reported
that importing a dependency that ships ESM via `exports.import` but
omits a `"type"` field surfaced as `SyntaxError: ... does not provide an
export named '...'`. The bug landed in 4.21.0 and was fixed implicitly
by the 4.21.1 sync-hook refactor: tsx still classifies the dependency as
CJS, but Node's default-on syntax detection (>= 20.19.0 / >= 22.7.0)
re-classifies the output through CJS<->ESM interop and recovers the
named export. There is no existing test that pins this behavior, so a
future refactor of the classifier or hook layout could silently regress
it.
## Changes
- Adds one version-sensitive regression test gated on `requireEsm`,
mirroring the reporter's shape: an ESM-typed entry that named-imports
from `module-a`, where `module-a/package.json` has `exports.import` but
no `"type"`, and `index.js` uses ESM syntax.
- Asserts `exitCode === 0` and `stdout === 'hello world from esm'`, so a
reintroduction (the dependency classified as CJS with named exports
dropped) fails loudly on the supported Node matrix.1 parent 1ce8463 commit 1472f3e
1 file changed
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
236 | 269 | | |
237 | 270 | | |
238 | 271 | | |
| |||
0 commit comments