admin管理员组文章数量:1317909
I am learning about how build system works in JavaScript. If babel-loader
is transpiler that translates React
to JavaScript
, why is it part of webpack
plugin?
Isn't transpiling
and bundling
is a separate process?
And is there a resource that explain how all this frameworks fit together and make build system work in detail? I seem to only find high level overview at the official docs.
I am learning about how build system works in JavaScript. If babel-loader
is transpiler that translates React
to JavaScript
, why is it part of webpack
plugin?
Isn't transpiling
and bundling
is a separate process?
And is there a resource that explain how all this frameworks fit together and make build system work in detail? I seem to only find high level overview at the official docs.
Share Improve this question asked May 30, 2020 at 12:51 Ishan PatelIshan Patel 6,09112 gold badges51 silver badges70 bronze badges1 Answer
Reset to default 12- Webpack is a "module bundler". On its own it does not change the source of a program (note: there are some caveats to this, e.g. minification), only join all the different bits of a large codebase together for easier and more efficient delivery over the Internet (depending on the use case; you may be bundling server-side code, in which case the benefits are mostly around being able to consolidate build tooling).
- A webpack loader is used to process files during bundling. It is specific to webpack (you would not use
babel-loader
without webpack, except maybe in cases of interop with other build tools, but even then it would not be used on its own). - In a webpack configuration one specifies a mapping of file extensions to webpack loaders. For example, a mon case is to process
.ts
files usingts-loader
. This way, webpack will pass off files with the.ts
extension to the TypeScript piler, and use the output of this pilation in the bundle, instead of the source program. - Babel is a piler; it takes an ESNext program and produces an equivalent ES3+ patible program.
babel-loader
does whatts-loader
does for TypeScript; passes off files to the Babel piler, and returns the result to be used in the bundle in-place of the original source program.
Isn't transpiling and bundling is a separate process?
Yes. That is why we have "webpack the bundler", and "Babel the piler/transpiler", and babel-loader
to connect the two together. Without babel-loader
webpack would not be able to process files through Babel.
Hope that helps.
本文标签: javascriptwhy babelloader is part of webpack instead babel itselfStack Overflow
版权声明:本文标题:javascript - why babel-loader is part of webpack instead babel itself? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742028382a2415980.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论