Skip to content

Commit 7dac092

Browse files
committed
repl: filter out module names that contain colon
These would otherwise result in syntax like `… node:sea = …`, which causes further problems with indefinite wait. Fixes: TypeStrong#2150
1 parent ddb05ef commit 7dac092

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/repl.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,16 @@ export function createRepl(options: CreateReplOptions = {}) {
376376
// Declare node builtins.
377377
// Skip the same builtins as `addBuiltinLibsToObject`:
378378
// those starting with _
379-
// those containing /
379+
// those containing / or :
380380
// those that already exist as globals
381381
// Intentionally suppress type errors in case @types/node does not declare any of them, and because
382382
// `declare import` is technically invalid syntax.
383383
// Avoid this when in transpileOnly, because third-party transpilers may not handle `declare import`.
384384
if (!service?.transpileOnly) {
385385
state.input += `// @ts-ignore\n${builtinModules
386386
.filter(
387-
(name) => !name.startsWith('_') && !name.includes('/') && !['console', 'module', 'process'].includes(name)
387+
(name) => (!name.startsWith('_') && !name.includes('/') && !name.includes(':')
388+
&& !['console', 'module', 'process'].includes(name))
388389
)
389390
.map((name) => `declare import ${name} = require('${name}')`)
390391
.join(';')}\n`;

0 commit comments

Comments
 (0)