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

Commit

Permalink
Cache errors thrown while loading ES modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Aug 15, 2017
1 parent b56ce4e commit f803d23
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import getSourceType from "./util/get-source-type.js"
import isObjectLike from "./util/is-object-like.js"
import keys from "./util/keys.js"
import resolveId from "./util/resolve-id.js"
import setGetter from "./util/set-getter.js"

const queryHashRegExp = /[?#].*$/

Expand Down Expand Up @@ -179,6 +180,8 @@ class Runtime {
}

if (error) {
// Unlike CJS, ESM errors are preserved for subsequent loads.
setGetter(Module._cache, cacheId, () => { throw error })
throw error
} else {
child = Module._cache[cacheId]
Expand Down

0 comments on commit f803d23

Please sign in to comment.