WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,16 @@ export function createRepl(options: CreateReplOptions = {}) {
// Declare node builtins.
// Skip the same builtins as `addBuiltinLibsToObject`:
// those starting with _
// those containing /
// those containing / or :
// those that already exist as globals
// Intentionally suppress type errors in case @types/node does not declare any of them, and because
// `declare import` is technically invalid syntax.
// Avoid this when in transpileOnly, because third-party transpilers may not handle `declare import`.
if (!service?.transpileOnly) {
state.input += `// @ts-ignore\n${builtinModules
.filter(
(name) => !name.startsWith('_') && !name.includes('/') && !['console', 'module', 'process'].includes(name)
(name) => !(name.startsWith('_') || name.includes('/') || name.includes(':')
|| ['console', 'module', 'process'].includes(name))
)
.map((name) => `declare import ${name} = require('${name}')`)
.join(';')}\n`;
Expand Down