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

Basic PnP dependency resolution not working #1150

Closed
molst opened this issue Apr 2, 2020 · 4 comments
Closed

Basic PnP dependency resolution not working #1150

molst opened this issue Apr 2, 2020 · 4 comments
Labels
bug Something isn't working stale Issues that didn't get attention

Comments

@molst
Copy link

molst commented Apr 2, 2020

Hi,

Using this minimal library, the following three commands give the following error message.

Error: Cannot find package 'del' imported from C:\...\yarn2test\test.mjs

yarn node         --experimental-modules test.mjs
node              --experimental-modules test.mjs
node -r ./.pnp.js --experimental-modules test.mjs

This suggests that the PnP functionality in yarn is not activated. To verify this I need to do some debugging, or at least debug logging.

The stack trace tells that node uses some default resolver:

internal/modules/esm/default_resolve.js:82
  let url = moduleWrapResolve(specifier, parentURL);
            ^
Error: Cannot find package 'del' imported from C:\...\yarn2test\test.mjs
    at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:82:13)
    at Loader.resolve (internal/modules/esm/loader.js:73:33)
    at Loader.getModuleJob (internal/modules/esm/loader.js:147:40)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:41:40)
    at link (internal/modules/esm/module_job.js:40:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Unfortunately I've searched through my whole hard disk to find the default_resolve.js file with no luck and even looked thorugh the zip files. I've also looked in the zip packages in the cache and I haven't found any way to get a non-minified copy of yarn-berry.js. So, I feel quite crippled and have no other option than to beg for some help. I think yarn is improving the javascript dependency story quite a bit, so I really would like to have this working.

Cheers!

Environment:

  • OS: Windows 10
  • Node version: 12.13.0
  • Yarn version: berry
@molst molst added the bug Something isn't working label Apr 2, 2020
@arcanis
Copy link
Member

arcanis commented Apr 2, 2020

Hey! ESM modules go through a completely different codepath in Node (cjs / esm). The problem is that this codepath is still very new, and although modules have technically been marked stable the way to alter the resolution is still in heavy discussion (nodejs/modules#351).

There have been improvements lately with the new version of the loader API that could theoretically use the PnP resolver, but I haven't had the bandwidth to look into it yet (especially since I don't use native ESM myself atm). Help wanted!

Unfortunately I've searched through my whole hard disk to find the default_resolve.js file with no luck and even looked thorugh the zip files

You can't find it - the files in internal/ are Node-internal scripts that are bundled within the Node executable. You can read them on the Node repository, but they can't be edited without recompiling the binary.

@molst
Copy link
Author

molst commented Apr 2, 2020

Thanks @arcanis for all the info! Then at least I know what I should expect in the nearest future, and in my case I'll have to fall back to using node-modules for a while. FYI my use case is sharing libraries using ESM between client and server.

@yarnbot
Copy link
Collaborator

yarnbot commented Jun 9, 2020

Hi! 👋

This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).

Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolution faster). It helps us help you! 😃

If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label.

@yarnbot yarnbot added the stale Issues that didn't get attention label Jun 9, 2020
@paul-soporan
Copy link
Member

Tracked in #638.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale Issues that didn't get attention
Projects
None yet
Development

No branches or pull requests

4 participants