-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(plugin): install monorepo sub-plugin deps when not hoisted #1007
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -573,6 +573,18 @@ export function validatePluginStructure(pluginDir: string): ValidationResult { | |||||||||||||||
| return { valid: errors.length === 0, errors }; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| /** Check whether a directory has its own production dependencies in package.json. */ | ||||||||||||||||
| function hasOwnDependencies(dir: string): boolean { | ||||||||||||||||
| const pkgPath = path.join(dir, 'package.json'); | ||||||||||||||||
| if (!fs.existsSync(pkgPath)) return false; | ||||||||||||||||
| try { | ||||||||||||||||
| const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')); | ||||||||||||||||
| return pkg.dependencies != null && Object.keys(pkg.dependencies).length > 0; | ||||||||||||||||
| } catch { | ||||||||||||||||
| return false; | ||||||||||||||||
|
Comment on lines
+583
to
+584
|
||||||||||||||||
| } catch { | |
| return false; | |
| } catch (err) { | |
| throw new PluginError( | |
| `Invalid package.json in ${dir}: ${getErrorMessage(err)}`, | |
| 'Fix the plugin package.json so dependencies can be determined and installed correctly.', | |
| ); |
Copilot
AI
Apr 13, 2026
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 will run npm install --omit=dev inside every sub-plugin that has a non-empty dependencies object. In large monorepos this can multiply install time and may repeatedly touch the workspace/root lockfile even when the root install already covers dependency resolution (e.g., npm workspaces/hoisting). Consider detecting a workspace/hoisting setup at the repo root and skipping per-sub-plugin installs in that case, or otherwise limiting redundant installs (e.g., only when the root has no workspaces and the sub-plugin lacks a usable node_modules).
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.
The "skips sub-plugins without own dependencies" test currently doesn't create a
package.jsoninsubDir, so it can pass because the file is missing rather than becausehasOwnDependenciescorrectly returns false for an existingpackage.jsonwith empty/missingdependencies. To cover the intended behavior, write a minimalpackage.jsonforsubDirthat has nodependencies(or an empty object) and assert that nonpm installruns insubDir.