You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been working on a library which wraps rollup + rollup-plugin-ts and exports a build function. I want to run the rollup build within Jest so that I can test it.
ReferenceError: The following babel dependencies could not be found within your node_modules folder: "@babel/core", "@babel/runtime", "@babel/plugin-transform-runtime", and "@babel/preset-env". Make sure to install them if you want to use babel for transpilation
Issue detail
It looks like there are two issues at play here. Firstly, the error message thrown here is overriding the actual import error message and therefore making it difficult to debug the issue. I would suggest also logging the error contained in core.
The real error is Error: You need to run with a version of node that supports ES Modules in the VM API. which is Jest telling us that if we want to use the import statement, we need to enable the experimental ES module support.
So this gets us to the crux of the issue, the CJS bundle of this package contains the import statement which Jest doesn't like.
Hey there. Thanks for the bug report! You're right that the dynamic import expression left in the CommonJS bundle is definitely not intentional on my part. After investigating a little, it seems to be caused by a changed default setting in Rollup v3. I've made sure to negate this flag such that the CommonJS bundle is, well, just that!
tsc
(if applicable):Reproduction
I've been working on a library which wraps rollup + rollup-plugin-ts and exports a build function. I want to run the rollup build within Jest so that I can test it.
Example project: https://github.com/georgesmith46/rollup-plugin-ts-test
Run
npm i && npx jest
Expected Behavior
The test should pass.
Actual Behavior
The following error is thrown:
Issue detail
It looks like there are two issues at play here. Firstly, the error message thrown here is overriding the actual import error message and therefore making it difficult to debug the issue. I would suggest also logging the error contained in
core
.The real error is
Error: You need to run with a version of node that supports ES Modules in the VM API.
which is Jest telling us that if we want to use theimport
statement, we need to enable the experimental ES module support.So this gets us to the crux of the issue, the CJS bundle of this package contains the
import
statement which Jest doesn't like.Let me know if this is actually an issue with Jest/Babel and I can raise it with them instead 👍
The text was updated successfully, but these errors were encountered: