bare-module-traverse 2.0.0 → 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 +2 -1
- package/lib/resolve/bare.js +4 -4
- package/lib/resolve/node.js +9 -11
- package/package.json +7 -5
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
|
package/lib/resolve/bare.js
CHANGED
|
@@ -13,11 +13,11 @@ module.exports = function (entry, parentURL, opts = {}) {
|
|
|
13
13
|
conditions = conditions.map((conditions) => ['addon', ...conditions])
|
|
14
14
|
|
|
15
15
|
return resolve.addon(entry.specifier || '.', parentURL, {
|
|
16
|
+
...opts,
|
|
16
17
|
extensions,
|
|
17
18
|
conditions,
|
|
18
19
|
hosts,
|
|
19
|
-
linked
|
|
20
|
-
...opts
|
|
20
|
+
linked
|
|
21
21
|
})
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -34,8 +34,8 @@ module.exports = function (entry, parentURL, opts = {}) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return resolve.module(entry.specifier, parentURL, {
|
|
37
|
+
...opts,
|
|
37
38
|
extensions,
|
|
38
|
-
conditions
|
|
39
|
-
...opts
|
|
39
|
+
conditions
|
|
40
40
|
})
|
|
41
41
|
}
|
package/lib/resolve/node.js
CHANGED
|
@@ -6,34 +6,32 @@ 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 =
|
|
13
|
+
conditions = conditions.map((conditions) => ['addon', ...conditions])
|
|
14
14
|
|
|
15
15
|
return resolve.addon(entry.specifier || '.', parentURL, {
|
|
16
|
+
...opts,
|
|
16
17
|
extensions,
|
|
17
18
|
conditions,
|
|
18
|
-
hosts
|
|
19
|
-
...opts
|
|
19
|
+
hosts
|
|
20
20
|
})
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (entry.type & lex.constants.ASSET) {
|
|
24
|
-
conditions = ['
|
|
24
|
+
conditions = conditions.map((conditions) => ['asset', ...conditions])
|
|
25
25
|
} else if (entry.type & lex.constants.REQUIRE) {
|
|
26
26
|
extensions = ['.js', '.json', '.node']
|
|
27
|
-
conditions = ['
|
|
27
|
+
conditions = conditions.map((conditions) => ['require', ...conditions])
|
|
28
28
|
} else if (entry.type & lex.constants.IMPORT) {
|
|
29
|
-
conditions = ['
|
|
30
|
-
} else {
|
|
31
|
-
conditions = ['node']
|
|
29
|
+
conditions = conditions.map((conditions) => ['import', ...conditions])
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
return resolve.module(entry.specifier, parentURL, {
|
|
33
|
+
...opts,
|
|
35
34
|
extensions,
|
|
36
|
-
conditions
|
|
37
|
-
...opts
|
|
35
|
+
conditions
|
|
38
36
|
})
|
|
39
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-module-traverse",
|
|
3
|
-
"version": "2.0.
|
|
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
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"test
|
|
43
|
-
"
|
|
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
|
},
|