-
Notifications
You must be signed in to change notification settings - Fork 98
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
Draft: feat(yarn-plugin-external-workspaces): Add a yarn plugin for adding external workspace support #3504
base: main
Are you sure you want to change the base?
Conversation
// otherwise see if it is a js file that can be loaded | ||
if (!baseFinder) { | ||
const extension = path.extname(configPath).toLowerCase(); | ||
if (extension === ".js" || extension === ".cjs") { |
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.
In a later iteration, it would be great if we can also add support for .mjs
or ESM in general.
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.
We can discuss this more but the issue is that imports for esm are async, which has implications up the chain and the plugin resolver code expects synchronous execution.
* @param configPath the path to the config file | ||
* @returns a definition finder function if successful, or null if it is not specified | ||
*/ | ||
export function tryJsonLoad(configPath: string): DefinitionFinder | null { |
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.
It's not obvious to me why this needs to return a lambda. Can't it just return a readonly map?
"directory": "incubator/yarn-plugin-external-workspaces" | ||
}, | ||
"engines": { | ||
"node": ">=16.17" |
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.
(nit) NodeJs 16 is no longer supported. NodeJs 18 will go out of support in April 2025. Ideally this should be Node 20 or 22
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.
Imo, this is fine. This just requires the package to use Node 16 or greater. It only makes sense to put a higher requirement if we actually use features from later versions of Node.
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 was generated by the rnx-kit package creation code. We have some packages in the repo marked as node 16+ and others as 18+. We should probably be consistent and update the package generation with the new value.
…nd a shared package for the behavior
Description
Submitting this early for feedback. This still needs lots of testing before it is ready to be merged but I'm just sharing the files early.
This creates a yarn plugin where it adds a new protocol external: with a similar syntax to workspace: such that when the package is found locally it will treat it like a workspace (by rerouting to the portal: syntax) and when it does not exist it will be treated as npm: and downloaded like a normal package.
It is configurable by a JSON file, with the ability to embed it in a key in the file. The default being package.json/external-workspaces, such that these can be defined below the workspaces key in the package.json. It can also route to a .js or .cjs file such that custom code can be invoked when necessary.
I haven't added the range parsing, as such it treats everything like it is workspace:* syntax at the moment, there are some open questions as well. I also need to check the publishing workflow to ensure it transforms the syntax correctly, one thing at a time though.
Test plan