bare-module 4.8.4 → 4.8.5

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 CHANGED
@@ -114,14 +114,9 @@ module.exports = exports = class Module {
114
114
  Module._modules.delete(this)
115
115
  }
116
116
 
117
- _run() {
118
- binding.runModule(this._handle, Module._handle, Module._onrun)
119
- }
120
-
121
117
  _transform(isImport, isDynamicImport) {
122
118
  if (isDynamicImport) {
123
- this._synthesize()
124
- this._evaluate(true /* eagerRun */)
119
+ this._run()
125
120
  } else if (isImport) {
126
121
  this._synthesize()
127
122
  } else {
@@ -205,7 +200,7 @@ module.exports = exports = class Module {
205
200
  )
206
201
  }
207
202
 
208
- _evaluate(eagerRun = false) {
203
+ _evaluate() {
209
204
  if ((this._state & constants.states.EVALUATED) !== 0) return
210
205
 
211
206
  this._state |= constants.states.EVALUATED
@@ -224,17 +219,23 @@ module.exports = exports = class Module {
224
219
  urlToPath(this._url),
225
220
  urlToDirname(this._url)
226
221
  )
227
-
228
- if (eagerRun) this._run()
229
222
  } else if (this._type === constants.types.MODULE) {
230
223
  this._run()
231
224
 
232
225
  this._exports = binding.getNamespace(this._handle)
233
- } else if (eagerRun) {
234
- this._run()
235
226
  }
236
227
  }
237
228
 
229
+ _run() {
230
+ if ((this._state & constants.states.RUN) !== 0) return
231
+
232
+ this._state |= constants.states.RUN
233
+
234
+ this._synthesize()
235
+
236
+ binding.runModule(this._handle, Module._handle, Module._onrun)
237
+ }
238
+
238
239
  [Symbol.for('bare.inspect')]() {
239
240
  return {
240
241
  __proto__: { constructor: Module },
@@ -2,6 +2,7 @@ declare const constants: {
2
2
  states: {
3
3
  EVALUATED: number
4
4
  SYNTHESIZED: number
5
+ RUN: number
5
6
  DESTROYED: number
6
7
  }
7
8
  types: {
package/lib/constants.js CHANGED
@@ -2,7 +2,8 @@ module.exports = {
2
2
  states: {
3
3
  EVALUATED: 1,
4
4
  SYNTHESIZED: 2,
5
- DESTROYED: 4
5
+ RUN: 4,
6
+ DESTROYED: 8
6
7
  },
7
8
 
8
9
  types: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "4.8.4",
3
+ "version": "4.8.5",
4
4
  "description": "Module support for JavaScript",
5
5
  "exports": {
6
6
  ".": {