Set package versions to fixed values
Please consider setting package versions to fixed values instead of "compatible" ones. We wasted a lot of time yesterday trying to figure out why our setup broke. It turned out that angular2-template-loader came out with a bad patch.
This suggestion has some merit. I came to this project just yesterday and all I see are issues as it's not just template loader but Angular 2.4.5 > 2.4.6 breaking HMR as well. Not sure if overly pessimistic view but it seems that this setup has a chance to come down every time minor update to a dependency is made.
That said, it might be better to have tested fixed versions as a starting point, if someone wants bleeding-edge package updates it may be easily opted-in. I've had little luck trying to set fixed versions myself, removing just the ^ from all packages didn't work. /newbie 😢
I agree - these templates represent the file-> new experience and if depending on when you acquired them you get a random work/broken experience - thats not a great user experience
Could we fix with some kind of CI test when someone makes a change to package versions?
You're totally right that it's a poor experience when 3rd-party dependencies put breaking changes in minor point releases.
Unfortunately, pinning dependencies to exact versions isn't a great solution, because:
- Dependencies then very quickly get out of date. There are reasons why people publish patch releases to their packages, which includes bugfixes, possibly even for security issues. You wouldn't get those updates possibly for a very long time (if ever, since once your
package.jsonis generated, most developers will be cautious about changing it). In most cases, the updates are desirable, rather than problematic. - Pinning to specific dependencies in
package.jsonis not even sufficient, since dependencies themselves have dependencies (and so on), and those indirect dependencies would not be pinned any more than they are today. NPM does have a feature for pinning all chains of dependencies - i.e., "shrinkwrap" - but that would be an extreme solution that you typically won't find in any templates/starter kits/etc.
Having two third-party breaking changes within the space of a couple of days is very bad, but fortunately it's an extreme case and has rarely happened over the course of the year or so this project has been underway. I can't help but think this is just something that's going to require ongoing monitoring and maintenance.
I'll mark this as closed, since it's not something we'll take action on in the short term. But please feel free to continue discussing it here. I'd be especially interested to hear if someone has experience of what other mainstream templates/starter kits/etc (with nontrivial NPM dependency graphs) do to handle this. Thanks!
it seems that this setup has a chance to come down every time minor update to a dependency is made
That's true for this and most other project template systems that allow updates from package managers. Theoretically, the File->New ASP.NET projects could fail in the same way because they auto-grab latest NuGet packages (and the only reason you don't see them fail like that is because Microsoft is extremely cautious about taking third-party dependencies, which is not a luxury we have in the context of SPA technologies).
For what it's worth, I have to disagree on this one. I think shrinkwrapping is the way to go because having a slightly outdated setup that always works is better than having an updated setup that maybe works. One can always update the shrinkwrap every now and then (after verifying the build works).
You typically only use the template to generate the project one time. Once you generate the project, the fact that they are not set to specific versions in the template no longer comes into play. ;) Simply do a find/replace on the caret and remove it. ;)
Your solution doesn't work and, even if it did, it wouldn't address the issues raised on this thread (user experience and reliability vs using latest packages).
Removing the caret itself won't work, you'd have to delete node_modules completely, then npm i again to get that specific version.
It's definitely a problem with modular/library development within Node, but it depends project to project what someone wants to do whether it's pinning all of their dependencies or not. I'm not sure what the overall feeling is about that from the community.
The package itself has since been fixed, a breaking PR was introduced into 0.6.1 that caused the underlying issue unfortunately :(
The way I see it we could optimize for user experience (You run this generator and it will just work. You're free to update the packages and see if the latest versions work). Or we could optimize for having the latest "compatible" versions of packages (You run this generator and chances are it will work, but there is definitely a chance that it won't).
I argue for shrinkwrapping because even if you use the caret on package versions you still run the risk of using outdated versions. Many package authors are starting to use SemVer in its strictest form: If there's a breaking change (no matter how minor) then they bump the major version. There are a few packages in this setup that fall into this category right now.
So if you're going to use outdated packages, why not use ones that are definitely going to work? And again, the user is free to try to update the packages, knowing there's a chance it will break the build.