bare-module-traverse 2.0.1 → 2.0.2

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/index.js CHANGED
@@ -198,12 +198,13 @@ exports.module = function* (url, source, attributes, artifacts, visited, opts =
198
198
  const [extension] = match
199
199
 
200
200
  switch (extension) {
201
- case '.js':
201
+ case '.js': {
202
202
  const isESM =
203
203
  defaultType === constants.MODULE || (info !== null && info.type === 'module')
204
204
 
205
205
  type = isESM ? constants.MODULE : constants.SCRIPT
206
206
  break
207
+ }
207
208
  case '.cjs':
208
209
  type = constants.SCRIPT
209
210
  break
@@ -6,11 +6,11 @@ module.exports = function (entry, parentURL, opts = {}) {
6
6
  const { host = runtime.host, hosts = [host] } = opts
7
7
 
8
8
  let extensions
9
- let conditions
9
+ let conditions = hosts.map((host) => ['node', ...host.split('-')])
10
10
 
11
11
  if (entry.type & lex.constants.ADDON) {
12
12
  extensions = ['.node']
13
- conditions = hosts.map((host) => ['node', 'addon', ...host.split('-')])
13
+ conditions = conditions.map((conditions) => ['addon', ...conditions])
14
14
 
15
15
  return resolve.addon(entry.specifier || '.', parentURL, {
16
16
  ...opts,
@@ -21,14 +21,12 @@ module.exports = function (entry, parentURL, opts = {}) {
21
21
  }
22
22
 
23
23
  if (entry.type & lex.constants.ASSET) {
24
- conditions = ['node', 'asset']
24
+ conditions = conditions.map((conditions) => ['asset', ...conditions])
25
25
  } else if (entry.type & lex.constants.REQUIRE) {
26
26
  extensions = ['.js', '.json', '.node']
27
- conditions = ['node', 'require']
27
+ conditions = conditions.map((conditions) => ['require', ...conditions])
28
28
  } else if (entry.type & lex.constants.IMPORT) {
29
- conditions = ['node', 'import']
30
- } else {
31
- conditions = ['node']
29
+ conditions = conditions.map((conditions) => ['import', ...conditions])
32
30
  }
33
31
 
34
32
  return resolve.module(entry.specifier, parentURL, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module-traverse",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Low-level module graph traversal for Bare",
5
5
  "exports": {
6
6
  ".": {
@@ -37,10 +37,11 @@
37
37
  "lib"
38
38
  ],
39
39
  "scripts": {
40
- "test": "npm run lint && npm run test:bare && npm run test:node",
41
- "test:bare": "bare test.js",
42
- "test:node": "node test.js",
43
- "lint": "prettier . --check"
40
+ "format": "prettier --write . && lunte --fix",
41
+ "lint": "prettier --check . && lunte",
42
+ "test": "npm run test:bare && npm run test:node",
43
+ "test:bare": "brittle-bare --coverage test.js",
44
+ "test:node": "brittle-node --coverage test.js"
44
45
  },
45
46
  "repository": {
46
47
  "type": "git",
@@ -61,6 +62,7 @@
61
62
  "bare-buffer": "^3.0.2",
62
63
  "bare-url": "^2.1.3",
63
64
  "brittle": "^3.2.1",
65
+ "lunte": "^1.8.0",
64
66
  "prettier": "^3.4.2",
65
67
  "prettier-config-holepunch": "^2.0.0"
66
68
  },