A
A
Alexey Nikolaev2016-11-06 22:41:46
JavaScript
Alexey Nikolaev, 2016-11-06 22:41:46

Do I understand the essence of webpack, task runners, requirejs and modules correctly?

Good evening.
I read about webpack - I've never used it before. Along the way, I read about topics related to it (modules, RequireJS) and made some conclusions.
1) Webpack is just a build system, not a task runner, and it's not fair to compare the two. Roughly speaking, webpack is similar to a ready-made task runner plugin package, plus a few unique features that are unique to it. At the same time, it itself is an npm package, albeit with a cli, and can be controlled through the task runner if necessary ( but the task runner cannot be controlled through the build system, because it simply does not have the authority to do so, and this is pointless ). This is the key difference: the build system is Vasya (albeit a very skilled one), and the task runner is a top manager. So?
2) Since the module is essentially just a pattern that needs to be followed, as a result, after assembly, we still get one or two large files (in accordance with the rules in the config). In other words, I will achieve a similar result in a barbaric way, gluing files together without any modules through gulp (encapsulating the content using objects). Right? I understand that modularity makes projects easier to maintain, scale, and maintain, but the bottom line is what counts.
3) To use a modular approach on the client, for example, using RequireJS, you need to connect it, let it work out and put the necessary files into the page code on the fly. Perhaps that is why famous projects that use all these newfangled features lag so violently in comparison with ordinary sites where a simple minified js is connected to three hundred kilobytes? And thus, we automatically roll back to point 2 to the assembly of modules.
How much do you agree with the above? What are the arguments against if these conclusions are wrong?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2016-11-07
@Nipheris

In other words, I will achieve a similar result in a barbaric way, gluing files together without any modules through gulp (encapsulating the content using objects). Right?

In a way, yes.
Not necessarily, the same webpack creates an independent bundle. Everything you need will be inside.
Comparisons with the C/C++ stack:
- modules are compilation units. We will not wait for real modules in C ++, so this is the best analogy so far :); modules written in a language other than the target JS (such as TypeScript or ES2015) are subject to compilation; JS resulting from compilation is like an object file;
- webpack is similar to a linker, with the difference that a plus linker collects only what is given to it into a binary, and webpack, on the contrary, can request compilation of modules (for which there is a concept of loaders - loaders). Imagine if the linker asked the C++ compiler to compile the required file. This is how webpack behaves;
- large output files - bundles are like ready-made lib files or binaries. They have a lot of compiled modules crammed into them, and they can either be linked to something else (if it's a library) or run (if it's a bundle to load into an HTML page);
- just like a linker (albeit with the ability to request the desired module) does not replace make, so webpack does not replace task runners.

K
Konstantin Kitmanov, 2016-11-07
@k12th

About Yes. The only thing I disagree with is the third point:
What famous projects are lagging? twitter? gmail? google and yandex maps Google docs? After all, no, although there is a rich and complex functionality. Dirty and facebook lag, because they are hung with crooked advertising to the very worst. Here are all sorts of banner networks with crooked pictures, videos and JS written in 1997 and slow down.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question