fix(config): extract package name from node_modules file:// URLs in getPluginName#17718
fix(config): extract package name from node_modules file:// URLs in getPluginName#17718yufeikang wants to merge 1 commit intoanomalyco:devfrom
Conversation
…etPluginName getPluginName returned the bare filename (e.g. 'index') for file:// URLs resolved from node_modules, causing deduplicatePlugins to treat unrelated plugins with index.js entry points as identical and silently drop all but one. Now detects '/node_modules/' in the path and extracts the npm package name (including scoped packages) instead of the filename.
|
The following comment was made by an LLM, it may be inaccurate: I found several related PRs addressing similar issues with plugin deduplication and file:// URL handling: Potential Related/Duplicate PRs:
These PRs appear to be addressing the same or very similar issues with plugin deduplication when resolving file:// URLs in node_modules. Check if any of these were previously closed or merged without fully resolving the issue (issue #17716). |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #17716
Type of change
What does this PR do?
getPluginNamereturnspath.parse(url.pathname).nameforfile://URLs, which yields"index"for any plugin whose entry point isindex.js/index.ts(the vast majority of npm packages). Whenload()resolves two npm plugins tofile://paths viaimport.meta.resolve,deduplicatePluginssees them both as"index"and silently drops one.This fix detects
/node_modules/in the file path and extracts the actual npm package name (including scoped packages) instead of the bare filename.How did you verify your code works?
getPluginNamewithnode_modulespaths (unscoped and scoped packages)deduplicatePluginsconfirming distinctnode_modules/*/index.jsentries are no longer treated as duplicatesbun test test/config/config.test.ts -t "getPluginName|deduplicatePlugins"(10 pass, 0 fail)oh-my-opencodewas being dropped due to name collision withopencode-openai-codex-auth(both resolved to"index")Screenshots / recordings
N/A - no UI change.
Checklist