bare-module 3.1.14 → 3.2.0

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/README.md CHANGED
@@ -163,6 +163,18 @@ If a package defines only a single export, `"."`, it may leave out the subpath e
163
163
 
164
164
  ##### Private imports
165
165
 
166
+ #### `"engines"`
167
+
168
+ ```json
169
+ {
170
+ "engines": {
171
+ "bare": ">=1.0.5"
172
+ }
173
+ }
174
+ ```
175
+
176
+ The engine requirements of the package. During module resolution, the versions declared by `Bare.versions` will be tested against the requirements declared by the package and resolution fail if they're not satisfied.
177
+
166
178
  ## API
167
179
 
168
180
  #### `Module.constants`
package/binding.c CHANGED
@@ -474,28 +474,30 @@ bare_module_run_module (js_env_t *env, js_callback_info_t *info) {
474
474
  err = js_get_promise_state(env, promise, &state);
475
475
  assert(err == 0);
476
476
 
477
+ js_value_t *reason;
478
+
477
479
  if (state == js_promise_rejected) {
478
- js_value_t *reason;
479
480
  err = js_get_promise_result(env, promise, &reason);
480
481
  if (err < 0) return NULL;
481
-
482
- js_value_t *exception;
483
- err = js_get_and_clear_last_exception(env, &exception);
482
+ } else {
483
+ err = js_get_null(env, &reason);
484
484
  assert(err == 0);
485
+ }
485
486
 
486
- js_value_t *ctx;
487
- err = js_get_reference_value(env, context->ctx, &ctx);
488
- assert(err == 0);
487
+ js_value_t *exception;
488
+ err = js_get_and_clear_last_exception(env, &exception);
489
+ assert(err == 0);
489
490
 
490
- js_value_t *args[3] = {reason, promise, exception};
491
+ js_value_t *ctx;
492
+ err = js_get_reference_value(env, context->ctx, &ctx);
493
+ assert(err == 0);
491
494
 
492
- js_call_function(env, ctx, argv[2], 3, args, NULL);
495
+ js_value_t *args[3] = {reason, promise, exception};
493
496
 
494
- return NULL;
495
- }
497
+ js_call_function(env, ctx, argv[2], 3, args, NULL);
496
498
  }
497
499
 
498
- return promise;
500
+ return NULL;
499
501
  }
500
502
 
501
503
  static js_value_t *
package/index.js CHANGED
@@ -180,7 +180,7 @@ const Module = module.exports = exports = class Module {
180
180
  }
181
181
 
182
182
  _run () {
183
- binding.runModule(this._handle, Module._handle, Module._onrejection)
183
+ binding.runModule(this._handle, Module._handle, Module._onrun)
184
184
  }
185
185
 
186
186
  _evaluate (eagerRun = false) {
@@ -343,10 +343,14 @@ const Module = module.exports = exports = class Module {
343
343
  }
344
344
  }
345
345
 
346
- static _onrejection (reason, promise, err = reason) {
347
- promise.catch(() => {}) // Don't leak the rejection
346
+ static _onrun (reason, promise, err = reason) {
347
+ if (err) {
348
+ promise.catch(() => {}) // Don't leak the rejection
348
349
 
349
- throw err
350
+ throw err
351
+ } else {
352
+ promise.catch((err) => queueMicrotask(() => { throw err }))
353
+ }
350
354
  }
351
355
 
352
356
  static Protocol = Protocol
@@ -449,6 +453,9 @@ const Module = module.exports = exports = class Module {
449
453
  imports,
450
454
  resolutions,
451
455
  builtins: builtins ? Object.keys(builtins) : [],
456
+ engines: {
457
+ ...Bare.versions
458
+ },
452
459
  extensions: [
453
460
  '.js',
454
461
  '.cjs',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "3.1.14",
3
+ "version": "3.2.0",
4
4
  "description": "Module support for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -27,7 +27,7 @@
27
27
  "homepage": "https://github.com/holepunchto/bare-module#readme",
28
28
  "dependencies": {
29
29
  "bare-bundle": "^1.0.0",
30
- "bare-module-resolve": "^1.4.4",
30
+ "bare-module-resolve": "^1.6.0",
31
31
  "bare-path": "^2.0.0",
32
32
  "cjs-module-lexer": "^1.2.3",
33
33
  "url-file-url": "^1.0.2"