actum / gulp-dev-stack

Actum dev stack based on gulp
MIT License
11 stars 7 forks source link

Webpack 2 (3) #169

Open kettanaito opened 7 years ago

kettanaito commented 7 years ago

Introduction

Webpack is undoubtedly one of the greatest things to handle JavaScript (any not only) bundling and serving for development and production environments.

Benefits

Implementation

This is a rather big change, therefore it is separated into several waves of implementation. Each wave will be followed by pull request and code approval. This issue is regarding only JavaScript bundling as a starting point. We can always extend the configuration once we have it (Webpack can beautifully bundle CSS, images, icons, fonts, anything).

First wave

Second wave

Third wave

Motivation

I would like to use my experience with custom configurations of Webpack from side projects, Conrad, and countless articles and posts on the web. There are a lot of details, which, if not configured, or configured wrong, can cause a spectre of various issues during development and production.

Integration

In order to eliminate incompatibility issues, mentioned changes should be stored in the separate release of gulp-dev-stack repository, marking a new era of our dev-stack.

This separation is definitely possible, feel free to suggest how it may be done if you did something similar in your repositories, otherwise I will just read the documentation of Git releases.

Additionally, choosing proper technology for your tasks is a great ground to end up with good implementation. Webpack is a great tool, yet it is still very likely that some projects will not get much benefit from it. This makes versioning even more important than ever.

Update from 23.06

This change has been approved as the part of ACTUM LAB. I will start on this as soon as I align with @DavidSlavik and my PM. Work in progress.

fidelman commented 7 years ago

@kettanaito If you need any help, I'm in a deal

DavidSlavik commented 7 years ago

Hello all,

we created "testing team" with @ronaldruzicka and @zmrhaljiri who will try if your version is ready for use. Hope that we will give you feedback very soon.

Thanks for your effort!

DavidSlavik commented 7 years ago

Please, update particular tasks by checking of checkboxes in your description.

kettanaito commented 7 years ago

@DavidSlavik hello. Testing team sounds great! I would like to gather all the feedback I can get once the implementation is testable.

However, my project workload does not allow me to spend as much time as I would want to on this internal task. I have checked the steps I've done so far, apart from the research on the web (which is not a step itself). I do not find current state as testable.

I would appreciate some help in the major obstacle this implementation faces, as well as our projects in Actum face: what is an efficient way to split the code for non router-based applications?

We already had a quick discussion with @janpanschab during the team-building, and that was interesting. I like when people brainstorm and solve problems. This is how I see this problem solved as well.

vbulant commented 7 years ago

@kettanaito There seems to be some kind of non-route based code splitting in Next.js 3: https://zeit.co/blog/next3

kettanaito commented 7 years ago

@vbulant thanks for the link! I am not very familiar with Next, yet from the things I've heart it is still based on routes. There are a few mentions of dynamic imports, which is good, but rather a flavor than a solution.

We can still use dynamic imports with Babel (maybe even without now), which resolves into a Promise. The code splitting always worked at the import point (it is not related to dynamic imports). Whenever Webpack encounters an require/import statement, it potentially creates a code splitting point.

I am thinking about organizing a small (1-1,5h) brainstorm for anybody who is interested regarding efficient code splitting point. We can come up with great ideas together :)

kettanaito commented 7 years ago

Update (16.08)

kettanaito commented 7 years ago

Update (17.08)

kettanaito commented 7 years ago

Update (30.08)

kettanaito commented 7 years ago

Update (25.09)

After some period I finally got time to spend on the task.

Benchmarks

Just to give you a brief overview how these changes affect the final bundle size.

Development Production Production (Gzip)
Before 1.1 Mb 346.4 Kb Not available
After 21.8 Kb 4.91 Kb 1.69 Kb
Size reduction ~98.1% ~98.5%

Note: Client bundle size is also smaller because all 3rd-party dependencies are bundled into a separate file (vendor.js). This file is meant to be downloaded once and cached, well, forever.

kettanaito commented 7 years ago

Update (27.10)

kettanaito commented 7 years ago

Update (13.11)

kettanaito commented 7 years ago

I would like to finish waves one and two before the end of November, so the repository would be available for testing amongst the front-end developers. The goal is to complete the second wave before the year ends.

Update (15.11)

kettanaito commented 6 years ago

Update 31.01

Thank you for everyone participating in the latest Actum Academy! I'm looking forward to continuing my research after the budged will be handled.

Changelog

TODO

Vidlec commented 6 years ago

I suggest using Webpack 4 straight away