Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Cleanup getExportByName().
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 27, 2019
1 parent 494c504 commit 4ec51fc
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions src/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,45 +960,45 @@ function getExportByName(entry, name, parentEntry) {
const parentCJS = parentEntry.package.options.cjs
const parentIsMJS = parentEntry.extname === ".mjs"

const parentMutableNamespace =
! parentIsMJS &&
parentCJS.mutableNamespace

const parentNamedExports =
! parentIsMJS &&
parentCJS.namedExports

const noMutableNamespace =
! parentMutableNamespace ||
entry.extname === ".mjs"

const noNamedExports =
! entry.builtin &&
! parentNamedExports &&
entry.type !== TYPE_ESM

if (name === "*") {
if (noMutableNamespace) {
return noNamedExports
? entry.cjsNamespace
: entry.esmNamespace
}

return noNamedExports
? entry.cjsMutableNamespace
: entry.esmMutableNamespace
}

if (noNamedExports &&
name === "default") {
return entry.exports
}

const { getters } = entry
if (name !== "*") {
const { getters } = entry

return Reflect.has(getters, name)
? tryGetter(getters[name])
: ERROR_GETTER
}

const parentMutableNamespace =
! parentIsMJS &&
parentCJS.mutableNamespace

const noMutableNamespace =
! parentMutableNamespace ||
entry.extname === ".mjs"

if (noMutableNamespace) {
return noNamedExports
? entry.cjsNamespace
: entry.esmNamespace
}

return Reflect.has(getters, name)
? tryGetter(getters[name])
: ERROR_GETTER
return noNamedExports
? entry.cjsMutableNamespace
: entry.esmMutableNamespace
}

function getExportByNameFast(entry, name, parentEntry) {
Expand Down

0 comments on commit 4ec51fc

Please sign in to comment.