Open jaydenseric opened 3 years ago
When the Babel sourceType is script (CJS), this plugin unessesarily creates _interopRequireDefault in the output.
sourceType
script
_interopRequireDefault
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:
object-assign
moduleSpecifier
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:
noInterop
@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.
true
@jaydenseric That makes sense to me!
When the Babel
sourceType
isscript
(CJS), this plugin unessesarily creates_interopRequireDefault
in the output.For example, this input:
Results in this output:
When output more like this would be better:
The
object-assign
package (along with others a user might specify using themoduleSpecifier
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.