bare-module 6.1.2 → 6.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 +40 -32
- package/index.js +4 -3
- package/package.json +5 -2
- package/prebuilds/android-arm/bare-module.bare +0 -0
- package/prebuilds/android-arm64/bare-module.bare +0 -0
- package/prebuilds/android-ia32/bare-module.bare +0 -0
- package/prebuilds/android-x64/bare-module.bare +0 -0
- package/prebuilds/darwin-arm64/bare-module.bare +0 -0
- package/prebuilds/darwin-x64/bare-module.bare +0 -0
- package/prebuilds/ios-arm64/bare-module.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-module.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-module.bare +0 -0
- package/prebuilds/linux-arm64/bare-module.bare +0 -0
- package/prebuilds/linux-x64/bare-module.bare +0 -0
- package/prebuilds/win32-arm64/bare-module.bare +0 -0
- package/prebuilds/win32-x64/bare-module.bare +0 -0
package/README.md
CHANGED
|
@@ -131,7 +131,7 @@ The following conditions are supported, listed in order from most specific to le
|
|
|
131
131
|
| `"node"` | Matches for any Node.js environment. |
|
|
132
132
|
| `"<platform>"` | Matches when equal to `Bare.platform`. See [`Bare.platform`](https://github.com/holepunchto/bare#bareplatform) for possible values. |
|
|
133
133
|
| `"<arch>"` | Matches when equal to `Bare.arch`. See [`Bare.arch`](https://github.com/holepunchto/bare#barearch) for possible values. |
|
|
134
|
-
| `"simulator"` | Matches when Bare was compiled for a simulator
|
|
134
|
+
| `"simulator"` | Matches when Bare was compiled for a simulator. |
|
|
135
135
|
| `"default"` | The fallback that always matches. This condition should always be last. |
|
|
136
136
|
|
|
137
137
|
Export conditions are evaluated in the order they are defined in the `"exports"` field. This means that less specific conditionals defined first will override more specific conditions define later. For example, the following will always call `./fallback.js` because `"default"` always matches and is defined first.
|
|
@@ -237,7 +237,7 @@ The following conditions are supported, listed in order from most specific to le
|
|
|
237
237
|
| `"node"` | Matches for any Node.js environment. |
|
|
238
238
|
| `"<platform>"` | Matches when equal to `Bare.platform`. See [`Bare.platform`](https://github.com/holepunchto/bare#bareplatform) for possible values. |
|
|
239
239
|
| `"<arch>"` | Matches when equal to `Bare.arch`. See [`Bare.arch`](https://github.com/holepunchto/bare#barearch) for possible values. |
|
|
240
|
-
| `"simulator"` | Matches when Bare was compiled for a simulator
|
|
240
|
+
| `"simulator"` | Matches when Bare was compiled for a simulator. |
|
|
241
241
|
| `"default"` | The fallback that always matches. This condition should always be last. |
|
|
242
242
|
|
|
243
243
|
The general rule is that conditions should be from most specific to least specific when defined.
|
|
@@ -332,6 +332,30 @@ options = {
|
|
|
332
332
|
}
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
+
#### `const url = Module.asset(specifier, parentURL[, options])`
|
|
336
|
+
|
|
337
|
+
Get the asset URL by resolving `specifier` relative to `parentURL`. `specifier` is a string and `parentURL` is a WHATWG `URL`.
|
|
338
|
+
|
|
339
|
+
Options include:
|
|
340
|
+
|
|
341
|
+
```js
|
|
342
|
+
options = {
|
|
343
|
+
// The referring module.
|
|
344
|
+
referrer: null,
|
|
345
|
+
// The ModuleProtocol to use resolve the specifier. Defaults to referrer's
|
|
346
|
+
// protocol if defined, otherwise defaults to Module.protocol
|
|
347
|
+
protocol,
|
|
348
|
+
// A default "imports" map to apply to all specifiers. Follows the same
|
|
349
|
+
// syntax and rules as the "imports" property defined in `package.json`.
|
|
350
|
+
imports,
|
|
351
|
+
// A map of preresolved imports with keys being serialized parent URLs and
|
|
352
|
+
// values being "imports" maps.
|
|
353
|
+
resolutions,
|
|
354
|
+
// The supported import conditions. "default" is always recognized.
|
|
355
|
+
conditions
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
335
359
|
#### `const module = Module.load(url[, source][, options])`
|
|
336
360
|
|
|
337
361
|
Load a module with the provided `url`. `url` is a WHATWG `URL`. If provided, the `source` will be passed to the matching `extension` for the `url`.
|
|
@@ -380,41 +404,17 @@ options = {
|
|
|
380
404
|
}
|
|
381
405
|
```
|
|
382
406
|
|
|
383
|
-
#### `const url = Module.asset(specifier, parentURL[, options])`
|
|
384
|
-
|
|
385
|
-
Get the asset URL by resolving `specifier` relative to `parentURL`. `specifier` is a string and `parentURL` is a WHATWG `URL`.
|
|
386
|
-
|
|
387
|
-
Options include:
|
|
388
|
-
|
|
389
|
-
```js
|
|
390
|
-
options = {
|
|
391
|
-
// The referring module.
|
|
392
|
-
referrer: null,
|
|
393
|
-
// The ModuleProtocol to use resolve the specifier. Defaults to referrer's
|
|
394
|
-
// protocol if defined, otherwise defaults to Module.protocol
|
|
395
|
-
protocol,
|
|
396
|
-
// A default "imports" map to apply to all specifiers. Follows the same
|
|
397
|
-
// syntax and rules as the "imports" property defined in `package.json`.
|
|
398
|
-
imports,
|
|
399
|
-
// A map of preresolved imports with keys being serialized parent URLs and
|
|
400
|
-
// values being "imports" maps.
|
|
401
|
-
resolutions,
|
|
402
|
-
// The supported import conditions. "default" is always recognized.
|
|
403
|
-
conditions
|
|
404
|
-
}
|
|
405
|
-
```
|
|
406
|
-
|
|
407
407
|
#### `module.url`
|
|
408
408
|
|
|
409
|
-
The WHATWG `URL`
|
|
409
|
+
The WHATWG `URL` identifier of the module.
|
|
410
410
|
|
|
411
411
|
#### `module.filename`
|
|
412
412
|
|
|
413
|
-
The
|
|
413
|
+
The file portion of `module.url`.
|
|
414
414
|
|
|
415
415
|
#### `module.dirname`
|
|
416
416
|
|
|
417
|
-
The directory
|
|
417
|
+
The directory portion of `module.url`.
|
|
418
418
|
|
|
419
419
|
#### `module.type`
|
|
420
420
|
|
|
@@ -454,7 +454,7 @@ An array of conditions used to resolve dependencies while loading the module. Se
|
|
|
454
454
|
|
|
455
455
|
#### `module.protocol`
|
|
456
456
|
|
|
457
|
-
The `ModuleProtocol` class used for resolving, reading and loading modules. See [Protocols](#protocols).
|
|
457
|
+
The `ModuleProtocol` class used for resolving, reading, and loading modules. See [Protocols](#protocols).
|
|
458
458
|
|
|
459
459
|
### CommonJS modules
|
|
460
460
|
|
|
@@ -503,7 +503,7 @@ See [`bare-addon`](https://github.com/holepunchto/bare-addon) for a template of
|
|
|
503
503
|
|
|
504
504
|
#### `require.addon.host`
|
|
505
505
|
|
|
506
|
-
Returns the string representation of the platform and architecture used when resolving addons with the pattern `<platform>-<arch>[
|
|
506
|
+
Returns the string representation of the platform and architecture used when resolving addons with the pattern `<platform>-<arch>[-<environment>]`. Returns the same value as `Bare.Addon.host`.
|
|
507
507
|
|
|
508
508
|
#### `const path = require.addon.resolve([specifier][, parentURL])`
|
|
509
509
|
|
|
@@ -540,6 +540,14 @@ A boolean representing whether the current module is the entry script where the
|
|
|
540
540
|
|
|
541
541
|
A cache of loaded modules for this module. The same value as `module.cache` for the current module.
|
|
542
542
|
|
|
543
|
+
#### `import.meta.dirname`
|
|
544
|
+
|
|
545
|
+
The directory name of the current module.
|
|
546
|
+
|
|
547
|
+
#### `import.meta.filename`
|
|
548
|
+
|
|
549
|
+
The file name of the current module.
|
|
550
|
+
|
|
543
551
|
#### `const href = import.meta.resolve(specifier[, parentURL])`
|
|
544
552
|
|
|
545
553
|
A module-relative resolution function which returns the URL string for the module. The `specifier` is a string which is resolved relative to the `parentURL` which is a WHATWG URL.
|
|
@@ -552,7 +560,7 @@ Returns the exported module contents.
|
|
|
552
560
|
|
|
553
561
|
#### `import.meta.addon.host`
|
|
554
562
|
|
|
555
|
-
Returns the string representation of the platform and architecture used when resolving addons with the pattern `<platform>-<arch>[
|
|
563
|
+
Returns the string representation of the platform and architecture used when resolving addons with the pattern `<platform>-<arch>[-<environment>]`. Returns the same value as `Bare.Addon.host`.
|
|
556
564
|
|
|
557
565
|
#### `const href = import.meta.addon.resolve([specifier][, parentURL])`
|
|
558
566
|
|
package/index.js
CHANGED
|
@@ -248,7 +248,7 @@ module.exports = exports = class Module {
|
|
|
248
248
|
static _cache =
|
|
249
249
|
module[kind] === Module[kind] ? module.cache || Object.create(null) : Object.create(null)
|
|
250
250
|
|
|
251
|
-
static _conditions = ['bare', 'node', Bare.
|
|
251
|
+
static _conditions = ['bare', 'node', ...Bare.Addon.host.split('-')]
|
|
252
252
|
|
|
253
253
|
static _handle = binding.init(this, this._onimport, this._onevaluate, this._onmeta)
|
|
254
254
|
|
|
@@ -323,6 +323,9 @@ module.exports = exports = class Module {
|
|
|
323
323
|
meta.main = module._main === module
|
|
324
324
|
meta.cache = module._cache
|
|
325
325
|
|
|
326
|
+
meta.dirname = module.dirname // For Node.js compatibility
|
|
327
|
+
meta.filename = module.filename // For Node.js compatibility
|
|
328
|
+
|
|
326
329
|
meta.resolve = function resolve(specifier, parentURL = referrer._url) {
|
|
327
330
|
return self.resolve(specifier, toURL(parentURL, referrer._url), {
|
|
328
331
|
referrer
|
|
@@ -797,8 +800,6 @@ exports.createRequire = function createRequire(parentURL, opts = {}) {
|
|
|
797
800
|
return require
|
|
798
801
|
}
|
|
799
802
|
|
|
800
|
-
if (Bare.simulator) Module._conditions.push('simulator')
|
|
801
|
-
|
|
802
803
|
Module._extensions['.js'] = function (module, source, referrer) {
|
|
803
804
|
const self = Module
|
|
804
805
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-module",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Module support for JavaScript",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,7 +20,9 @@
|
|
|
20
20
|
],
|
|
21
21
|
"addon": true,
|
|
22
22
|
"scripts": {
|
|
23
|
-
"
|
|
23
|
+
"format": "prettier --write . && lunte --fix",
|
|
24
|
+
"lint": "prettier --check . && lunte",
|
|
25
|
+
"test": "brittle-bare --coverage test.js"
|
|
24
26
|
},
|
|
25
27
|
"repository": {
|
|
26
28
|
"type": "git",
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
"bare-buffer": "^3.0.2",
|
|
47
49
|
"brittle": "^3.1.1",
|
|
48
50
|
"cmake-bare": "^1.1.6",
|
|
51
|
+
"lunte": "^1.6.0",
|
|
49
52
|
"prettier": "^3.3.3",
|
|
50
53
|
"prettier-config-holepunch": "^2.0.0"
|
|
51
54
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|