PatrickJS-starter icon indicating copy to clipboard operation
PatrickJS-starter copied to clipboard

[Feature] 💥 Upgrade to webpack 4 🎉👍

Open almothafar opened this issue 8 years ago • 32 comments

  • I'm submitting a ... [ ] bug report [X] feature request [ ] question about the decisions made in the repository

  • Do you want to request a feature or report a bug? Feature: Upgrade to webpack 4

  • What is the current behavior? Currently, it is Webpack 3

  • What is the expected behavior? Use Webpack 4 as it contains big improvements

  • What is the motivation / use case for changing the behavior? As you can see the big features and changes in release notes: https://github.com/webpack/webpack/releases/tag/v4.0.0

🎉 💃

almothafar avatar Feb 25 '18 12:02 almothafar

Looks like will have to wait until html-webpack-plugin is upgraded. Might have to upgrade some others as well, but this one is crucial.

lanovoy avatar Feb 26 '18 12:02 lanovoy

https://github.com/jantimon/html-webpack-plugin/issues/860

Looks like they are already working on it. Maybe you can test further with the alternative: npm install -D webpack-contrib/html-webpack-plugin

Uter1007 avatar Feb 26 '18 12:02 Uter1007

It fails to install for me. Runs some specs and throws lots of exceptions. May be because we're using corporate npm registry and it doesn't have an access to webpack-contrib/ .

lanovoy avatar Feb 26 '18 13:02 lanovoy

There are a couple of packages which needs patches. https://github.com/szrenwei/inline-manifest-webpack-plugin/issues/10 and https://github.com/numical/script-ext-html-webpack-plugin/issues/41. Patches are obvious and I used patch-package for now.

sherlock1982 avatar Mar 02 '18 12:03 sherlock1982

FYI, Angular CLI (next beta) has been updated for webpack 4.0

lanovoy avatar Mar 06 '18 10:03 lanovoy

@sherlock1982 we can use webpack-inline-manifest-plugin instead of inline-manifest-webpack-plugin And script-ext-html-webpack-plugin version 2 is supporting webpack 4

almothafar avatar Mar 15 '18 10:03 almothafar

I did a quick and dirty upgrade to the latest version of webpack (4.1.1). It's working, the build is much faster, but unfortunately I had to disable html-elements-plugin which exists as part of this repo (angular-starter\config\html-elements-plugin\index.js) since it's not compatible and I'm lacking both knowledge and time to upgrade it. My code changes are uploaded into the branch >> here <<. For now I'm not going to create PR for it. If someone is willing to look into it, please feel free.

lanovoy avatar Mar 16 '18 14:03 lanovoy

@lanovoy why you removed the CommonsChunkPlugin? https://github.com/gdi2290/angular-starter/compare/feature/migrate-to-webpack4#diff-f737fedb5357468044db2dbe98eb0218L189

Is there any reason? I think chunks are helpful, isn't?

for html-elements-plugin I think it can be a PR for it, sounds the Author is active so we can get this running once it is done, and maybe some people using it.

I'm not sure why you removed the ModuleConcatenationPlugin as well, I see commit says deprecated plugin, which one is? because I don't see the source of this info in their doc, is it NamedModulesPlugin or ModuleConcatenationPlugin.

There are my notes (or questions) currently.

Edit: One more note, @ngtools/webpack should stay at 1.10.0, version 6 beta is for Angular 6 I think.

almothafar avatar Mar 18 '18 08:03 almothafar

The CommonsChunkPlugin got removed, webpack 4 is supposed to handle this out of the box.

https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366

kuhnroyal avatar Mar 18 '18 12:03 kuhnroyal

@kuhnroyal thanks, but at least add some context to your link, like a TL;DR version.

almothafar avatar Mar 18 '18 14:03 almothafar

Yes, those plug-ins were removed as they are listed as not needed for webpack anymore. Webpack does the same as they do out of the box now.

вс, 18 марта 2018 г., 15:39 Al-Mothafar Al-Hasan [email protected]:

@kuhnroyal https://github.com/kuhnroyal thanks, but at least add some context to your link, like a TL;DR version.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gdi2290/angular-starter/issues/1973#issuecomment-374004414, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWb43vfihD5g3_aR9qPt7abYOAOva3pks5tfnGXgaJpZM4SSSSW .

lanovoy avatar Mar 18 '18 14:03 lanovoy

ngtools 1.10.0 (and 1.10.2) are technically not compatible with the Webpack 4, but you may be right and it's just a cosmetic incompatibility... Feel free to verify yourself.

вс, 18 марта 2018 г., 15:54 Maksym Lanovyi [email protected]:

Yes, those plug-ins were removed as they are listed as not needed for webpack anymore. Webpack does the same as they do out of the box now.

вс, 18 марта 2018 г., 15:39 Al-Mothafar Al-Hasan <[email protected]

:

@kuhnroyal https://github.com/kuhnroyal thanks, but at least add some context to your link, like a TL;DR version.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gdi2290/angular-starter/issues/1973#issuecomment-374004414, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWb43vfihD5g3_aR9qPt7abYOAOva3pks5tfnGXgaJpZM4SSSSW .

lanovoy avatar Mar 18 '18 14:03 lanovoy

@lanovoy I'll do verify later for sure, I just did code review and was looking for clarifications before I reinvent the wheel, sadly not have enough time to do that by myself, so I appreciate your efforts. If I have fixes I'll do that on the branch that you created.

almothafar avatar Mar 18 '18 15:03 almothafar

Awesome! Thank you

вс, 18 марта 2018 г., 16:58 Al-Mothafar Al-Hasan [email protected]:

@lanovoy https://github.com/lanovoy I'll do verify later for sure, I just did code review and was looking for clarifications before I reinvent the wheel, sadly not have enough time to do that by myself, so I appreciate your efforts. If I have fixes I'll do that on the branch that you created.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gdi2290/angular-starter/issues/1973#issuecomment-374010428, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWb409M3mhnEyy0IwD4DdmpIwn_DrT0ks5tfoQdgaJpZM4SSSSW .

lanovoy avatar Mar 18 '18 16:03 lanovoy

One another outstanding issue with the webpack 4 conversion in the branch created by me, is that there is some dependency to webpack 3.x still somewhere (likely in the plugins npm packages). After npm install you will find both webpack versions in the node_modules.

lanovoy avatar Mar 19 '18 11:03 lanovoy

@lanovoy let me look into it. I am not expert but I can try.

govi2010 avatar Mar 19 '18 11:03 govi2010

@lanovoy I checked your code. use "@angular/cli": "next", instead of "@angular/cli": "^1.7.3", becasue "@angular/cli": "^1.7.3", version has dependency of webpack 3

govi2010 avatar Mar 19 '18 12:03 govi2010

I was thinking about postponing this, until Angular 6 is released it should be on 4th of April https://github.com/angular/angular/blob/master/docs/RELEASE_SCHEDULE.md

almothafar avatar Mar 19 '18 14:03 almothafar

I agree, it would be the best to wait until Angular 6 release. I will create an issue to upgrade shipped with this repo plug-in, tho...

пн, 19 марта 2018 г., 15:38 Al-Mothafar Al-Hasan [email protected]:

I was thinking about postponing this, until Angular 6 is released it should be on 4th of April https://github.com/angular/angular/blob/master/docs/RELEASE_SCHEDULE.md

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gdi2290/angular-starter/issues/1973#issuecomment-374234724, or mute the thread https://github.com/notifications/unsubscribe-auth/AFWb404QX0TDjuFhNjEZycp65g6CS0rwks5tf8LwgaJpZM4SSSSW .

lanovoy avatar Mar 19 '18 14:03 lanovoy

#1995

Additionally in my branch there is a problem with the karma test runner it seems so.

lanovoy avatar Mar 19 '18 15:03 lanovoy