babel-plugin-explicit-exports-references icon indicating copy to clipboard operation
babel-plugin-explicit-exports-references copied to clipboard

Breaks ES Modules

Open jwarkentin opened this issue 3 years ago • 1 comments

When transpiling to ES Modules (including setting "type": "module" in package.json) this breaks Jest tests with the error:

ReferenceError: module is not defined

It seems it doesn't take the targeted build type into account and just assumes it's building CommonJS modules. I know the options are limited and I'm not certain what the best solution is, but since ES Module adoption is only increasing it would be nice to have the option to not produce a broken build with Jest. Just wanted to at least raise the issue for consideration.

jwarkentin avatar Jan 26 '22 11:01 jwarkentin

Thanks for this! ESM has different rules (like module and exports not being available) but there may be a solution. I'll take a look.

Xunnamius avatar Jan 26 '22 16:01 Xunnamius