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

Fix importing in CJS nodejs by adding conditional export #303

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

davidyuk
Copy link
Member

@davidyuk davidyuk commented Dec 7, 2024

This PR is supported by the Æternity Foundation

I discovered that the recent calldata package can't be imported into a CJS file in nodejs.

// test.cjs
const { Encoder } = require('@aeternity/aepp-calldata');

console.log('Encoder', Encoder);

fails with

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /.../test-aeproject-2/node_modules/@aeternity/aepp-calldata/package.json

using nodejs@20.18 and @aeternity/aepp-calldata@1.9.0. Looks like "type": "module", in package.json we added recently enabled the usage of exports instead main in this case 👉 👈

@davidyuk davidyuk requested a review from dincho December 7, 2024 15:44
@dincho dincho merged commit 5e5bd28 into master Dec 9, 2024
2 checks passed
@dincho dincho deleted the fix-cjs-node branch December 9, 2024 09:20
@dincho dincho added the bug Something isn't working label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants