bare-module-traverse 1.7.2 → 1.7.4
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 +4 -4
- package/index.js +14 -4
- package/lib/resolve/bare.d.ts +3 -1
- package/lib/resolve/bare.js +10 -3
- package/lib/resolve/node.d.ts +2 -1
- package/lib/resolve/node.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,11 +114,11 @@ options = {
|
|
|
114
114
|
arch: Bare.arch,
|
|
115
115
|
simulator: false,
|
|
116
116
|
host: `${platform}-${arch}${simulator ? '-simulator' : ''}`,
|
|
117
|
-
|
|
117
|
+
hosts: [host]
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
For single target traversal it is sufficient to pass `platform`, `arch`, `simulator`, and/or `host`. For multi target
|
|
121
|
+
For single target traversal it is sufficient to pass `platform`, `arch`, `simulator`, and/or `host`. For multi target traversal pass a list of `hosts` identifiers instead.
|
|
122
122
|
|
|
123
123
|
#### `resolve.node`
|
|
124
124
|
|
|
@@ -130,11 +130,11 @@ options = {
|
|
|
130
130
|
arch: process.arch,
|
|
131
131
|
simulator: false,
|
|
132
132
|
host: `${platform}-${arch}${simulator ? '-simulator' : ''}`,
|
|
133
|
-
|
|
133
|
+
hosts: [host]
|
|
134
134
|
}
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
For single target traversal it is sufficient to pass `platform`, `arch`, `simulator`, and/or `host`. For multi target
|
|
137
|
+
For single target traversal it is sufficient to pass `platform`, `arch`, `simulator`, and/or `host`. For multi target traversal pass a list of `hosts` identifiers instead.
|
|
138
138
|
|
|
139
139
|
### Algorithm
|
|
140
140
|
|
package/index.js
CHANGED
|
@@ -254,10 +254,6 @@ exports.package = function* (url, source, artifacts, visited, opts = {}) {
|
|
|
254
254
|
if (info) {
|
|
255
255
|
yield { dependency: { url, source, imports: {}, lexer: { imports: [] } } }
|
|
256
256
|
|
|
257
|
-
if (info.addon) {
|
|
258
|
-
yield { children: exports.prebuilds(url, artifacts, visited, opts) }
|
|
259
|
-
}
|
|
260
|
-
|
|
261
257
|
if (info.assets) {
|
|
262
258
|
yield {
|
|
263
259
|
children: exports.assets(info.assets, url, artifacts, visited, opts)
|
|
@@ -322,6 +318,13 @@ exports.preresolved = function* (url, source, resolutions, artifacts, visited, o
|
|
|
322
318
|
}
|
|
323
319
|
|
|
324
320
|
exports.imports = function* (parentURL, source, imports, artifacts, lexer, visited, opts = {}) {
|
|
321
|
+
// Handle backwards compatibility with the `target` option
|
|
322
|
+
if (opts.target) {
|
|
323
|
+
const { target, ...rest } = opts
|
|
324
|
+
rest.hosts = target
|
|
325
|
+
opts = rest
|
|
326
|
+
}
|
|
327
|
+
|
|
325
328
|
const {
|
|
326
329
|
resolve = exports.resolve.default,
|
|
327
330
|
builtinProtocol = 'builtin:',
|
|
@@ -468,6 +471,13 @@ exports.imports = function* (parentURL, source, imports, artifacts, lexer, visit
|
|
|
468
471
|
}
|
|
469
472
|
|
|
470
473
|
exports.prebuilds = function* (packageURL, artifacts, visited, opts = {}) {
|
|
474
|
+
// Handle backwards compatibility with the `target` option
|
|
475
|
+
if (opts.target) {
|
|
476
|
+
const { target, ...rest } = opts
|
|
477
|
+
rest.hosts = target
|
|
478
|
+
opts = rest
|
|
479
|
+
}
|
|
480
|
+
|
|
471
481
|
const {
|
|
472
482
|
host = null, // Shorthand for single host resolution
|
|
473
483
|
hosts = host !== null ? [host] : [],
|
package/lib/resolve/bare.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { type Import } from 'bare-module-lexer'
|
|
|
2
2
|
import { type ResolveOptions, type Resolver } from 'bare-addon-resolve'
|
|
3
3
|
|
|
4
4
|
interface BareResolveOptions extends ResolveOptions {
|
|
5
|
+
linked?: boolean
|
|
5
6
|
platform?: string
|
|
6
7
|
arch?: string
|
|
7
8
|
simulator?: boolean
|
|
8
|
-
|
|
9
|
+
host?: string
|
|
10
|
+
hosts?: string[]
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
declare function resolve(entry: Import, parentURL: URL, opts?: BareResolveOptions): Resolver
|
package/lib/resolve/bare.js
CHANGED
|
@@ -3,17 +3,24 @@ const resolve = require('../resolve')
|
|
|
3
3
|
const runtime = require('../runtime')
|
|
4
4
|
|
|
5
5
|
module.exports = function (entry, parentURL, opts = {}) {
|
|
6
|
+
// Handle backwards compatibility with the `target` option
|
|
7
|
+
if (opts.target) {
|
|
8
|
+
const { target, ...rest } = opts
|
|
9
|
+
rest.hosts = target
|
|
10
|
+
opts = rest
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
const {
|
|
7
14
|
linked = false,
|
|
8
15
|
platform = runtime.platform,
|
|
9
16
|
arch = runtime.arch,
|
|
10
17
|
simulator = runtime.simulator,
|
|
11
18
|
host = `${platform}-${arch}${simulator ? '-simulator' : ''}`,
|
|
12
|
-
|
|
19
|
+
hosts = [host]
|
|
13
20
|
} = opts
|
|
14
21
|
|
|
15
22
|
let extensions
|
|
16
|
-
let conditions =
|
|
23
|
+
let conditions = hosts.map((host) => ['bare', 'node', ...host.split('-')])
|
|
17
24
|
|
|
18
25
|
if (entry.type & lex.constants.ADDON) {
|
|
19
26
|
extensions = linked ? [] : ['.bare', '.node']
|
|
@@ -22,7 +29,7 @@ module.exports = function (entry, parentURL, opts = {}) {
|
|
|
22
29
|
return resolve.addon(entry.specifier || '.', parentURL, {
|
|
23
30
|
extensions,
|
|
24
31
|
conditions,
|
|
25
|
-
hosts
|
|
32
|
+
hosts,
|
|
26
33
|
linked,
|
|
27
34
|
...opts
|
|
28
35
|
})
|
package/lib/resolve/node.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ interface NodeResolveOptions extends ResolveOptions {
|
|
|
5
5
|
platform?: string
|
|
6
6
|
arch?: string
|
|
7
7
|
simulator?: boolean
|
|
8
|
-
|
|
8
|
+
host?: string
|
|
9
|
+
hosts?: string[]
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
declare function resolve(entry: Import, parentURL: URL, opts?: NodeResolveOptions): Resolver
|
package/lib/resolve/node.js
CHANGED
|
@@ -3,12 +3,19 @@ const resolve = require('../resolve')
|
|
|
3
3
|
const runtime = require('../runtime')
|
|
4
4
|
|
|
5
5
|
module.exports = function (entry, parentURL, opts = {}) {
|
|
6
|
+
// Handle backwards compatibility with the `target` option
|
|
7
|
+
if (opts.target) {
|
|
8
|
+
const { target, ...rest } = opts
|
|
9
|
+
rest.hosts = target
|
|
10
|
+
opts = rest
|
|
11
|
+
}
|
|
12
|
+
|
|
6
13
|
const {
|
|
7
14
|
platform = runtime.platform,
|
|
8
15
|
arch = runtime.arch,
|
|
9
16
|
simulator = runtime.simulator,
|
|
10
17
|
host = `${platform}-${arch}${simulator ? '-simulator' : ''}`,
|
|
11
|
-
|
|
18
|
+
hosts = [host]
|
|
12
19
|
} = opts
|
|
13
20
|
|
|
14
21
|
let extensions
|
|
@@ -16,12 +23,12 @@ module.exports = function (entry, parentURL, opts = {}) {
|
|
|
16
23
|
|
|
17
24
|
if (entry.type & lex.constants.ADDON) {
|
|
18
25
|
extensions = ['.node']
|
|
19
|
-
conditions =
|
|
26
|
+
conditions = hosts.map((host) => ['node', 'addon', ...host.split('-')])
|
|
20
27
|
|
|
21
28
|
return resolve.addon(entry.specifier || '.', parentURL, {
|
|
22
29
|
extensions,
|
|
23
30
|
conditions,
|
|
24
|
-
|
|
31
|
+
hosts,
|
|
25
32
|
...opts
|
|
26
33
|
})
|
|
27
34
|
}
|