eslint-plugin-n 17.10.3 → 17.11.0
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/lib/rules/no-deprecated-api.js +52 -0
- package/lib/rules/no-missing-import.js +5 -1
- package/lib/rules/no-process-env.js +51 -1
- package/lib/unsupported-features/node-builtins-modules/inspector.js +6 -0
- package/lib/unsupported-features/node-builtins-modules/module.js +7 -0
- package/lib/unsupported-features/node-builtins-modules/path.js +1 -1
- package/lib/unsupported-features/node-builtins-modules/perf_hooks.js +31 -2
- package/lib/unsupported-features/node-builtins-modules/repl.js +49 -0
- package/lib/unsupported-features/node-builtins-modules/stream.js +1 -0
- package/lib/unsupported-features/node-builtins-modules/util.js +1 -0
- package/lib/unsupported-features/node-builtins-modules/zlib.js +37 -10
- package/lib/unsupported-features/node-builtins.js +1 -0
- package/lib/util/import-target.js +13 -2
- package/package.json +1 -1
|
@@ -330,6 +330,12 @@ const rawModules = {
|
|
|
330
330
|
},
|
|
331
331
|
},
|
|
332
332
|
},
|
|
333
|
+
nextTick: {
|
|
334
|
+
[READ]: {
|
|
335
|
+
since: "22.7.0",
|
|
336
|
+
replacedBy: "'queueMicrotask()'",
|
|
337
|
+
},
|
|
338
|
+
},
|
|
333
339
|
},
|
|
334
340
|
punycode: {
|
|
335
341
|
[READ]: {
|
|
@@ -351,6 +357,17 @@ const rawModules = {
|
|
|
351
357
|
[READ]: { since: "6.0.0", replacedBy: null },
|
|
352
358
|
},
|
|
353
359
|
},
|
|
360
|
+
repl: {
|
|
361
|
+
REPLServer: {
|
|
362
|
+
[READ]: { since: "22.9.0", replacedBy: "new repl.REPLServer()" },
|
|
363
|
+
},
|
|
364
|
+
Recoverable: {
|
|
365
|
+
[READ]: { since: "22.9.0", replacedBy: "new repl.Recoverable()" },
|
|
366
|
+
},
|
|
367
|
+
REPL_MODE_MAGIC: {
|
|
368
|
+
[READ]: { since: "8.0.0", replacedBy: null },
|
|
369
|
+
},
|
|
370
|
+
},
|
|
354
371
|
// safe-buffer.Buffer function/constructror is just a re-export of buffer.Buffer
|
|
355
372
|
// and should be deprecated likewise.
|
|
356
373
|
"safe-buffer": {
|
|
@@ -576,6 +593,41 @@ const rawModules = {
|
|
|
576
593
|
[READ]: { since: "8.0.0", replacedBy: null },
|
|
577
594
|
},
|
|
578
595
|
},
|
|
596
|
+
zlib: {
|
|
597
|
+
BrotliCompress: {
|
|
598
|
+
[CALL]: {
|
|
599
|
+
since: "22.9.0",
|
|
600
|
+
replacedBy: "new zlib.BrotliCompress()",
|
|
601
|
+
},
|
|
602
|
+
},
|
|
603
|
+
BrotliDecompress: {
|
|
604
|
+
[CALL]: {
|
|
605
|
+
since: "22.9.0",
|
|
606
|
+
replacedBy: "new zlib.BrotliDecompress()",
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
Deflate: {
|
|
610
|
+
[CALL]: { since: "22.9.0", replacedBy: "new zlib.Deflate()" },
|
|
611
|
+
},
|
|
612
|
+
DeflateRaw: {
|
|
613
|
+
[CALL]: { since: "22.9.0", replacedBy: "new zlib.DeflateRaw()" },
|
|
614
|
+
},
|
|
615
|
+
Gunzip: {
|
|
616
|
+
[CALL]: { since: "22.9.0", replacedBy: "new zlib.Gunzip()" },
|
|
617
|
+
},
|
|
618
|
+
Gzip: {
|
|
619
|
+
[CALL]: { since: "22.9.0", replacedBy: "new zlib.Gzip()" },
|
|
620
|
+
},
|
|
621
|
+
Inflate: {
|
|
622
|
+
[CALL]: { since: "22.9.0", replacedBy: "new zlib.Inflate()" },
|
|
623
|
+
},
|
|
624
|
+
InflateRaw: {
|
|
625
|
+
[CALL]: { since: "22.9.0", replacedBy: "new zlib.InflateRaw()" },
|
|
626
|
+
},
|
|
627
|
+
Unzip: {
|
|
628
|
+
[CALL]: { since: "22.9.0", replacedBy: "new zlib.Unzip()" },
|
|
629
|
+
},
|
|
630
|
+
},
|
|
579
631
|
}
|
|
580
632
|
const modules = extendTrackmapWithNodePrefix(rawModules)
|
|
581
633
|
|
|
@@ -30,6 +30,7 @@ module.exports = {
|
|
|
30
30
|
allowModules: getAllowModules.schema,
|
|
31
31
|
resolvePaths: getResolvePaths.schema,
|
|
32
32
|
tryExtensions: getTryExtensions.schema,
|
|
33
|
+
ignoreTypeImport: { type: "boolean", default: false },
|
|
33
34
|
tsconfigPath: getTSConfig.schema,
|
|
34
35
|
typescriptExtensionMap: getTypescriptExtensionMap.schema,
|
|
35
36
|
},
|
|
@@ -39,12 +40,15 @@ module.exports = {
|
|
|
39
40
|
messages,
|
|
40
41
|
},
|
|
41
42
|
create(context) {
|
|
43
|
+
const options = context.options[0] ?? {}
|
|
44
|
+
const ignoreTypeImport = options.ignoreTypeImport ?? false
|
|
45
|
+
|
|
42
46
|
const filePath = context.filename ?? context.getFilename()
|
|
43
47
|
if (filePath === "<input>") {
|
|
44
48
|
return {}
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
return visitImport(context, {}, targets => {
|
|
51
|
+
return visitImport(context, { ignoreTypeImport }, targets => {
|
|
48
52
|
checkExistence(context, targets)
|
|
49
53
|
})
|
|
50
54
|
},
|
|
@@ -13,8 +13,26 @@ const querySelector = [
|
|
|
13
13
|
`[computed!=true]`,
|
|
14
14
|
`[object.name="process"]`,
|
|
15
15
|
`[property.name="env"]`,
|
|
16
|
+
`,`,
|
|
17
|
+
`MemberExpression`,
|
|
18
|
+
`[computed=true]`,
|
|
19
|
+
`[object.name="process"]`,
|
|
20
|
+
`[property.value="env"]`,
|
|
16
21
|
]
|
|
17
22
|
|
|
23
|
+
/**
|
|
24
|
+
* @param {unknown} node [description]
|
|
25
|
+
* @returns {node is import('estree').MemberExpression}
|
|
26
|
+
*/
|
|
27
|
+
function isMemberExpresion(node) {
|
|
28
|
+
return (
|
|
29
|
+
node != null &&
|
|
30
|
+
typeof node === "object" &&
|
|
31
|
+
"type" in node &&
|
|
32
|
+
node.type === "MemberExpression"
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
18
36
|
/** @type {import('eslint').Rule.RuleModule} */
|
|
19
37
|
module.exports = {
|
|
20
38
|
meta: {
|
|
@@ -25,16 +43,48 @@ module.exports = {
|
|
|
25
43
|
url: "https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/no-process-env.md",
|
|
26
44
|
},
|
|
27
45
|
fixable: null,
|
|
28
|
-
schema: [
|
|
46
|
+
schema: [
|
|
47
|
+
{
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
allowedVariables: {
|
|
51
|
+
type: "array",
|
|
52
|
+
items: { type: "string" },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
additionalProperties: false,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
29
58
|
messages: {
|
|
30
59
|
unexpectedProcessEnv: "Unexpected use of process.env.",
|
|
31
60
|
},
|
|
32
61
|
},
|
|
33
62
|
|
|
34
63
|
create(context) {
|
|
64
|
+
const options = context.options[0] ?? {}
|
|
65
|
+
/** @type {string[]} */
|
|
66
|
+
const allowedVariables = options.allowedVariables ?? []
|
|
35
67
|
return {
|
|
36
68
|
/** @param {import('estree').MemberExpression} node */
|
|
37
69
|
[querySelector.join("")](node) {
|
|
70
|
+
if (
|
|
71
|
+
"parent" in node &&
|
|
72
|
+
isMemberExpresion(node.parent) &&
|
|
73
|
+
node.parent.property != null
|
|
74
|
+
) {
|
|
75
|
+
const child = node.parent.property
|
|
76
|
+
if (
|
|
77
|
+
(child.type === "Identifier" &&
|
|
78
|
+
node.parent.computed === false &&
|
|
79
|
+
allowedVariables.includes(child.name)) ||
|
|
80
|
+
(child.type === "Literal" &&
|
|
81
|
+
typeof child.value === "string" &&
|
|
82
|
+
node.parent.computed === true &&
|
|
83
|
+
allowedVariables.includes(child.value))
|
|
84
|
+
) {
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
}
|
|
38
88
|
context.report({ node, messageId: "unexpectedProcessEnv" })
|
|
39
89
|
},
|
|
40
90
|
}
|
|
@@ -4,6 +4,12 @@ const { READ } = require("@eslint-community/eslint-utils")
|
|
|
4
4
|
|
|
5
5
|
/** @type {import('../types.js').SupportVersionTraceMap} */
|
|
6
6
|
const common_objects = {
|
|
7
|
+
Network: {
|
|
8
|
+
requestWillBeSent: { [READ]: { experimental: ["22.6.0"] } },
|
|
9
|
+
responseReceived: { [READ]: { experimental: ["22.6.0"] } },
|
|
10
|
+
loadingFinished: { [READ]: { experimental: ["22.6.0"] } },
|
|
11
|
+
loadingFailed: { [READ]: { experimental: ["22.7.0"] } },
|
|
12
|
+
},
|
|
7
13
|
console: { [READ]: { supported: ["8.0.0"] } },
|
|
8
14
|
close: { [READ]: { supported: ["9.0.0"] } },
|
|
9
15
|
open: { [READ]: { supported: ["8.0.0"] } },
|
|
@@ -5,6 +5,11 @@ const { READ } = require("@eslint-community/eslint-utils")
|
|
|
5
5
|
/** @type {import('../types.js').SupportVersionTraceMap} */
|
|
6
6
|
const Module = {
|
|
7
7
|
builtinModules: { [READ]: { supported: ["9.3.0", "8.10.0", "6.13.0"] } },
|
|
8
|
+
constants: {
|
|
9
|
+
compileCacheStatus: {
|
|
10
|
+
[READ]: { experimental: ["22.8.0"] },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
8
13
|
createRequire: { [READ]: { supported: ["12.2.0"] } },
|
|
9
14
|
createRequireFromPath: {
|
|
10
15
|
[READ]: {
|
|
@@ -12,6 +17,8 @@ const Module = {
|
|
|
12
17
|
deprecated: ["12.2.0"],
|
|
13
18
|
},
|
|
14
19
|
},
|
|
20
|
+
enableCompileCache: { [READ]: { experimental: ["22.8.0"] } },
|
|
21
|
+
getCompileCacheDir: { [READ]: { experimental: ["22.8.0"] } },
|
|
15
22
|
isBuiltin: { [READ]: { supported: ["18.6.0", "16.17.0"] } },
|
|
16
23
|
register: { [READ]: { experimental: ["20.6.0"] } },
|
|
17
24
|
syncBuiltinESMExports: { [READ]: { supported: ["12.12.0"] } },
|
|
@@ -10,7 +10,7 @@ const path = {
|
|
|
10
10
|
dirname: { [READ]: { supported: ["0.1.16"] } },
|
|
11
11
|
extname: { [READ]: { supported: ["0.1.25"] } },
|
|
12
12
|
format: { [READ]: { supported: ["0.11.15"] } },
|
|
13
|
-
matchesGlob: { [READ]: { experimental: ["22.5.0"] } },
|
|
13
|
+
matchesGlob: { [READ]: { experimental: ["22.5.0", "20.17.0"] } },
|
|
14
14
|
isAbsolute: { [READ]: { supported: ["0.11.2"] } },
|
|
15
15
|
join: { [READ]: { supported: ["0.1.16"] } },
|
|
16
16
|
normalize: { [READ]: { supported: ["0.1.23"] } },
|
|
@@ -4,7 +4,36 @@ const { READ } = require("@eslint-community/eslint-utils")
|
|
|
4
4
|
|
|
5
5
|
/** @type {import('../types.js').SupportVersionTraceMap} */
|
|
6
6
|
const perf_hooks = {
|
|
7
|
-
performance: {
|
|
7
|
+
performance: {
|
|
8
|
+
[READ]: { supported: ["8.5.0"] },
|
|
9
|
+
clearMarks: { [READ]: { supported: ["8.5.0"] } },
|
|
10
|
+
clearMeasures: { [READ]: { supported: ["16.7.0"] } },
|
|
11
|
+
clearResourceTimings: { [READ]: { supported: ["18.2.0", "v16.17.0"] } },
|
|
12
|
+
eventLoopUtilization: { [READ]: { supported: ["14.10.0", "12.19.0"] } },
|
|
13
|
+
getEntries: { [READ]: { supported: ["16.7.0"] } },
|
|
14
|
+
getEntriesByName: { [READ]: { supported: ["16.7.0"] } },
|
|
15
|
+
getEntriesByType: { [READ]: { supported: ["16.7.0"] } },
|
|
16
|
+
mark: { [READ]: { supported: ["8.5.0"] } },
|
|
17
|
+
markResourceTiming: { [READ]: { supported: ["8.2.0", "16.17.0"] } },
|
|
18
|
+
measure: { [READ]: { supported: ["8.5.0"] } },
|
|
19
|
+
nodeTiming: {
|
|
20
|
+
[READ]: { supported: ["8.5.0"] },
|
|
21
|
+
bootstrapComplete: { [READ]: { supported: ["8.5.0"] } },
|
|
22
|
+
environment: { [READ]: { supported: ["8.5.0"] } },
|
|
23
|
+
idleTime: { [READ]: { supported: ["14.10.0", "12.19.0"] } },
|
|
24
|
+
loopExit: { [READ]: { supported: ["8.5.0"] } },
|
|
25
|
+
loopStart: { [READ]: { supported: ["8.5.0"] } },
|
|
26
|
+
nodeStart: { [READ]: { supported: ["8.5.0"] } },
|
|
27
|
+
uvMetricsInfo: { [READ]: { supported: ["22.8.0"] } },
|
|
28
|
+
v8Start: { [READ]: { supported: ["8.5.0"] } },
|
|
29
|
+
},
|
|
30
|
+
now: { [READ]: { supported: ["8.5.0"] } },
|
|
31
|
+
onresourcetimingbufferfull: { [READ]: { supported: ["18.8.0"] } },
|
|
32
|
+
setResourceTimingBufferSize: { [READ]: { supported: ["18.8.0"] } },
|
|
33
|
+
timeOrigin: { [READ]: { supported: ["8.5.0"] } },
|
|
34
|
+
timerify: { [READ]: { supported: ["8.5.0"] } },
|
|
35
|
+
toJSON: { [READ]: { supported: ["16.1.0"] } },
|
|
36
|
+
},
|
|
8
37
|
createHistogram: { [READ]: { supported: ["15.9.0", "14.18.0"] } },
|
|
9
38
|
monitorEventLoopDelay: { [READ]: { supported: ["11.10.0"] } },
|
|
10
39
|
PerformanceEntry: { [READ]: { supported: ["8.5.0"] } },
|
|
@@ -16,7 +45,7 @@ const perf_hooks = {
|
|
|
16
45
|
PerformanceObserver: { [READ]: { supported: ["8.5.0"] } },
|
|
17
46
|
PerformanceObserverEntryList: { [READ]: { supported: ["8.5.0"] } },
|
|
18
47
|
Histogram: { [READ]: { supported: ["11.10.0"] } },
|
|
19
|
-
IntervalHistogram: { [READ]: { supported: ["
|
|
48
|
+
IntervalHistogram: { [READ]: { supported: ["11.10.0"] } },
|
|
20
49
|
RecordableHistogram: { [READ]: { supported: ["15.9.0", "14.18.0"] } },
|
|
21
50
|
}
|
|
22
51
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict"
|
|
2
|
+
|
|
3
|
+
const { CALL, READ } = require("@eslint-community/eslint-utils")
|
|
4
|
+
|
|
5
|
+
/** @type {import('../types.js').SupportVersionTraceMap} */
|
|
6
|
+
const repl = {
|
|
7
|
+
start: {
|
|
8
|
+
[READ]: { supported: ["0.1.91"] },
|
|
9
|
+
},
|
|
10
|
+
writer: {
|
|
11
|
+
[READ]: { supported: ["0.1.91"] },
|
|
12
|
+
},
|
|
13
|
+
REPLServer: {
|
|
14
|
+
[READ]: { supported: ["0.1.91"] },
|
|
15
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
16
|
+
},
|
|
17
|
+
REPL_MODE_MAGIC: {
|
|
18
|
+
[READ]: {
|
|
19
|
+
supported: ["4.0.0"],
|
|
20
|
+
deprecated: ["8.0.0"],
|
|
21
|
+
// removed: ['10.0.0'],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
REPL_MODE_SLOPPY: {
|
|
25
|
+
[READ]: { supported: ["4.0.0"] },
|
|
26
|
+
},
|
|
27
|
+
REPL_MODE_STRICT: {
|
|
28
|
+
[READ]: { supported: ["4.0.0"] },
|
|
29
|
+
},
|
|
30
|
+
Recoverable: {
|
|
31
|
+
[READ]: { supported: ["6.2.0"] },
|
|
32
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
33
|
+
},
|
|
34
|
+
builtinModules: {
|
|
35
|
+
[READ]: { supported: ["14.5.0"] },
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** @type {import('../types.js').SupportVersionTraceMap} */
|
|
40
|
+
module.exports = {
|
|
41
|
+
repl: {
|
|
42
|
+
[READ]: { supported: ["0.1.91"] },
|
|
43
|
+
...repl,
|
|
44
|
+
},
|
|
45
|
+
"node:repl": {
|
|
46
|
+
[READ]: { supported: ["14.13.1", "12.20.0"] },
|
|
47
|
+
...repl,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
@@ -45,6 +45,7 @@ const Stream = {
|
|
|
45
45
|
finished: { [READ]: { supported: ["10.0.0"] } },
|
|
46
46
|
pipeline: { [READ]: { supported: ["10.0.0"] } },
|
|
47
47
|
compose: { [READ]: { supported: ["16.9.0"] } },
|
|
48
|
+
duplexPair: { [READ]: { supported: ["22.6.0", "20.17.0"] } },
|
|
48
49
|
|
|
49
50
|
Readable,
|
|
50
51
|
Writable,
|
|
@@ -88,6 +88,7 @@ const util = {
|
|
|
88
88
|
deprecate: { [READ]: { supported: ["0.8.0"] } },
|
|
89
89
|
format: { [READ]: { supported: ["0.5.3"] } },
|
|
90
90
|
formatWithOptions: { [READ]: { supported: ["10.0.0"] } },
|
|
91
|
+
getCallSite: { [READ]: { supported: ["22.9.0"] } },
|
|
91
92
|
getSystemErrorName: { [READ]: { supported: ["9.7.0", "8.12.0"] } },
|
|
92
93
|
getSystemErrorMap: { [READ]: { supported: ["16.0.0", "14.17.0"] } },
|
|
93
94
|
inherits: { [READ]: { supported: ["0.3.0"] } },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict"
|
|
2
2
|
|
|
3
|
-
const { READ } = require("@eslint-community/eslint-utils")
|
|
3
|
+
const { CALL, READ } = require("@eslint-community/eslint-utils")
|
|
4
4
|
|
|
5
5
|
/** @type {import('../types.js').SupportVersionTraceMap} */
|
|
6
6
|
const zlib = {
|
|
@@ -33,15 +33,42 @@ const zlib = {
|
|
|
33
33
|
inflateRawSync: { [READ]: { supported: ["0.11.12"] } },
|
|
34
34
|
unzip: { [READ]: { supported: ["0.6.0"] } },
|
|
35
35
|
unzipSync: { [READ]: { supported: ["0.11.12"] } },
|
|
36
|
-
BrotliCompress: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
BrotliCompress: {
|
|
37
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
38
|
+
[READ]: { supported: ["11.7.0", "10.16.0"] },
|
|
39
|
+
},
|
|
40
|
+
BrotliDecompress: {
|
|
41
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
42
|
+
[READ]: { supported: ["11.7.0", "10.16.0"] },
|
|
43
|
+
},
|
|
44
|
+
Deflate: {
|
|
45
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
46
|
+
[READ]: { supported: ["0.5.8"] },
|
|
47
|
+
},
|
|
48
|
+
DeflateRaw: {
|
|
49
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
50
|
+
[READ]: { supported: ["0.5.8"] },
|
|
51
|
+
},
|
|
52
|
+
Gunzip: {
|
|
53
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
54
|
+
[READ]: { supported: ["0.5.8"] },
|
|
55
|
+
},
|
|
56
|
+
Gzip: {
|
|
57
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
58
|
+
[READ]: { supported: ["0.5.8"] },
|
|
59
|
+
},
|
|
60
|
+
Inflate: {
|
|
61
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
62
|
+
[READ]: { supported: ["0.5.8"] },
|
|
63
|
+
},
|
|
64
|
+
InflateRaw: {
|
|
65
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
66
|
+
[READ]: { supported: ["0.5.8"] },
|
|
67
|
+
},
|
|
68
|
+
Unzip: {
|
|
69
|
+
[CALL]: { deprecated: ["22.9.0"] },
|
|
70
|
+
[READ]: { supported: ["0.5.8"] },
|
|
71
|
+
},
|
|
45
72
|
}
|
|
46
73
|
|
|
47
74
|
/** @type {import('../types.js').SupportVersionTraceMap} */
|
|
@@ -31,6 +31,7 @@ const NodeBuiltinModules = {
|
|
|
31
31
|
...require("./node-builtins-modules/punycode.js"),
|
|
32
32
|
...require("./node-builtins-modules/querystring.js"),
|
|
33
33
|
...require("./node-builtins-modules/readline.js"),
|
|
34
|
+
...require("./node-builtins-modules/repl.js"),
|
|
34
35
|
...require("./node-builtins-modules/sea.js"),
|
|
35
36
|
...require("./node-builtins-modules/stream.js"),
|
|
36
37
|
...require("./node-builtins-modules/string_decoder.js"),
|
|
@@ -8,10 +8,17 @@ const { resolve } = require("path")
|
|
|
8
8
|
const { isBuiltin } = require("node:module")
|
|
9
9
|
const resolver = require("enhanced-resolve")
|
|
10
10
|
|
|
11
|
+
const {
|
|
12
|
+
NodeBuiltinModules,
|
|
13
|
+
} = require("../unsupported-features/node-builtins.js")
|
|
11
14
|
const isTypescript = require("./is-typescript")
|
|
12
15
|
const { getTSConfigForContext } = require("./get-tsconfig.js")
|
|
13
16
|
const getTypescriptExtensionMap = require("./get-typescript-extension-map")
|
|
14
17
|
|
|
18
|
+
const nodeBuiltinFallback = Object.keys(NodeBuiltinModules).map(
|
|
19
|
+
name => /** @type {const} */ ({ name, alias: false })
|
|
20
|
+
)
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* @overload
|
|
17
24
|
* @param {string[]} input
|
|
@@ -44,13 +51,15 @@ function getTSConfigAliases(context) {
|
|
|
44
51
|
|
|
45
52
|
const paths = tsConfig?.config?.compilerOptions?.paths
|
|
46
53
|
|
|
47
|
-
if (paths == null) {
|
|
54
|
+
if (tsConfig?.path == null || paths == null) {
|
|
48
55
|
return
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
return Object.entries(paths).map(([name, alias]) => ({
|
|
52
59
|
name: removeTrailWildcard(name),
|
|
53
|
-
alias: removeTrailWildcard(alias)
|
|
60
|
+
alias: removeTrailWildcard(alias).map(relative =>
|
|
61
|
+
resolve(tsConfig.path, "..", relative)
|
|
62
|
+
),
|
|
54
63
|
}))
|
|
55
64
|
}
|
|
56
65
|
|
|
@@ -302,6 +311,8 @@ module.exports = class ImportTarget {
|
|
|
302
311
|
|
|
303
312
|
extensionAlias,
|
|
304
313
|
alias,
|
|
314
|
+
|
|
315
|
+
fallback: nodeBuiltinFallback,
|
|
305
316
|
}
|
|
306
317
|
|
|
307
318
|
const requireResolve = resolver.create.sync(this.resolverConfig)
|