diff --git a/crates/oxc_formatter/src/ir_transform/sort_imports/compute_metadata.rs b/crates/oxc_formatter/src/ir_transform/sort_imports/compute_metadata.rs index c4b6028015eb3..e03a7d466fe4a 100644 --- a/crates/oxc_formatter/src/ir_transform/sort_imports/compute_metadata.rs +++ b/crates/oxc_formatter/src/ir_transform/sort_imports/compute_metadata.rs @@ -310,14 +310,32 @@ fn is_style(source: &str) -> bool { .is_some_and(|ext| STYLE_EXTENSIONS.contains(ext)) } +/// Node.js builtin modules list generated by `require('node:module').builtinModules` static NODE_BUILTINS: phf::Set<&'static str> = phf_set! { - "assert", "async_hooks", "buffer", "child_process", "cluster", "console", - "constants", "crypto", "dgram", "diagnostics_channel", "dns", "domain", - "events", "fs", "http", "http2", "https", "inspector", "module", "net", - "os", "path", "perf_hooks", "process", "punycode", "querystring", - "readline", "repl", "stream", "string_decoder", "sys", "timers", "tls", - "trace_events", "tty", "url", "util", "v8", "vm", "wasi", "worker_threads", - "zlib", + "_http_agent", "_http_client", "_http_common", + "_http_incoming", "_http_outgoing", "_http_server", + "_stream_duplex", "_stream_passthrough", "_stream_readable", + "_stream_transform", "_stream_wrap", "_stream_writable", + "_tls_common", "_tls_wrap", "assert", + "assert/strict", "async_hooks", "buffer", + "child_process", "cluster", "console", + "constants", "crypto", "dgram", + "diagnostics_channel", "dns", "dns/promises", + "domain", "events", "fs", + "fs/promises", "http", "http2", + "https", "inspector", "inspector/promises", + "module", "net", "os", + "path", "path/posix", "path/win32", + "perf_hooks", "process", "punycode", + "querystring", "readline", "readline/promises", + "repl", "stream", "stream/consumers", + "stream/promises", "stream/web", "string_decoder", + "sys", "timers", "timers/promises", + "tls", "trace_events", "tty", + "url", "util", "util/types", + "v8", "vm", "wasi", + "worker_threads", "zlib", "node:sea", + "node:sqlite", "node:test", "node:test/reporters" }; /// Check if an import source is a Node.js or Bun builtin module.