Skip to content

Commit

Permalink
[patch] Add module.exports to files using es3 member literals
Browse files Browse the repository at this point in the history
  • Loading branch information
sharmilajesupaul committed Oct 22, 2018
1 parent e8e5be0 commit df47a0a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Expand Up @@ -103,7 +103,10 @@ class ExportsFinder {
}

const objectName = path.get(`${property}.left.object.name`).node
const propertyName = path.get(`${property}.left.property.name`).node
// Check name of MemberExpressions and values of StringLiterals
const propertyName =
path.get(`${property}.left.property.name`).node ||
path.get(`${property}.left.property.value`).node
if (objectName === 'exports' || objectName === '_exports') {
if (propertyName === 'default') {
this.hasExportsDefault = true
Expand Down
22 changes: 22 additions & 0 deletions test/spec.js
Expand Up @@ -208,5 +208,27 @@ module.exports = [
module: 'default-entry',
exports: 'default-entry'
}
},
{
name: 'handle a single quote string literal export',
code: `
Object.defineProperty(exports, '__esModule', {value: true});
exports['default'] = 'foo';
`,
expected: {
module: 'foo',
exports: 'foo'
}
},
{
name: 'handle a double quote string literal export',
code: `
Object.defineProperty(exports, '__esModule', {value: true});
exports["default"] = 'foo';
`,
expected: {
module: 'foo',
exports: 'foo'
}
}
]

0 comments on commit df47a0a

Please sign in to comment.