Open kettanaito opened 7 years ago
@kettanaito If you need any help, I'm in a deal
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!
Please, update particular tasks by checking of checkboxes in your description.
@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.
@kettanaito There seems to be some kind of non-route based code splitting in Next.js 3: https://zeit.co/blog/next3
@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 :)
webpack.DefinePlugin()
and DLL bundle do not work well together (might be a Webpack bug)node_modules
modulesparts
and start with the changes of the build pipelineAfter some period I finally got time to spend on the task.
app
bundle:
--gzip
in the CLI)vendor
bundle (for the usage of development version of React, Redux, etc., as well as their production versions)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.
master
branch firstwebpack-dev-server
and HMR are in the scope as welldependencies
(this gets included into vendor.js
automatically), everything needed for development - into devDependencies
.build
task, no ambiguous prepare
task:subtask
(api-reload
-> api:reload
, tpl-compile
-> tpl:compile
). Following one convention, tasks are now predictableSVG_SPRITE_ALL
-> SVG.SPRITES.ALL
)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.
webpack-hot-middleware
and webpack-dev-middleware
attached to BrowserSync. This is the best option to use when you rely on BrowserSync anyway (for template and css hot reload)app.js
to enable hot reloading and HMRThank you for everyone participating in the latest Actum Academy! I'm looking forward to continuing my research after the budged will be handled.
I suggest using Webpack 4 straight away
Introduction
Webpack is undoubtedly one of the greatest things to handle JavaScript (any not only) bundling and serving for development and production environments.
Benefits
Flexibility. You can configure the source and transformation chain (loaders, plugins) to process your files. Result: Easily adoptable to any project's needs.
Performance:
DX:
Extendability. It is possible to easily extend the configuration to bundle CSS, images, fonts, anything. It is also quite simple to create a separate configurations for client/server/vendor/any end-points.
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
resolve.alias
for utmost DXvendor.js
bundle for third-party libraries (React, redux, younameit)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.