-
-
Notifications
You must be signed in to change notification settings - Fork 613
Closed
Description
- Rollup Plugin Name: commonjs
- Rollup Plugin Version: v19.0.0
- Rollup Version: ^2.39.0 (I think this is not related to)
- Operating System (or Browser): Win10
- Node Version: 14.15.3
- Link to reproduction (
⚠️ read below): https://replit.com/@githoniel/rollup-plugin-repro#output/bundle.js
Expected Behavior
webpack-commonjs2.min.js is minimize of webpack-commonjs2.js in the reproduction repo. so they should both be wrapped by getDefaultExportFromCjs
Actual Behavior
webpack-commonjs2.min.js is not wrap by getDefaultExportFromCjs and will throw error VM214:122 Uncaught TypeError: webpackCommonjs2_min is not a constructor when execute
Additional Information
webpackBootstrap in lib: commonjs2 is below
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };after minimization it will be
r.r = function (e) {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {
value: "Module"
}), Object.defineProperty(e, "__esModule", {
value: !0
})
}
the problem is Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); will get true before minimization but false after minimization in
plugins/packages/commonjs/src/ast-utils.js
Lines 63 to 70 in 6867290
| export function isDefineCompiledEsm(node) { | |
| const definedProperty = | |
| getDefinePropertyCallName(node, 'exports') || getDefinePropertyCallName(node, 'module.exports'); | |
| if (definedProperty && definedProperty.key === KEY_COMPILED_ESM) { | |
| return isTruthy(definedProperty.value); | |
| } | |
| return false; | |
| } |
when
transformCommonjs because of target is rename from exports to e
maybe we should revert #537 or just loose it by to not check targetName === 'module'
Metadata
Metadata
Assignees
Labels
No labels