Repository navigation
Automatic hoisting of common dependencies to repo root - #36
Conversation
| PackageUtilities.filterPackages(packages, "").map((pkg) => pkg.name), | ||
| ["package-3", "package-4", "package-a-1", "package-a-2"] | ||
| ); | ||
| }); |
There was a problem hiding this comment.
This is an change in edge-case behavior due to the way filtration is factored to support hoisting as well as scope/ignore. Previously --scope= was an error. Now it's a noop.
roblg
left a comment
There was a problem hiding this comment.
LGTM. I'm not super-familiar with the code, but the big things seem to be there, and look reasonable (hoisting/semver matching/warn on differing versions/.bin hangling).
This is taken from the base commit on the "enhanced bootstrap" PR.
Easier on my old eyes while I'm trying to grok this. :)
This method was renamed while this change set was in flight.
Mostly just so I'm sure I understand it.
We'll need those to link binaries from the root.
Scoped packages weren't hoisted with `--hoist`.
If it's depended on by the root package.json and others don't match.
|
Thanks for looking at this @roblg. I've since pushed two small fixes for minor issues I discovered while playing around bootstrapping babel, but they're pretty trivial. The bigger news is hoisting makes bootstrap twice as fast for babel! 🚀 |
That's awesome! |
|
Just made it even faster! Starting the root install first since it's likely to take longest. Now babel bootstrap takes 12s with hoisting compared to 30s without on my laptop! |
These will be present when deps are already satisfied at the root.
|
For comparison: With |
|
This will be easier to see in ascii art form: |
|
Been using this with React Server for a couple of days locally. Do want. Going to merge this afternoon, barring objections. |
| import path from "path"; | ||
| import {sync as globSync} from "glob"; | ||
| import minimatch from "minimatch"; | ||
| import isArray from "isarray"; |
There was a problem hiding this comment.
why not util.isArray (node < 4), or Array.isArray (node >= 4)
There was a problem hiding this comment.
Oh nice, didn't know about util.isArray.
This is still easier, though... :D
|
|
||
| // Add this version if it's the first time we've seen it. | ||
| if (!dep.versions[version]) { | ||
| dep.versions [version] = 0; |
There was a problem hiding this comment.
this whitespace hurts my brain! 😝
| .map((pkgName) => ({pkg: this.packageGraph.get(pkgName).package, deps: leaves[pkgName]})) | ||
| .forEach(({pkg, deps}) => actions.push( | ||
| (cb) => NpmUtilities.installInDir(pkg.location, deps, (err) => { | ||
| this.progressBar.tick(pkg.name); |
There was a problem hiding this comment.
am i missing something, or is this tick not captured in the progress bar length specified below?
There was a problem hiding this comment.
The progress bar is just initialized with the number of actions we're going to run.
this.progressBar.init(actions.length);There's a vestigial comment down there, though. I'll clean that up.
|
|
||
| // Get the most common version. | ||
| const commonVersion = Object.keys(versions) | ||
| .reduce((a, b) => versions[a] > versions[b] ? a : b); |
There was a problem hiding this comment.
this is much more elegant than what i did. 👍
|
Thanks for looking at this. Bombs away! |
This adds a pair of options to govern installing some or all external dependencies at the repo root instead of distributed in package directories.
From the original proposal for this:
The options may be set on the command lined or in asini.json.
This addresses #14.