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

Import undefined for commonJS module #194

Closed
petermasking opened this issue Mar 4, 2023 · 1 comment · Fixed by #195
Closed

Import undefined for commonJS module #194

petermasking opened this issue Mar 4, 2023 · 1 comment · Fixed by #195
Assignees
Labels
bug Something isn't working runtime Improvements or additions to the runtime package

Comments

@petermasking
Copy link
Member

Describe the bug
Importing the default value of commonJS module like this:

import bcrypt from 'bcryptjs';

Results into an undefined for bcrypt.

Expected behavior
That the bcrypt values contains the library.

@petermasking petermasking added bug Something isn't working runtime Improvements or additions to the runtime package labels Mar 4, 2023
@petermasking petermasking self-assigned this Mar 4, 2023
@petermasking
Copy link
Member Author

I've been investigating this issue and found that the import tries to load the 'default' export instead of the 'bcrypt' export after the caching rewrite process. In the ESM system these are the same thing, but not in commonJS modules. They do not have a default value. To fix this we need to always use the name specified for default imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working runtime Improvements or additions to the runtime package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant