Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel ignore vs exclude option

Tags:

babeljs

I don't get the difference b/w babel exclude vs ignore option even after reading their documentation.

What I understood is that exclude is less aggressive than ignore. And exclude makes the current configuration object inactive and ignore stops the processing all together.

Maybe if someone from babel team(or any expert on babel can put up nicely for the general public out here would be much appreciated.

like image 330
HalfWebDev Avatar asked Oct 21 '25 05:10

HalfWebDev


1 Answers

What I understood is that exclude is less aggressive than ignore. And exclude makes the current configuration object inactive and ignore stops the processing all together.

That's essentially accurate.

When a file is ignoreed, Babel will skip processing it entirely, which makes it good for excluding files that aren't JS, or files that you explicitly know should not be processed, like large already-bundled files.

The exclude key skips applying a given configuration block to a given file. This is primarily useful alongside the overrides option, allowing you to do things like this:

presets: ["@babel/preset-env"],
overrides: [
  {
    exclude: /node_modules/,
    plugins: ["babel-plugin-lodash"],
  },
],

for instance, if you wanted to compile all of your files with preset-env, but only process your local application files with babel-plugin-lodash.

like image 72
loganfsmyth Avatar answered Oct 24 '25 20:10

loganfsmyth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!