Skip to content

Commit

Permalink
Pass default host to resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Nov 2, 2024
1 parent d8a50b0 commit 00e0e35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/resolve/bare.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module.exports = function (entry, parentURL, opts = {}) {
const {
platform = runtime.platform,
arch = runtime.arch,
simulator = false
simulator = false,
host = `${platform}-${arch}${simulator ? '-simulator' : ''}`
} = opts

let extensions
Expand All @@ -19,7 +20,7 @@ module.exports = function (entry, parentURL, opts = {}) {
extensions = ['.bare', '.node']
conditions = ['addon', ...conditions]

return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, ...opts })
return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, host, ...opts })
}

if (entry.type & lex.constants.ASSET) {
Expand Down
18 changes: 15 additions & 3 deletions lib/resolve/node.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
const lex = require('bare-module-lexer')
const resolve = require('../resolve')

module.exports = function (entry, parentURL, opts) {
module.exports = function (entry, parentURL, opts = {}) {
const runtime = require('#runtime')

const {
platform = runtime.platform,
arch = runtime.arch,
simulator = false,
host = `${platform}-${arch}${simulator ? '-simulator' : ''}`
} = opts

let extensions
let conditions
let conditions = ['node', platform, arch]

if (simulator) conditions = [...conditions, 'simulator']

if (entry.type & lex.constants.ADDON) {
extensions = ['.node']
conditions = ['addon', ...conditions]

return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, ...opts })
return resolve.addon(entry.specifier || '.', parentURL, { extensions, conditions, host, ...opts })
}

if (entry.type & lex.constants.REQUIRE) {
Expand Down

0 comments on commit 00e0e35

Please sign in to comment.