swc-project / swc-project/swc-node
Cannot use import statement outside a module after upgrading @swc-node/jest
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 95
- Avg merge
- 14d 11h
- Merged PRs (30d)
- 1
Description
After upgrading @swc-node/jest from 1.5.5 to 1.6.2 I get next error while running jest tests.
/workspaces/app/__integration__/app.test.ts:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import _async_to_generator from "@swc/helpers/src/_async_to_generator.mjs";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1678:14)
at runMicrotasks (<anonymous>)
while having module: "esnext" in the tsconfig
It is probably related to https://github.com/swc-project/swc-node/issues/693
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure from integration/app.test.ts with @swc-node/jest 1.6.2 and inspect the project tsconfig, especially its module setting. Compare the Jest transformation behavior with version 1.5.5 and the related swc-node issue; done means the integration test runs without the module syntax error under the reported configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100