coreprocess / babel-plugin-js-logger

Babel plugin to enable js-logger in your entire project efficiently.
13 stars 4 forks source link

babel-loader excludes ignored #4

Open chris-feist opened 5 years ago

chris-feist commented 5 years ago

Using babel 7 and webpack 4, the excludes defined for babel-loader already filter out files before running them through this plugin. However, the plugin does not honor that and instead uses its own exclude option.

My example webpack rule:

      {
        test: /\.js$/,
        exclude: [/node_modules\/(?!(some-module-that-needs-logger)\/).*/],
        use: [
          {
            loader: 'babel-loader',
          },
        ],
      },

My babel.config.js plugin

    [
      'js-logger',
      {
        // TODO:  The next line should not be needed, but because of this bug, all node-modules are excluded instead of honoring the exclusions defined for the babel-loader
        exclude: [/node_modules\/(?!(some-module-that-needs-logger)\/).*/],
        format: {
          // some js-logger config
        },
      },
    ],

Basically with the latest babel and webpack, the exclusion checking code in this plugin can be removed. Maybe it wasn't needed in the first place, but I don't know.

chris-feist commented 5 years ago

I came up with a better hack to deal with the custom exclude property. In the babel config, use: exclude: [/^$/], instead