bare-module 1.14.1 → 1.14.3
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 +12 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -93,15 +93,7 @@ module.exports = exports = class Module {
|
|
|
93
93
|
static _bundles = Object.create(null)
|
|
94
94
|
static _modules = new Set()
|
|
95
95
|
|
|
96
|
-
static
|
|
97
|
-
|
|
98
|
-
static _ondestroy () {
|
|
99
|
-
for (const module in this._modules) {
|
|
100
|
-
module.destroy()
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
binding.destroy(this._context)
|
|
104
|
-
}
|
|
96
|
+
static _handle = binding.init(this, this._onimport, this._onevaluate, this._onmeta)
|
|
105
97
|
|
|
106
98
|
static _onimport (specifier, assertions, referrerFilename, dynamic) {
|
|
107
99
|
const referrer = this._cache[referrerFilename]
|
|
@@ -525,7 +517,7 @@ module.exports = exports = class Module {
|
|
|
525
517
|
static _evaluate (module) {
|
|
526
518
|
if ((module._state & constants.states.EVALUATED) !== 0) return
|
|
527
519
|
|
|
528
|
-
binding.runModule(module._handle, this.
|
|
520
|
+
binding.runModule(module._handle, this._handle)
|
|
529
521
|
|
|
530
522
|
if (module._type === constants.types.MODULE) {
|
|
531
523
|
module._exports = binding.getNamespace(module._handle)
|
|
@@ -543,7 +535,7 @@ module.exports = exports = class Module {
|
|
|
543
535
|
if (key !== 'default') names.push(key)
|
|
544
536
|
}
|
|
545
537
|
|
|
546
|
-
module._handle = binding.createSyntheticModule(module._filename, names, this.
|
|
538
|
+
module._handle = binding.createSyntheticModule(module._filename, names, this._handle)
|
|
547
539
|
|
|
548
540
|
module._state |= constants.states.SYNTHESIZED
|
|
549
541
|
}
|
|
@@ -617,7 +609,7 @@ exports._extensions['.mjs'] = function (module, source, referrer, protocol, impo
|
|
|
617
609
|
module._type = constants.types.MODULE
|
|
618
610
|
module._protocol = protocol
|
|
619
611
|
module._imports = imports
|
|
620
|
-
module._handle = binding.createModule(module._filename, source, 0, this.
|
|
612
|
+
module._handle = binding.createModule(module._filename, source, 0, this._handle)
|
|
621
613
|
}
|
|
622
614
|
|
|
623
615
|
exports._extensions['.json'] = function (module, source, referrer, protocol, imports) {
|
|
@@ -693,4 +685,11 @@ exports._protocols['data:'] = new Protocol({
|
|
|
693
685
|
}
|
|
694
686
|
})
|
|
695
687
|
|
|
696
|
-
process
|
|
688
|
+
process
|
|
689
|
+
.prependListener('teardown', () => {
|
|
690
|
+
for (const module of exports._modules) {
|
|
691
|
+
module.destroy()
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
binding.destroy(exports._handle)
|
|
695
|
+
})
|