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

incompatible with yarn2 PnP #263

Closed
cspotcode opened this issue Dec 9, 2020 · 1 comment · Fixed by #265
Closed

incompatible with yarn2 PnP #263

cspotcode opened this issue Dec 9, 2020 · 1 comment · Fixed by #265
Assignees
Labels
bug Something isn't working

Comments

@cspotcode
Copy link

In yarn2, any module you attempt to require() must be declared as a dependency in your own package.json. This means when @node-rs/helper attempts to, for example, require('@swc/core-linux'), it fails, because @swc/core-linux is not a dependency of @node-rs/helper

Fortunately, I think the solution is simple. @node-rs/helper needs to accept the caller's require function as an argument. Then when trying to require modules, it will use the caller's require, which is able to resolve the caller's dependencies. This is what we want, since we want to be sure that the modules we load match the versions that the caller wants to use.

For backwards compatibility, this can be optional, but it will probably cause issues with yarn 2 until the callers are updated to pass in a require function.

@cspotcode
Copy link
Author

Here is where I'm encountering this failure:
@swc/core is calling loadBinding:
https://github.com/swc-project/swc/blob/master/node-swc/src/index.ts#L14

The dependencies are declared for @swc/core, so they can be require()d by @swc/core but not by @node-rs/helper
https://github.com/swc-project/swc/blob/master/package.json#L80-L85

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 a pull request may close this issue.

2 participants