You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Node, require("es6-error") returns the function ExtendableError, but in Rollup or Webpack, require("es6-error") returns a module { default: ExtendableError }. This means an es6-error dependent can’t be compatible with both environments without contortions.
This is because Node is using pkg.main (./lib/index), while Rollup and Webpack are using pkg.module (./es6/index.js), and the two files do not provide compatible interfaces.
Three potential solutions are:
disable babel-plugin-add-module-exports, so require("es6-error").default would work everywhere; or
add ExtendableError.default = ExtendableError for compatibility; or
remove pkg.module.
The text was updated successfully, but these errors were encountered:
andersk
changed the title
pkg.main, pkg.module are incompatible, so require("es6-error") behaves differently under Webpack
pkg.main, pkg.module are incompatible, so require("es6-error") behaves differently under Rollup/Webpack
Aug 29, 2020
In Node,
require("es6-error")
returns the functionExtendableError
, but in Rollup or Webpack,require("es6-error")
returns a module{ default: ExtendableError }
. This means anes6-error
dependent can’t be compatible with both environments without contortions.This is because Node is using
pkg.main
(./lib/index
), while Rollup and Webpack are usingpkg.module
(./es6/index.js
), and the two files do not provide compatible interfaces.Three potential solutions are:
babel-plugin-add-module-exports
, sorequire("es6-error").default
would work everywhere; orExtendableError.default = ExtendableError
for compatibility; orpkg.module
.The text was updated successfully, but these errors were encountered: