Skip to content

Creating a regular expression for excluding node modules from transpiling except for individual modules

License

Notifications You must be signed in to change notification settings

OlehDutchenko/babel-loader-exclude-node-modules-except

Repository files navigation

babel-loader-exclude-node-modules-except

license npm npm Tests

Statements Branches Functions Lines
Statements Branches Functions Lines

Creating a regular expression for excluding node_modules
from babel transpiling except for individual modules

Usage

// webpack.config.js

const babelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except');

module.exports = {
  // config properties
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: babelLoaderExcludeNodeModulesExcept([
          // es6 modules from node_modules/
          'custom-jquery-methods',
          'swiper',
          'dom7'
        ]),
        use: {
          loader: 'babel-loader'
        }
      }
    ]
  }
};

Also, wildcards for matching are allowed, except names

Since v1.2.0

// webpack.config.js

const babelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except');

module.exports = {
  // config properties
  // ...
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: babelLoaderExcludeNodeModulesExcept([
          'react-*',
          '@awesomecorp/*'
        ]),
        use: {
          loader: 'babel-loader'
        }
      }
    ]
  }
};

Contributors 💪


License

MIT License


About

Creating a regular expression for excluding node modules from transpiling except for individual modules

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •