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
|
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'
Expected Behavior
webpack-commonjs2.min.jsis minimize ofwebpack-commonjs2.jsin the reproduction repo. so they should both be wrapped bygetDefaultExportFromCjsActual Behavior
webpack-commonjs2.min.jsis not wrap bygetDefaultExportFromCjsand will throw errorVM214:122 Uncaught TypeError: webpackCommonjs2_min is not a constructorwhen executeAdditional Information
webpackBootstrap in
lib: commonjs2is belowafter minimization it will be
the problem is
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });will get true before minimization but false after minimization inplugins/packages/commonjs/src/ast-utils.js
Lines 63 to 70 in 6867290
when
transformCommonjsbecause of target is rename fromexportstoemaybe we should revert #537 or just loose it by to not check
targetName === 'module'