-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Switch to npm5 #29576
Switch to npm5 #29576
Conversation
@felixfbecker, thanks for your PR! By analyzing the history of the files in this pull request, we identified @joaomoreno and @bpasero to be potential reviewers. |
Install step on master: 350.53s Total build time on master: 21min 39s |
Awesome numbers. Is the idea that people stop using shrinkwrap altogether? Did you actually update to the latest versions of our runtime dependencies? That is something we wouldn't take very lightly as it's bitten us in the past - odd issues here and there. Can we somehow do this without actually updating our runtime dependencies versions? |
For projects, yes. shrinkwrap still serves a purpose for locking the dependency versions of published packages, e.g. if you install gulp and gulp had an npm-shrinkwrap.json, the dependency tree of gulp's dependencies would be locked. You generally don't want this. npm-shrinkwrap.json and package-lock.json have an identical schema, but the former is published to npm, the latter not. package-lock.json is the default for new projects. I did not update any versions - npm migrates the schema automatically, and I then renamed all the files. All dependencies should still be locked to the same version (you can see this if you look at cc38d99). Also, devDependencies are now included by default. |
What happens if we leave the shrinkwrap files in the repo as well? If we remove them we force everyone to update to npm@5 at once, which can be done, yet is not ideal. |
I wouldn't keep them both, because then we risk them getting out of sync. It also wouldn't be of any use because the schema was upgraded and is not backwards-compatible (i.e. npm5 can upgrade npm4 shrinkwraps, but npm4 can't read upgraded npm5 shrinkwraps/package-locks) |
Exactly, so it needs to be a coordinated event across the whole dev team, internal and external build definitions and documentation. |
yep, just like on a Node version update. |
I added a check to both npm.sh and npm.bat and tested on mac and Windows
|
44ba048
to
a6bfd13
Compare
@alexandrudima Pointed out another source of issues: our internal OSS tracking tool, which currently gets its input from |
@felixfbecker I'd put the npm checks in here instead: https://github.com/Microsoft/vscode/blob/master/build/npm/preinstall.js#L6 We use the |
Done. |
Depending on what properties it uses, it might not have to change at all |
Oh boy, shrinkwraps got updated in master... |
244c0ea
to
63141aa
Compare
Rebased and re-migrated all changed shrinkwrap files. |
@felixfbecker No worries about keeping this up to date with |
Okay, cool. My process was (with knowing that no new npm-shrinkwrap was added):
Because the rename is a separate commit this was easier than I thought. |
Spent the whole afternoon on this. It's not as trivial at it looks.
I'll pick it up tomorrow, but I might just trash this PR and start over. Sorry for that @felixfbecker. On the plus side: I've made all our TFS build agents dependent on NVM, so we can pick any node version during the build. This was crucial, in order to be able to build |
I think with shrinkwrap it only saved what you had installed, so if you run shrinkwrap on a mac, it would save fsevents, if you run it on a Windows machine, it would save windows-mutex - never optionalDependencies not installed. If you tried to install from a shrinkwrap that included platform-incompatible optionalDependencies, npm would error. I think npm 5 now saves all optional dependencies, but only installs those that can be installed. Another problem I saw on this branch is that there seems to be some manual modifications in the npm-shrinkwrap.json to replace transitive dependencies with a fork - this seems to fail for npm5 with an EINTEGRITY error because the forked version's hash doesn't match the hash in the shrinkwrap (just a theory, could be different issue). No problem if you start over, I'm happy if npm5 makes it into master in any way :) |
And as I suspected: We can't really take this right now since we have optional dependencies which are platform specific. We'd have constant changes in these files all the time. I see some activity going on in npm/npm#16839, which seems related, let's see if that fixes it. I've created #30134 so we remember to do this eventually. |
This should make installation time (and therefor builds) much faster and make lockfiles way more reliable, especially in regard to handling of optionalDependencies like fsevents.
I just ran
scripts/npm install
with npm5, which upgrades all the shrinkwrap files, then renamed then.Additionally updated npm version in Travis and adapted gulpfiles.
I recommend merging this without squashing so the renames are recorded and not a huge delete+add.