-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
When the Babel sourceType
is script
(CJS), this plugin unessesarily creates _interopRequireDefault
in the output.
For example, this input:
Object.assign({});
Results in this output:
var _default = _interopRequireDefault(require("object-assign")).default;
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
_default({});
When output more like this would be better:
var _default = require("object-assign");
_default({});
The object-assign
package (along with others a user might specify using the moduleSpecifier
option) doesn't require any default interop:
https://unpkg.com/object-assign@4.1.1/index.js
Perhaps we should add a new noInterop
option, that behaves like the same for @babel/plugin-transform-modules-commonjs
:
https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#nointerop
It should default to true
, to ensure optimal output when no options are provided.
Metadata
Metadata
Assignees
Labels
No labels