0

I have a lib written in es6. It builds IIFE artefact (using rollup and babel configured via .babelrc) and it also exposes itself as a npm module without any transpiling (via 'module' key in package.json: https://github.com/rollup/rollup/wiki/pkg.module).

Another webpack project configured with its own babel-loader imports and uses this lib as a npm dep.

The problem is that webpack's babel-loader uses '.babelrc' from the lib to transpile it (that's how babel config lookup works).

'babelrc:false' disables config lookup and I've managed to overcome the problem by inlining webpack's babel config inside webpack.config, but is there a way to configure my webpack+babel to use babel config local to my project and not those it could find in node_modules/ ?

I understand that I can transpile my lib but since it's a private one and being used in controlled environment, I think one transpiling process in my webpack app should be enough.

Mike
  • 314
  • 1
  • 9

1 Answers1

0

this is an config examble. You can config your babel-loader through query which will cover those config from node_modules/.babelrc.

module: {
    loaders: [
        {
            test: /\.js$|\.jsx$/,
            exclude: /node_modules\/(?!(you_modules)\/).*/,
            loader: 'babel-loader',
            query: {
                presets: [
                    ['es2015', {
                        'useBuiltIns': true,
                        'modules': "commonjs",
                    }],
                    'stage-1',
                    'react'
                ],
            }
        }
    ]
},
DaFois
  • 2,197
  • 8
  • 26
  • 43
lebron
  • 21
  • 1