babel-esm-plugin icon indicating copy to clipboard operation
babel-esm-plugin copied to clipboard

Doesn't seem to exclude externals from bundle

Open glebcha opened this issue 5 years ago • 6 comments

I use https://github.com/liady/webpack-node-externals to handle externals and cjs is ok, but esm include all of external dependencies. Maybe I did something wrong?

glebcha avatar Jul 23 '19 10:07 glebcha

Can u give us a sample repo? It'll be extremely helpful

prateekbh avatar Jul 23 '19 14:07 prateekbh

Looks like https://github.com/webpack-contrib/worker-loader/issues/95#issuecomment-352856617 related @prateekbh please look at comment

glebcha avatar Jul 31 '19 11:07 glebcha

oh yes that absolutely seems to be the root cause. I'll try to fix this.

Disclaimer: My free time during the pandemic is running seriously low. PRs are always welcome and will be reviewed at priority

prateekbh avatar May 04 '20 17:05 prateekbh

could there be a workaround for this issue?

fabioricali avatar May 09 '20 07:05 fabioricali

Adding the externalPlugin to this source code would be fix i guess

prateekbh avatar May 10 '20 23:05 prateekbh

Yeah, the quick fix is (in src/index.js of this plugin):

const { ExternalsPlugin } = require('webpack');

// ....

      if (compiler.options.externals) {
        new ExternalsPlugin('module', compiler.options.externals).apply(childCompiler);
      }

prograhammer avatar Aug 02 '21 04:08 prograhammer