rollup / rollup-plugin-babel

This package has moved and is now available at @rollup/plugin-babel / https://github.com/rollup/plugins/tree/master/packages/babel
MIT License
702 stars 87 forks source link

bundle requires core-js internals #361

Closed johannes-z closed 4 years ago

johannes-z commented 4 years ago

My final bundle has a lot of statements like the following, even though I'm using @rollup/plugin-node-resolve and @rollup/plugin-commonjs:

var $ = require('../internals/export')

var isObject = require('../internals/is-object');

var isArray = require('../internals/is-array');

I've created a repro here: https://github.com/johannes-z/rollup-babel-yarn This is the bundle generated: https://github.com/johannes-z/rollup-babel-yarn/blob/master/packages/consumer/lib/main.js

For babel I'm using @babel/preset-env with useBuiltIns: 'usage', so that Promise gets polyfilled as well.

Ref: https://github.com/rollup/rollup-plugin-babel/issues/312

nicolo-ribaudo commented 4 years ago

It's because in packages/consumer/rollup.config.js you are only excluding consumer's node_modules, but core-js comes from the top-level node_modules. For this reason, Babel injects imports to core-js in core-js itself, causing problems.

You can fix it by using exclude: /node_modules/, which will ignore all the node_modules folders.

johannes-z commented 4 years ago

Thanks, that was it.