question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enable PnP by default if within a PnP environment?

See original GitHub issue

This is a followup to #174. In this PR, we’ve implemented normalize-options.js as a way for third-party runtimes to hook into resolve by default and modify its default options.

It worked really well, and unlocked many packages - Babel being an important one. I just found out, however, that it doesn’t work with one particular project: Next.js. For some reason, Next precompiles resolve and thus causes normalize-options.js to disappear, leaving no chance to the hook to override it.

There are a few options to solve that on their side, but I wonder: could/should resolve improve its support? Since 2018 a lot of new projects have adopted PnP, including enhanced-resolve from Webpack. Coupled to the fact that:

  • This behaviour is in essence already enabled by default for everyone using PnP
  • It doesn’t affect at all people that don’t use PnP
  • The PnP API has been very stable for a while now
  • PnP will be the default in Yarn 2+

How would you feel about adding the PnP logic into resolve itself if process.versions.pnp is detected (we would still have forceNodeResolution to prevent it, just like it is at the moment)?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
arcaniscommented, Jan 3, 2020

I made a tentative PR: https://github.com/browserify/resolve/pull/205 - basically giving the hook the option to skip the path.join if it doesn’t apply to a package.

If possible at all, I would really appreciate if the change could be made in a semver-minor release. Lots of packages are depending on resolve, and that would help compatibility in one fell swoop.

1reaction
arcaniscommented, Nov 30, 2019

I’m a bit cautious doing this, as it’s generally quite intrusive and prone to break 🤔

I feel like the less we need to add a layer between Node and its users, the better I feel (for example that’s part of the reason why we use NODE_OPTIONS to inject the runtime instead of overriding child_process and worker_threads).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure PnP PowerShell
By default PnP PowerShell will report its usage anonymously to the PnP team. We collection information about the version of PnP PowerShell, the...
Read more >
Plug'n'Play | Yarn - Package Manager
In this install mode (the default starting from Yarn 2.0), Yarn generates a single .pnp.cjs file instead of the usual node_modules folder containing...
Read more >
Configure the PnP Settings on a Switch through the CLI - Cisco
Configure PNP Settings. Step 1. Log in to the switch console. The default username and password is cisco/cisco. If you have configured a...
Read more >
Introducing the PnP provisioning engine | Microsoft Learn
This article introduces the PnP provisioning engine, which was originally released in April 2015 within the [OfficeDev PnP](.
Read more >
How to Connect to SharePoint Online using PnP PowerShell?
PnP PowerShell internally uses the Client-Side Object model code for its operations. With PnP PowerShell, we can reduce the number of lines in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found