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

Some symbols are removed from the bundle, but polyfill imports are left for them #316

Closed slavafomin closed 4 years ago

slavafomin commented 5 years ago

Hello!

Thank you for this great plugin!

But, could you please share your thoughts on the following issue?

Consider a case, where there is a symbol in the source code, which triggers addition of the polyfill import by preset-env, like import 'core-js/modules/es.promise'. However, this symbol is not used and not exported by the library, therefore Rollup removes it from the final bundle. And right now we have a situation where the symbol itself is removed, but the polyfill for it is left in the header of the bundle.

Do you think if something could be done about it?

Thanks!


We are using the following configuration now:

babelPlugin(<BabelConfig | BabelPluginConfig> {
  extensions: ['.js', '.jsx', '.ts', '.tsx'],
  root: projectPath,
  babelrc: false,
  runtimeHelpers: true,
  presets: [
    [babelPresetEnv, {
      useBuiltIns: 'usage',
      corejs: 3,
    }],
  ],
  plugins: [
    [babelPluginTransformRuntime, {
      helpers: true,
      regenerator: false,
      corejs: false,
    }],
  ],
  exclude: [
    '**/node_modules/**',
  ],
})

And we have the rollup-plugin-typescript2 before that.

Andarist commented 4 years ago

I'm not sure if I understand the issue correctly. Could you set up a repro case for this?

Andarist commented 4 years ago

As we’ve not received a repro case I’m going to close this. If you manage to create one please ping me and I will reopen this.