Skip to content

@swc-node/jest needs install @swc/helpers ? #683

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

Closed
sizuhiko opened this issue Jan 6, 2023 · 4 comments · Fixed by #685
Closed

@swc-node/jest needs install @swc/helpers ? #683

sizuhiko opened this issue Jan 6, 2023 · 4 comments · Fixed by #685

Comments

@sizuhiko
Copy link

sizuhiko commented Jan 6, 2023

Bump @swc-node/jest from 1.5.5 to 1.5.6, has some errors.

 FAIL  test/utils/cookie-utils.test.ts
  ● Test suite failed to run

    Cannot find module '@swc/helpers/lib/_interop_require_wildcard.js' from 'test/utils/cookie-utils.test.ts'

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:425:11)
      at Object.<anonymous> (test/utils/cookie-utils.test.ts:14:33)

...

others...

    Cannot find module '@swc/helpers/lib/_interop_require_default.js' from 'src/domain/schema/permission-response-schema.ts'

etc...

I try npm i -D @swc/helpers, then re-run npm t is successfully.

I think better include @swc/helpers to peerDependencies.

@stefee
Copy link
Contributor

stefee commented Jan 6, 2023

I noticed this as well. It would be best to add as a dependency or peer dependency.

jrolfs added a commit to hoverinc/hover-javascript that referenced this issue Jan 10, 2023
jrolfs added a commit to hoverinc/hover-javascript that referenced this issue Jan 18, 2023
jrolfs added a commit to hoverinc/hover-javascript that referenced this issue Jan 18, 2023
@gyz0072004
Copy link
Contributor

Same issue here.

@gyz0072004
Copy link
Contributor

Meanwhile, as @swc/helpers is a pure esm module, it requires jest to be configured as esm enabled.

@jrolfs
Copy link
Contributor

jrolfs commented Feb 2, 2023

I ran into this as well (because of the pure ESM bit). It's technically an @swc/core thing, but @swc-node/jest explicitly enables externalHelpers for some reason:

externalHelpers: jest ? true : false,

To inline the helpers, you can pass the externalHelpers option via the swc configuration section:

module.exports = {
  transform: {
    '^.+\\.(t|j)sx?$': [
      '@swc-node/jest',
      { swc: { jsc: { externalHelpers: false } } }
    ]
  }
}

Unfortunately, passing any of the swc options clobbers everything that @swc-node/jest configures automatically for us (including paths aliases), which kind of defeats the purpose of it altogether. I'm planning on opening a pull request to merge the swc options instead.

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

Successfully merging a pull request may close this issue.

4 participants