Thankfully, there were many talented developers who found ways to come up with creative solutions to make the lives of other developers easier.
babel key in your
package.json or source code files such as
babel.config.json. All of these are ways to provide configuration options to a wonderful tool which is called BabelJS.
From how I understood upon reading the documentation of BabelJS, here are the two major ways it helps developers to support target environments:
- Polyfill injection - Babel makes it easier for developers to integrate polyfill into their source code as it knows which polyfill must be injected depending on the developer's target environments.
Knowing these things which sums up what BabelJS does, I would like to add these basic things that I took note of, which in my opinion, are helpful for new developers to know about BabelJS as they look into their Babel configuration files.
Plugins - On your babel configuration file(
babel.config.json), you may see the
pluginskey. Babel makes it possible to do source code transformation through plugins.
Presets - On your babel configuration file, you may actually see first the
presetskey. Presets are simply an opinionated collection of
- Tip - In the past I was so confused as to why my babel config wasn't working on my code which caused my project to not work in a certain browser. I discovered that there can be multiple babel configurations that may override your configuration. Thankfully, I solved it before through google search 😂. Now, I know a better solution. I discovered that it is possible to see which babel config is used on certain source code files .
Thank you for spending the time reading this post. I hope that you learned something today!