Skip to content

Make option for exclude in js config #83

@nemchik

Description

@nemchik

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

https://github.com/namics/webpack-config-plugins/blob/6bf7421bf492dba2d1b62e1889c3970c2f48b4bf/packages/js-config-webpack-plugin/config/production.config.js#L13 and https://github.com/namics/webpack-config-plugins/blob/6bf7421bf492dba2d1b62e1889c3970c2f48b4bf/packages/js-config-webpack-plugin/config/development.config.js#L12 cause the node_modules folder NOT to be processed by the babel loader, and thus code from node packages is not transpiled per my babel configuration.

Expected behavior

It would be great if this could be setup as an option, along the lines of options.jsConfigExclude with a default value of [/[/\\\\]node_modules[/\\\\]/] that could be passed in as

new CommonConfigWebpackPlugin({ jsConfigExclude: "" }),

or

new JsConfigWebpackPlugin({ jsConfigExclude: "" }),

for those of us who want to intentionally include the node_modules folder to be transpiled by babel.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Using https://www.npmjs.com/package/signature_pad in some of my projects with the common config ends up with class in my bundles, and IE 11 does not know what to do with this, which causes all kinds of problems (the rest of the code in the bundle stops functioning). When including my own override for this by doing:

  module: {
    rules: [
      {
        test: /\.(js|jsx|mjs)$/,
        //exclude: [/[/\\\\]node_modules[/\\\\]/], // exclude node_modules folder per default
        use: [
          // run process in multiple threads
          require.resolve("thread-loader"),
          {
            loader: require.resolve("babel-loader"),
            options: {
              extends: "./.babelrc.json",
              // cache builds, future builds attempt to read from cache to avoid needing to run expensive babel processings
              cacheDirectory: true,
              // do not include superfluous whitespace characters and line terminators
              // https://babeljs.io/docs/en/babel-core/#options
              compact: true,
            },
          },
        ],
      },
    ],
  },

everything is transpiled through babel and works as expected. On my system (which is 6+ years old, dell optiplex 3010, core i3) I did not notice any significant difference in runtime for building bundles. Others may have different experience with that (noting that excluding node_modules is recommended to decrease runtime), which is why I'm hoping this can be an option and the default can maintain the current value so it would not be a breaking change.

Environment


Plugin version: 2.0.1

 
- Node version: v15.5.0 
- Platform:  Windows

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjs-configjs-config-webpack-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions