Skip to content
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

[Feature] 💥 Upgrade to webpack 4 🎉👍 #1973

Closed
almothafar opened this issue Feb 25, 2018 · 32 comments
Closed

[Feature] 💥 Upgrade to webpack 4 🎉👍 #1973

almothafar opened this issue Feb 25, 2018 · 32 comments

Comments

@almothafar
Copy link
Contributor

  • 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

🎉 💃

@lanovoy
Copy link
Contributor

lanovoy commented Feb 26, 2018

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.

@Uter1007
Copy link

jantimon/html-webpack-plugin#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

@lanovoy
Copy link
Contributor

lanovoy commented Feb 26, 2018

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/ .

@sherlock1982
Copy link

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

@lanovoy
Copy link
Contributor

lanovoy commented Mar 6, 2018

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

@almothafar
Copy link
Contributor Author

@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

@lanovoy
Copy link
Contributor

lanovoy commented Mar 16, 2018

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.

@almothafar
Copy link
Contributor Author

almothafar commented Mar 18, 2018

@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.

@kuhnroyal
Copy link

kuhnroyal commented Mar 18, 2018

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

@almothafar
Copy link
Contributor Author

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

@lanovoy
Copy link
Contributor

lanovoy commented Mar 18, 2018 via email

@lanovoy
Copy link
Contributor

lanovoy commented Mar 18, 2018 via email

@almothafar
Copy link
Contributor Author

@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.

@lanovoy
Copy link
Contributor

lanovoy commented Mar 18, 2018 via email

@lanovoy
Copy link
Contributor

lanovoy commented Mar 19, 2018

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.

@govi2010
Copy link

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

@govi2010
Copy link

@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

@almothafar
Copy link
Contributor Author

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

@lanovoy
Copy link
Contributor

lanovoy commented Mar 19, 2018 via email

@lanovoy
Copy link
Contributor

lanovoy commented Mar 19, 2018

#1995

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

@govi2010
Copy link

I agree with waiting for angular 6 release decision. I will try to update html-elements-plugin I don't know how to update but will give a try.

@Yizhachok
Copy link

@lanovoy have you checked HMR reload after code updating? Because after CommonsChunkPlugin removing it was broken to me.

@sherlock1982
Copy link

@lanovoy you're using jasmine-core 3.1.0 which has an issue with current zone.js. This is explained here. You could use 2.9.1 or wait until new zone.js release.

@lanovoy
Copy link
Contributor

lanovoy commented Mar 21, 2018

@Yizhachok Nope, didn't test HMR. You can clone from my branch and verify yourself, tho.
In any case HMR is not really working with current setup (pre-upgrade to webpack4) - it's doing whole page reload instead of hot swapping changed parts...

@lanovoy
Copy link
Contributor

lanovoy commented Mar 21, 2018

@sherlock1982 Thanks. I suppose we're going to wait for Angular 6 release in any case, so hopefully jasmine-core will be updated by that time as well...

@mrowles
Copy link

mrowles commented Mar 21, 2018

Heads up, there are few issues with the current angular-starter test webpack + ts settings when using packages webpack@4 + typescript @2.6.2 + awesome-typescript-loader@5. More info here.

@lanovoy
Copy link
Contributor

lanovoy commented Apr 11, 2018

Looks like Angular 6 release is postponed again. RC3 just got released. Many really sweet features with Angular 6, so upgrading to it should be pretty much a priority for this starter project.

@konuch
Copy link

konuch commented Apr 26, 2018

I checked out this branch and got it working https://github.com/gdi2290/angular-starter/tree/feature/migrate-to-webpack4

@konuch
Copy link

konuch commented May 4, 2018

Bump, Angular 6.0 is out.

@govi2010
Copy link

govi2010 commented May 4, 2018

@konuch We were waiting for angular 6 release. Yes we need to test our migrate-to-webpack4 branch before we push to master.
I will start working on SSR implementation this week end.

@aaronwJordan
Copy link

aaronwJordan commented May 30, 2018

@govi2010 I did a quick skim of migrate-to-webpack4 and didn't see anything for SSR. Is that coming soon? We're looking at implementing SSR in the near future and I want to do it the 'correct' way. Thanks!

@lanovoy
Copy link
Contributor

lanovoy commented Jul 9, 2018

It was merged into master. Thanks for the help people! PR for reference #2019

@lanovoy lanovoy closed this as completed Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants