bare-module-traverse 1.2.2 → 1.2.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.
@@ -7,7 +7,8 @@ module.exports = function (entry, parentURL, opts = {}) {
7
7
  const {
8
8
  platform = runtime.platform,
9
9
  arch = runtime.arch,
10
- simulator = false
10
+ simulator = false,
11
+ host = `${platform}-${arch}${simulator ? '-simulator' : ''}`
11
12
  } = opts
12
13
 
13
14
  let extensions
@@ -19,7 +20,7 @@ module.exports = function (entry, parentURL, opts = {}) {
19
20
  extensions = ['.bare', '.node']
20
21
  conditions = ['addon', ...conditions]
21
22
 
22
- return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, ...opts })
23
+ return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, host, ...opts })
23
24
  }
24
25
 
25
26
  if (entry.type & lex.constants.ASSET) {
@@ -1,14 +1,26 @@
1
1
  const lex = require('bare-module-lexer')
2
2
  const resolve = require('../resolve')
3
3
 
4
- module.exports = function (entry, parentURL, opts) {
4
+ module.exports = function (entry, parentURL, opts = {}) {
5
+ const runtime = require('#runtime')
6
+
7
+ const {
8
+ platform = runtime.platform,
9
+ arch = runtime.arch,
10
+ simulator = false,
11
+ host = `${platform}-${arch}${simulator ? '-simulator' : ''}`
12
+ } = opts
13
+
5
14
  let extensions
6
- let conditions
15
+ let conditions = ['node', platform, arch]
16
+
17
+ if (simulator) conditions = [...conditions, 'simulator']
7
18
 
8
19
  if (entry.type & lex.constants.ADDON) {
9
20
  extensions = ['.node']
21
+ conditions = ['addon', ...conditions]
10
22
 
11
- return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, ...opts })
23
+ return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, host, ...opts })
12
24
  }
13
25
 
14
26
  if (entry.type & lex.constants.REQUIRE) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module-traverse",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "Low-level module graph traversal for Bare",
5
5
  "exports": {
6
6
  ".": "./index.js",