bare-module 3.0.5 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +9 -1
- package/lib/errors.js +4 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -166,7 +166,15 @@ const Module = module.exports = exports = class Module {
|
|
|
166
166
|
static _handle = binding.init(this, this._onimport, this._onevaluate, this._onmeta)
|
|
167
167
|
|
|
168
168
|
static _onimport (specifier, assertions, referrerURL, isDynamicImport) {
|
|
169
|
-
const referrer = this._cache[referrerURL]
|
|
169
|
+
const referrer = this._cache[referrerURL] || null
|
|
170
|
+
|
|
171
|
+
if (referrer === null) {
|
|
172
|
+
let msg = `Cannot find referrer for module '${specifier}'`
|
|
173
|
+
|
|
174
|
+
if (referrerURL) msg += ` imported from '${referrerURL}'`
|
|
175
|
+
|
|
176
|
+
throw errors.REFERRER_MISSING(msg)
|
|
177
|
+
}
|
|
170
178
|
|
|
171
179
|
const url = this.resolve(specifier, referrer._url, {
|
|
172
180
|
isImport: true,
|
package/lib/errors.js
CHANGED
|
@@ -23,4 +23,8 @@ module.exports = class ModuleError extends Error {
|
|
|
23
23
|
static INVALID_BUNDLE_EXTENSION (msg) {
|
|
24
24
|
return new ModuleError(msg, 'INVALID_BUNDLE_EXTENSION', ModuleError.INVALID_BUNDLE_EXTENSION)
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
static REFERRER_MISSING (msg) {
|
|
28
|
+
return new ModuleError(msg, 'REFERRER_MISSING', ModuleError.REFERRER_MISSING)
|
|
29
|
+
}
|
|
26
30
|
}
|