bare-module-traverse 1.7.2 → 1.7.3

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
@@ -114,11 +114,11 @@ options = {
114
114
  arch: Bare.arch,
115
115
  simulator: false,
116
116
  host: `${platform}-${arch}${simulator ? '-simulator' : ''}`,
117
- target: [host]
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 target traversal pass a list of `target` identifiers instead.
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
- target: [host]
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 target traversal pass a list of `target` identifiers instead.
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
@@ -322,6 +322,13 @@ exports.preresolved = function* (url, source, resolutions, artifacts, visited, o
322
322
  }
323
323
 
324
324
  exports.imports = function* (parentURL, source, imports, artifacts, lexer, visited, opts = {}) {
325
+ // Handle backwards compatibility with the `target` option
326
+ if (opts.target) {
327
+ const { target, ...rest } = opts
328
+ rest.hosts = target
329
+ opts = rest
330
+ }
331
+
325
332
  const {
326
333
  resolve = exports.resolve.default,
327
334
  builtinProtocol = 'builtin:',
@@ -468,6 +475,13 @@ exports.imports = function* (parentURL, source, imports, artifacts, lexer, visit
468
475
  }
469
476
 
470
477
  exports.prebuilds = function* (packageURL, artifacts, visited, opts = {}) {
478
+ // Handle backwards compatibility with the `target` option
479
+ if (opts.target) {
480
+ const { target, ...rest } = opts
481
+ rest.hosts = target
482
+ opts = rest
483
+ }
484
+
471
485
  const {
472
486
  host = null, // Shorthand for single host resolution
473
487
  hosts = host !== null ? [host] : [],
@@ -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
- target?: string[]
9
+ host?: string
10
+ hosts?: string[]
9
11
  }
10
12
 
11
13
  declare function resolve(entry: Import, parentURL: URL, opts?: BareResolveOptions): Resolver
@@ -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
- target = [host]
19
+ hosts = [host]
13
20
  } = opts
14
21
 
15
22
  let extensions
16
- let conditions = target.map((host) => ['bare', 'node', ...host.split('-')])
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: target,
32
+ hosts,
26
33
  linked,
27
34
  ...opts
28
35
  })
@@ -5,7 +5,8 @@ interface NodeResolveOptions extends ResolveOptions {
5
5
  platform?: string
6
6
  arch?: string
7
7
  simulator?: boolean
8
- target?: string[]
8
+ host?: string
9
+ hosts?: string[]
9
10
  }
10
11
 
11
12
  declare function resolve(entry: Import, parentURL: URL, opts?: NodeResolveOptions): Resolver
@@ -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
- target = [host]
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 = target.map((host) => ['node', 'addon', ...host.split('-')])
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
- host,
31
+ hosts,
25
32
  ...opts
26
33
  })
27
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module-traverse",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Low-level module graph traversal for Bare",
5
5
  "exports": {
6
6
  ".": {