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

version 4.6.0 gives SyntaxError: Cannot use import statement outside a module #83

Closed
meltalite opened this issue Apr 14, 2022 · 7 comments
Assignees
Labels

Comments

@meltalite
Copy link

Issue:
Our test in the CI suddenly failed today.

 /app/node_modules/jest-mock-axios/dist/index.js:22
    import { jest } from "@jest/globals";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

    > 1 | import mockAxios from 'jest-mock-axios';
        | ^
      2 | mockAxios.__defineGetter__('CancelToken', function() {
      3 |   return {
      4 |     source: () => {

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (src/__mocks__/axios.js:1:1)

Root cause:
in our package.json, we use ^4.5.0, so our CI picked up release 4.6.0 which enables experimental support for native ESM

@kingjan1999 kingjan1999 self-assigned this Apr 14, 2022
@kingjan1999
Copy link
Collaborator

Hi,

sorry for the inconvenience; I guess the experiment failed here. Is it okay for you to pin to 4.5.0 for the moment?

I'll have to figure out if there is a way to adequately support both ESM and CJS in one release (I thought the current way would do it...). Otherwise I'll probably push 4.6.1, rolling back the ESM changes and pushing 5.0.0 version instead (as initially planned).

@meltalite
Copy link
Author

I don't mind at all. But I think it's better to push 4.6.1 so no one else will accidentally get into the same trouble again.

@kingjan1999 kingjan1999 pinned this issue Apr 14, 2022
@bploetz
Copy link

bploetz commented Apr 14, 2022

We ran into this today as well. We had our dependency defined as ^4.3.0, and once we figured out what was going on, locking it down to ~4.3.0 fixed it for us.

Agreed that this should have been a major version bump to 5.0.0, and in the mean time a release of 4.6.1 that rolls it back sounds like the right thing to do. 👍

@kingjan1999
Copy link
Collaborator

Just published 4.6.1. Please check if this works for you

@meltalite
Copy link
Author

Checked, the issue no longer occurred in 4.6.1. ✅

ps: sorry for the delayed response due to the holiday

@marcoambrosini
Copy link

marcoambrosini commented May 16, 2022

Hi, I'm testing with 4.6.1 and the issue is still present for me

@judithrocketmakers
Copy link

Also still seeing this error with 4.6.1, sadly.

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

No branches or pull requests

5 participants