Skip to content

Commit

Permalink
fix(node): update list of builtin node modules, add missing export to…
Browse files Browse the repository at this point in the history
… _http_common (#27294)

Fixes #27289

We exported these but forgot to add them to the list of builtins used by
the resolver, so we weren't resolving bare imports of some modules (e.g.
`"_http_common"`)

Also adds a missing export of `HTTPParser` from `_http_common`
  • Loading branch information
nathanwhit authored Dec 9, 2024
1 parent 883abfa commit 44d7697
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cli/lsp/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,13 +743,16 @@ fn get_node_completions(
}
let items = SUPPORTED_BUILTIN_NODE_MODULES
.iter()
.map(|name| {
.filter_map(|name| {
if name.starts_with('_') {
return None;
}
let specifier = format!("node:{}", name);
let text_edit = Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
range: *range,
new_text: specifier.clone(),
}));
lsp::CompletionItem {
Some(lsp::CompletionItem {
label: specifier,
kind: Some(lsp::CompletionItemKind::FILE),
detail: Some("(node)".to_string()),
Expand All @@ -758,7 +761,7 @@ fn get_node_completions(
IMPORT_COMMIT_CHARS.iter().map(|&c| c.into()).collect(),
),
..Default::default()
}
})
})
.collect();
Some(CompletionList {
Expand Down
11 changes: 11 additions & 0 deletions ext/node/polyfill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ macro_rules! generate_builtin_node_module_lists {

// NOTE(bartlomieju): keep this list in sync with `ext/node/polyfills/01_require.js`
generate_builtin_node_module_lists! {
"_http_agent",
"_http_common",
"_http_outgoing",
"_http_server",
"_stream_duplex",
"_stream_passthrough",
"_stream_readable",
"_stream_transform",
"_stream_writable",
"_tls_common",
"_tls_wrap",
"assert",
"assert/strict",
"async_hooks",
Expand Down
4 changes: 4 additions & 0 deletions ext/node/polyfills/_http_common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
SafeRegExp,
Symbol,
} = primordials;
import { HTTPParser } from "ext:deno_node/internal_binding/http_parser.ts";

export const CRLF = "\r\n";
export const kIncomingMessage = Symbol("IncomingMessage");
Expand Down Expand Up @@ -79,6 +80,8 @@ export {
checkIsHttpToken as _checkIsHttpToken,
};

export { HTTPParser };

export default {
_checkInvalidHeaderChar: checkInvalidHeaderChar,
_checkIsHttpToken: checkIsHttpToken,
Expand All @@ -87,4 +90,5 @@ export default {
continueExpression,
kIncomingMessage,
methods,
HTTPParser,
};

0 comments on commit 44d7697

Please sign in to comment.