-
-
Notifications
You must be signed in to change notification settings - Fork 753
feat: Add pnp_manifest option to resolver
#12417
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rspack canceled.Built without sensitive environment variables
|
|
@smeng9 We should add |
|
@stormslowly Since rspack-resolver does not have a formal document, I have updated the document of README.md in rstackjs/rspack-resolver@f9e2fcf |
2c8abda to
6096b51
Compare
| builtin_modules: options.builtin_modules, | ||
| imports_fields, | ||
| enable_pnp: options.pnp.unwrap_or(false), | ||
| pnp_manifest: if options.pnp.unwrap_or(false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use options.pnp_manifest.map(PathBuf::from)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated to use options.pnp_manifest.map(PathBuf::from)
However I think providing the default value by calling pnp::find_closest_pnp_manifest_path if no pnp_manifest is provided in the options is still necessary. This ensures pnp global cache works out of the box without any additional configuration needed
crates/rspack_core/Cargo.toml
Outdated
| swc_experimental_ecma_ast = { workspace = true } | ||
| swc_experimental_ecma_parser = { workspace = true } | ||
| swc_experimental_ecma_semantic = { workspace = true } | ||
| pnp.workspace = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we need pnp::find_closest_pnp_manifest_path function, we need the pnp dependency
| if options.pnp.unwrap_or(false) { | ||
| std::env::current_dir() | ||
| .ok() | ||
| .and_then(|cwd| pnp::find_closest_pnp_manifest_path(&cwd)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed in the link provided (rstackjs/rspack-resolver#141 (comment)), we need to consider the implications of sticking to the current project PnP manifest. Doing so could potentially disrupt project references to other PnP-enabled projects.
In my opinion, if a user wants to utilize the global cache, they should explicitly configure their settings—in other words, stick to the manifest file.
However, if we config the manifest for uesrs, they may encounter difficulties when working with projects that reference other Yarn projects.
|
I am thinking that Yarn PnP's enableGlobalCache is enabled by default. https://yarnpkg.com/configuration/yarnrc#enableGlobalCache So the PnP manifest should support global cache by default.
But case 1, will be a breaking change for current PnP users. So what's your opinion @smeng9 |
|
Hi @stormslowly This merge request is a bug fix for incorrectly resolved In rspack-resolve https://github.com/rstackjs/rspack-resolver/blob/main/src/lib.rs#L899C19-L899C49, we are already resolving Even if we have a yarn PnP project listed as another yarn PnP project's dependency, when performing a yarn install, the dependent project will be installed to global cache first, which strips away its |
|
Let me clarify my explanation with the following example: GitHub Repository. Both the The
However, it fails when using the current Pull Request due to the configuration of the PnP manifest in the I hope this explanation is clearer. |
|
I see the problem. If this is considered a breaking change, we can push it to 2.0 However I still think if app/index.js uses ../lib/index.js directly by referencing a single file out of it's package scope, which has hidden imports of |
|
If we are setting up the package to include files from another package, we should do the following stormslowly/mult_yarn_pnp_manifest@master...smeng9:mult_yarn_pnp_manifest:master |
Summary
Fixes #10919
Related links
Merge rstackjs/rspack-resolver#141 first
Checklist