bare-module 3.1.7 → 3.1.9

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.
Files changed (2) hide show
  1. package/index.js +10 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -29,6 +29,7 @@ const Module = module.exports = exports = class Module {
29
29
  this._protocol = null
30
30
  this._bundle = null
31
31
  this._function = null
32
+ this._names = null
32
33
  this._handle = null
33
34
 
34
35
  Module._modules.add(this)
@@ -179,7 +180,9 @@ const Module = module.exports = exports = class Module {
179
180
  }
180
181
  }
181
182
 
182
- this._handle = binding.createSyntheticModule(this._url.href, names, Module._handle)
183
+ this._names = names
184
+
185
+ this._handle = binding.createSyntheticModule(this._url.href, this._names, Module._handle)
183
186
  }
184
187
 
185
188
  _evaluate (eagerRun = false) {
@@ -208,6 +211,10 @@ const Module = module.exports = exports = class Module {
208
211
 
209
212
  this._exports = binding.getNamespace(this._handle)
210
213
  }
214
+
215
+ if (this._type === constants.types.ADDON) {
216
+ if (eagerRun) binding.runModule(this._handle, Module._handle)
217
+ }
211
218
  }
212
219
 
213
220
  [Symbol.for('bare.inspect')] () {
@@ -280,10 +287,8 @@ const Module = module.exports = exports = class Module {
280
287
 
281
288
  module._evaluate()
282
289
 
283
- binding.setExport(module._handle, 'default', module._exports)
284
-
285
- for (const [key, value] of Object.entries(module._exports)) {
286
- binding.setExport(module._handle, key, value)
290
+ for (const name of module._names) {
291
+ binding.setExport(module._handle, name, name === 'default' ? module._exports : module._exports[name])
287
292
  }
288
293
  }
289
294
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "description": "Module support for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [