JavaScript & TypeScript / Scenario
Unexpected Token 'export': A Dependency Declares War
The app builds, the tests explode inside node_modules, and four fixes are on the table with very different price tags. Choose like someone who understands the collision.
- Difficulty
- Hard
- Format
- Scenario
- Points
- 200
- Estimate
- 15 min
// MISSION BRIEF
Your Mission
A routine dependency bump upgraded an HTTP client to a version that ships ESM only. The application, bundled by Vite, works perfectly. The Jest suite now fails before a single test runs.
Read the failure, the Jest config, and the dependency's package.json. Explain the collision precisely, then pick the remediation that fits a 900-test suite with a deadline.
// FIRST CONTACT
Battle teaser
First artifact
CI failure (every suite that touches the client)
State the collision precisely:
- ANode 20 dropped support for the export keyword outside browsers
- BThe dependency ships only an ESM build ('type': 'module', import-only exports); Jest executes tests as CommonJS and, by default, transforms nothing under node_modules, so raw ESM syntax reaches the CJS runtime and dies at parse
- CThe package is missing its main field, which is a publishing bug to report upstream
- Dts-jest cannot compile JavaScript dependencies, only TypeScript ones
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
javascriptesmjestdependenciestooling