-
Notifications
You must be signed in to change notification settings - Fork 7
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
Require of jse-eval fails when build with typescript #57
Comments
@FrankVisuals - I'll try to look into this later tonight, but in the meantime, can you try with both 1.4.0 and 1.3.0? 1.3.0 only had a default export, not any named exports. 1.4.0 flipped the package.json file for the project from cjs to esm and added the named exports. |
using a default export causes the module build file to be used by typescript when it transpiles to cjs, which then doesn't work for mixing esm and cjs. Simply removing the default line resolves the issue. Fixes #57
🎉 This issue has been resolved in version 1.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@FrankVisuals - it looks like it was caused by the |
Thanks for the fast solution! I was just about to test it with 1.3 which forced me to use |
I have a typescript project where I import
jse-eval
- the typescript build works fine, but when executing the built files, it will fail with Error[ERR_REQUIRE_ESM]: Must use import to load ES Module
I've created a very lightweight repo to reproduce this issue: https://github.com/FrankVisuals/error-showcase
I did not find any way (changing to require instead of import, or import * as ...) to get it running when using a typescript build before.
The
Is built to
Based on the package.json I would expect
require("jse-eval")
to target the.cjs
version. The full error shown below, indicates the module is tried to be loaded:My node version is v14.19.0
My npm version is 8.5.5
MacOs 12.2.1
Is this an expected behaviour? Based on the docs it seems that this should actually work.
The text was updated successfully, but these errors were encountered: