Skip to content

Commit

Permalink
fix: produce workable code when __esModule is already preserved
Browse files Browse the repository at this point in the history
  • Loading branch information
bhovhannes committed Dec 15, 2022
1 parent 75e9ff4 commit 2eccaf5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/commonjs/src/helpers.js
Expand Up @@ -35,6 +35,7 @@ export function getDefaultExportFromNamespaceIfNotNamed (n) {
}
export function getAugmentedNamespace(n) {
if (n.__esModule) return n;
var f = n.default;
if (typeof f == "function") {
var a = function a () {
Expand Down
13 changes: 13 additions & 0 deletions packages/commonjs/test/snapshots/function.js.md
Expand Up @@ -3491,6 +3491,7 @@ Generated by [AVA](https://avajs.dev).
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespaceCompat(externalEsmDefault);␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -3577,6 +3578,7 @@ Generated by [AVA](https://avajs.dev).
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespaceCompat(externalEsmDefault);␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -3657,6 +3659,7 @@ Generated by [AVA](https://avajs.dev).
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespaceCompat(externalEsmDefault);␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -3750,6 +3753,7 @@ Generated by [AVA](https://avajs.dev).
'main.js': `'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -3957,6 +3961,7 @@ Generated by [AVA](https://avajs.dev).
'main.js': `'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -4187,6 +4192,7 @@ Generated by [AVA](https://avajs.dev).
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespaceCompat(externalEsmDefault);␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -4289,6 +4295,7 @@ Generated by [AVA](https://avajs.dev).
'main.js': `'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -4482,6 +4489,7 @@ Generated by [AVA](https://avajs.dev).
}␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -4760,6 +4768,7 @@ Generated by [AVA](https://avajs.dev).
var externalEsmDefault__namespace = /*#__PURE__*/_interopNamespaceCompat(externalEsmDefault);␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -4854,6 +4863,7 @@ Generated by [AVA](https://avajs.dev).
'main.js': `'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -6163,6 +6173,7 @@ Generated by [AVA](https://avajs.dev).
'main.js': `'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -6214,6 +6225,7 @@ Generated by [AVA](https://avajs.dev).
'main.js': `'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -7167,6 +7179,7 @@ Generated by [AVA](https://avajs.dev).
'main.js': `'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down
Binary file modified packages/commonjs/test/snapshots/function.js.snap
Binary file not shown.
3 changes: 3 additions & 0 deletions packages/commonjs/test/snapshots/test.js.md
Expand Up @@ -42,6 +42,7 @@ Generated by [AVA](https://avajs.dev).
}␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -199,6 +200,7 @@ Generated by [AVA](https://avajs.dev).
`'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down Expand Up @@ -279,6 +281,7 @@ Generated by [AVA](https://avajs.dev).
`'use strict';␊
␊
function getAugmentedNamespace(n) {␊
if (n.__esModule) return n;␊
var f = n.default;␊
if (typeof f == "function") {␊
var a = function a () {␊
Expand Down
Binary file modified packages/commonjs/test/snapshots/test.js.snap
Binary file not shown.

0 comments on commit 2eccaf5

Please sign in to comment.