Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set "__esModule" to true unless "addDefaultProperty" is true #79

Open
SteinNs opened this issue May 7, 2019 · 0 comments
Open

Set "__esModule" to true unless "addDefaultProperty" is true #79

SteinNs opened this issue May 7, 2019 · 0 comments

Comments

@SteinNs
Copy link

SteinNs commented May 7, 2019

The plugin helps us set

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = 'foo';
module.exports = exports['default'];

So we can only usemod = require('xx') but not mod = require('xx').default any more if we don't set "addDefaultProperty" to true.
However, both
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } in Babel and

__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;

in webpack imports a module harmonly depending on whethermodule.__esModule is true which may import undefined from module.default.

So will it better set "__esModule" to false when "addDefaultProperty" is false in order to tell Babel and webpack import module from module.exports instead of module.exports.default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant