bare-module 1.12.0 → 1.12.1

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/binding.c CHANGED
@@ -198,6 +198,9 @@ bare_module_destroy (js_env_t *env, js_callback_info_t *info) {
198
198
  err = js_delete_reference(env, context->on_evaluate);
199
199
  assert(err == 0);
200
200
 
201
+ err = js_delete_reference(env, context->on_meta);
202
+ assert(err == 0);
203
+
201
204
  err = js_delete_reference(env, context->ctx);
202
205
  assert(err == 0);
203
206
 
package/index.js CHANGED
@@ -390,20 +390,20 @@ const Module = module.exports = class Module {
390
390
 
391
391
  static _transform (module, referrer = null, dynamic = false) {
392
392
  if (dynamic) {
393
- if (module._type !== 'esm' && module._handle === null) {
393
+ if (module._type !== constants.TYPE_ESM && module._handle === null) {
394
394
  this._synthesize(module)
395
395
  }
396
396
 
397
397
  this._evaluate(module)
398
398
  } else if (referrer) {
399
- if (referrer._type === 'esm') {
400
- if (module._type !== 'esm' && module._handle === null) {
399
+ if (referrer._type === constants.TYPE_ESM) {
400
+ if (module._type !== constants.TYPE_ESM && module._handle === null) {
401
401
  this._synthesize(module)
402
402
  }
403
- } else if (module._type === 'esm') {
403
+ } else if (module._type === constants.TYPE_ESM) {
404
404
  this._evaluate(module)
405
405
  }
406
- } else if (module._type === 'esm') {
406
+ } else if (module._type === constants.TYPE_ESM) {
407
407
  this._evaluate(module)
408
408
  }
409
409
 
@@ -415,7 +415,7 @@ const Module = module.exports = class Module {
415
415
 
416
416
  binding.runModule(module._handle, this._context)
417
417
 
418
- if (module._type === 'esm') {
418
+ if (module._type === constants.TYPE_ESM) {
419
419
  module.exports = binding.getNamespace(module._handle)
420
420
  }
421
421
 
@@ -441,7 +441,7 @@ Module._extensions['.js'] = function (module, source, referrer, protocol, import
441
441
  (module._info && module._info.type === 'module') ||
442
442
 
443
443
  // The source is a data: URI and the referrer is itself an ES module.
444
- (protocol === this._protocols['data:'] && referrer && referrer._type === 'esm')
444
+ (protocol === this._protocols['data:'] && referrer && referrer._type === constants.TYPE_ESM)
445
445
  )
446
446
 
447
447
  const loader = this._extensions[isESM ? '.mjs' : '.cjs']
@@ -474,7 +474,7 @@ Module._extensions['.cjs'] = function (module, source, referrer, protocol, impor
474
474
  return module.exports
475
475
  }
476
476
 
477
- module._type = 'cjs'
477
+ module._type = constants.TYPE_CJS
478
478
  module._protocol = protocol
479
479
  module._imports = imports
480
480
 
@@ -498,7 +498,7 @@ Module._extensions['.mjs'] = function (module, source, referrer, protocol, impor
498
498
 
499
499
  if (typeof source !== 'string') source = Buffer.coerce(source).toString()
500
500
 
501
- module._type = 'esm'
501
+ module._type = constants.TYPE_ESM
502
502
  module._protocol = protocol
503
503
  module._imports = imports
504
504
 
@@ -510,7 +510,7 @@ Module._extensions['.json'] = function (module, source, referrer, protocol, impo
510
510
 
511
511
  if (typeof source !== 'string') source = Buffer.coerce(source).toString()
512
512
 
513
- module._type = 'json'
513
+ module._type = constants.TYPE_JSON
514
514
  module._protocol = protocol
515
515
  module._imports = imports
516
516
 
@@ -518,7 +518,7 @@ Module._extensions['.json'] = function (module, source, referrer, protocol, impo
518
518
  }
519
519
 
520
520
  Module._extensions['.bare'] = function (module, source, referrer, protocol, imports) {
521
- module._type = 'addon'
521
+ module._type = constants.TYPE_ADDON
522
522
  module._protocol = protocol
523
523
  module._imports = imports
524
524
 
@@ -526,7 +526,7 @@ Module._extensions['.bare'] = function (module, source, referrer, protocol, impo
526
526
  }
527
527
 
528
528
  Module._extensions['.node'] = function (module, source, referrer, protocol, imports) {
529
- module._type = 'addon'
529
+ module._type = constants.TYPE_ADDON
530
530
  module._protocol = protocol
531
531
  module._imports = imports
532
532
 
@@ -538,7 +538,7 @@ Module._extensions['.bundle'] = function (module, source, referrer, protocol, im
538
538
 
539
539
  const bundle = this._bundleFor(module.filename, protocol, source)
540
540
 
541
- module._type = 'bundle'
541
+ module._type = constants.TYPE_BUNDLE
542
542
  module._protocol = protocol
543
543
  module._imports = imports
544
544
 
package/lib/constants.js CHANGED
@@ -1,3 +1,9 @@
1
1
  module.exports = {
2
- STATE_EVALUATED: 1
2
+ STATE_EVALUATED: 1,
3
+
4
+ TYPE_ESM: 'esm',
5
+ TYPE_CJS: 'cjs',
6
+ TYPE_JSON: 'json',
7
+ TYPE_BUNDLE: 'bundle',
8
+ TYPE_ADDON: 'addon'
3
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "1.12.0",
3
+ "version": "1.12.1",
4
4
  "description": "Module support for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [