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

Commit

Permalink
Revert partial package type support. [closes #784]
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Apr 24, 2019
1 parent 8389f17 commit c93add3
Showing 1 changed file with 7 additions and 32 deletions.
39 changes: 7 additions & 32 deletions src/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const {
} = CHAR_CODE

const {
FLAGS,
OPTIONS
} = ENV

Expand All @@ -69,8 +68,6 @@ const {

const ESMRC_FILENAME = ".esmrc"
const PACKAGE_JSON_FILENAME = "package.json"
const STATE_TYPE_COMMONJS = 1
const STATE_TYPE_MODULE = 2

const esmrcExts = [".mjs", ".cjs", ".js", ".json"]

Expand All @@ -96,11 +93,6 @@ const defaultOptions = {
wasm: false
}

const moduleTypeOptions = {
cjs: false,
mode: MODE_STRICT
}

const zeroConfigOptions = {
cjs: {
cache: true,
Expand Down Expand Up @@ -668,32 +660,18 @@ function readInfo(dirPath, state) {
}
}

const shouldCheckType = state.type === void 0

let pkgParsed = 0

if (pkgJSON !== null &&
(shouldCheckType ||
! optionsFound)) {
! optionsFound) {
pkgJSON = parseJSON(pkgJSON)
pkgParsed = pkgJSON === null ? -1 : 1

if (pkgParsed === 1) {
if (shouldCheckType &&
has(pkgJSON, "type") &&
pkgJSON.type === "module") {
optionsFound = true
options = moduleTypeOptions
state.type = STATE_TYPE_MODULE
} else {
state.type = STATE_TYPE_COMMONJS
}

if (! optionsFound &&
has(pkgJSON, "esm")) {
optionsFound = true
options = pkgJSON.esm
}
if (pkgParsed === 1 &&
! optionsFound &&
has(pkgJSON, "esm")) {
optionsFound = true
options = pkgJSON.esm
}
}

Expand Down Expand Up @@ -743,10 +721,7 @@ function readInfo(dirPath, state) {
if (options === true ||
! optionsFound) {
optionsFound = true

options = FLAGS.type === "module"
? moduleTypeOptions
: OPTIONS
options = OPTIONS
}

if (pkgParsed !== 1 &&
Expand Down

0 comments on commit c93add3

Please sign in to comment.