-
Notifications
You must be signed in to change notification settings - Fork 42
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
Invalid exports field in the package.json #770
Comments
Closed
Should be fixed once #802 is done |
dohaki
added a commit
to bosonprotocol/chat-sdk
that referenced
this issue
Aug 2, 2022
When running the test with `jest`, it errored with ``` Cannot find module 'js-waku' from 'node_modules/@xmtp/xmtp-js/dist/cjs/src/utils.js' ``` The problem seems to be this issue waku-org/js-waku#770. Until this is resolved, we use a local patch as this only occurs when running tests.
dohaki
added a commit
to bosonprotocol/chat-sdk
that referenced
this issue
Aug 2, 2022
When running the test with `jest`, it errored with ``` Cannot find module 'js-waku' from 'node_modules/@xmtp/xmtp-js/dist/cjs/src/utils.js' ``` The problem seems to be this issue waku-org/js-waku#770. Until this is resolved, we use a local patch as this only occurs when running tests.
21 tasks
dennisfurrer
added a commit
to bosonprotocol/chat-sdk
that referenced
this issue
Aug 3, 2022
* Revert "feat: remove all tests related files (#2)" This reverts commit 7cb60d8. * build: add patch for js-waku not found (#7) When running the test with `jest`, it errored with ``` Cannot find module 'js-waku' from 'node_modules/@xmtp/xmtp-js/dist/cjs/src/utils.js' ``` The problem seems to be this issue waku-org/js-waku#770. Until this is resolved, we use a local patch as this only occurs when running tests. * Add unit and integration tests * Implement review remarks Co-authored-by: Dong-Ha Kim <[email protected]> Co-authored-by: Dennis Furrer <[email protected]>
Fixed in 0.25.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a bug report.
Problem
We are using jest for running tests on the Status Web. The ecosystem is still in the early adoption of
exports
field, but Jest recently added supported to thejest-resolve
. The tests were failing on the error messageCannot find module 'js-waku' from <FILE_NAME>
. It took me a while, but I found the culprit.#621 introduced invalid
exports
field definition to thepackage.json
. The main issue is that import condition is not pointing to a valid file that can be loaded viaimport
orimport()
(because it is a CommonJS build).Proposed Solutions
After reading Node.js Packages documentation and Webpack Package Exports article, I believe the correct configuration is the following:
import
condition pointing to ESM buildrequire
condition pointing to CommonJS builddefault
condition is a generic fallback that always matches and should be lastUnless you have environment-specific code, it is not necessary to use the
node
condition. However, it seems to be a good practice to be explicit about it.The text was updated successfully, but these errors were encountered: