This is the first article in this column and the beginning of reinventing the Webpack wheel.
1. The importance of wheels
Why repeat the wheel? Especially webpack is such a complex build system, so many ecological chains, certainly not as good as the existing ah. Yes, I know I don’t have the strength to build a better wheel right now, maybe even a simple wheel that I can’t put too much weight on. But I don’t think it’s important. The process of building the wheel is a process of summing up and rising. In my own implementation, I not only had a deeper understanding of the underlying principle of Webpack from the bottom of the framework, but also had a deeper understanding of Webpack, its plugins and loader, and its hotLoad. And it may be possible to find a weakness in this model when building a wheel. I think that’s the essence of building a wheel, and to be able to get to this point is a stage victory.
This column features building wheels
In this column, I try not to analyze the source code for WebPack directly, hoping to analyze why the authors are doing it, and if so, how I should do it, and then, based on that, make an important point about the source code.
So, I might be nagging concepts, I might be nagging logic, and I might be writing code that overturns and starts over. But this is not so important, what is important is the process of continuous quantitative change to qualitative change, in which, it is also the process of my own continuous improvement.
Methodology of wheel construction
Consider the surface and point, and then by the way of point and surface, roughly divided into the following parts:
-
- Continue with a few dozen lines of code to create the simplest frame of the wheel, the central axis of the wheel (core logic).
-
- Prepare for scaling out from the central axis (add life cycle hooks).
-
- Add spokes (add Plugin, Loader)
-
- Increase the outer ring (ES6 to ES5, dev-middleware, hot-middleware, etc.)
The result is a new wheel that can be tested in depth and even put into production.
After all, the wheel is an important invention of human progress, and it is the repetition of the wheel that keeps it changing, renewing, and increasing productivity. From the rolling transportation of logs, to the use of wooden wheels, to today’s large use of car wheels, aircraft wheels, is not the best proof. Haha, I feel like I found a good example for my wheel.
Next, we will recreate the wheel step by step according to the methodology. Due to the high pressure of work at ordinary times, I try my best to make use of weekends and update during breaks. Please watch and wait patiently. At the same time, you are welcome to join the compilation of this column, together to make the wheel well ~~
Due to time or impulse, I may not follow the above steps when I write. But I think, as I get more and more articles, I’ll keep sorting them out and making them more organized.