@rollup/plugin-commonjs 19.0.1 → 19.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @rollup/plugin-commonjs ChangeLog
2
2
 
3
+ ## v19.0.2
4
+
5
+ _2021-07-26_
6
+
7
+ ### Bugfixes
8
+
9
+ - fix convert module.exports with `__esModule` property(#939) (#942)
10
+
3
11
  ## v19.0.1
4
12
 
5
13
  _2021-07-15_
package/README.md CHANGED
@@ -309,7 +309,9 @@ For these situations, you can change Rollup's behaviour either globally or per m
309
309
  import * as dep$1 from 'dep';
310
310
 
311
311
  function getDefaultExportFromNamespaceIfNotNamed(n) {
312
- return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
312
+ return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1
313
+ ? n['default']
314
+ : n;
313
315
  }
314
316
 
315
317
  var dep = getDefaultExportFromNamespaceIfNotNamed(dep$1);
package/dist/index.es.js CHANGED
@@ -779,6 +779,20 @@ function isShorthandProperty(parent) {
779
779
  return parent && parent.type === 'Property' && parent.shorthand;
780
780
  }
781
781
 
782
+ function hasDefineEsmProperty(node) {
783
+ return node.properties.some((property) => {
784
+ if (
785
+ property.type === 'Property' &&
786
+ property.key.type === 'Identifier' &&
787
+ property.key.name === '__esModule' &&
788
+ isTruthy(property.value)
789
+ ) {
790
+ return true;
791
+ }
792
+ return false;
793
+ });
794
+ }
795
+
782
796
  function wrapCode(magicString, uses, moduleName, exportsName) {
783
797
  const args = [];
784
798
  const passedArgs = [];
@@ -1254,6 +1268,18 @@ function transformCommonjs(
1254
1268
  } else if (!firstTopLevelModuleExportsAssignment) {
1255
1269
  firstTopLevelModuleExportsAssignment = node;
1256
1270
  }
1271
+
1272
+ if (defaultIsModuleExports === false) {
1273
+ shouldWrap = true;
1274
+ } else if (defaultIsModuleExports === 'auto') {
1275
+ if (node.right.type === 'ObjectExpression') {
1276
+ if (hasDefineEsmProperty(node.right)) {
1277
+ shouldWrap = true;
1278
+ }
1279
+ } else if (defaultIsModuleExports === false) {
1280
+ shouldWrap = true;
1281
+ }
1282
+ }
1257
1283
  } else if (exportName === KEY_COMPILED_ESM) {
1258
1284
  if (programDepth > 3) {
1259
1285
  shouldWrap = true;