-
Notifications
You must be signed in to change notification settings - Fork 18
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
Node 16.12+ breaks esmock #16
Comments
@mroderick thanks for messaging me here. I'll take a look this evening to try resolving this. |
The mac+node issue described here affects me (though they are discussing a different version) https://stackoverflow.com/questions/69452504/zlib-error-when-attempting-to-run-npm-install-or-yarn#answer-69743293 I'll need to resolve environment issues before I can look into this |
Two changes fix this package for the latest versions of node,
Here's what I propose,
Maybe "getSource" should be kept rather than removed, I'm not sure. @mroderick do you have any input? cc @Swivelgames feel free to give your opinion or ignore as well. |
the PR auto-closed this ticket... |
its published as version 0.4.2 https://www.npmjs.com/package/esmock feel free to re-open this issue @mroderick I didn't intend close the issue but wrote 'closes #16' in the PR description and github closed it. Anyway, I think its resolved. |
With version esmock@1.0.0 on 16.13.0 you get this warning: |
@maherma-adg do you recommend a way to resolve this? I searched for a way to conditionally export 'getSource' if node version is less than 16.12, but node forces the file to declare exports statically. what do you think of think of this idea... two module loaders, one for node v12-v16.11 and another for node v16.13+ node v12-v16.11 mocha --loader=esmock/loader.getSource.mjs node v16.12+ mocha --loader=esmock I'm not exactly sure if it will work, but I think it could work. |
I would prefer if "--loader=esmock" could be used always but how does one make that load a file that only exports "getSource" for node v12-v16.11? |
@maherma-adg I found a way to make the warning go away #19 |
@maherma-adg try the newest version |
I can confirm that the issue has been resolved 👍 |
It's works with ava, but I can't make it work with jest, anyone can? |
@maherma-adg I haven't tried it with jest, but doesn't jest process everything through a transpiler? Maybe that's why it doesn't work... maybe its transforming the sources into cjs or something similar |
As far as I know, jest only transpile when needed ( and you must configure transpiler ) for TS, Vue, JSX, etc. I'll try to dig deeper. UPDATE: My mistake, reading more into doc, I see automatic transform through babel is done for JS files. |
@maherma-adg https://jestjs.io/docs/ecmascript-modules try disabling transformations or configuring them to produce esm |
How can I set the loader for jest on esm? |
@OlaoluwaM if you make a PR with a sample basic jest test in it, I can try and make things work with that |
When upgrading to latest node, we're seeing errors with using
esmock
.With some investigation, it looks like
16.12
is the version that brokeesmock
.Node 16.12 CHANGELOG
How to reproduce
nvm use 16.11
npm ci
npm test
nvm use 16.12
npm ci
npm test
The text was updated successfully, but these errors were encountered: