Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use import statement outside a module after upgrading @swc-node/jest #699

Open
meskill opened this issue Feb 24, 2023 · 5 comments
Open

Comments

@meskill
Copy link
Contributor

meskill commented Feb 24, 2023

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 #693

@gyz0072004
Copy link
Contributor

Same issue here. I see it's because of this commit: e353c1a, which overrides the externalHelpers to true for @swc-node/jest. @Brooooooklyn Is it possible to accept option for externalHelpers?

@eltonio450
Copy link

Hello

Did you find a workaround 🙏 ?

thank you!

@gyz0072004
Copy link
Contributor

Hello

Did you find a workaround 🙏 ?

thank you!

I didn't find a workaround with @swc-node/jest. However, when I turned to @swc/jest our application just worked without problem. You can have a try.

@theoephraim
Copy link

running into similar issues here. Can anyone explain the difference between @swc-node/jest and @swc/jest?

@theoephraim
Copy link

Also @gyz0072004 - do you have an example of your setup anywhere? Seems to be quite tricky to get everything (including setup / teardown files in TS) to play nicely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants