diff options
author | 2023-09-29 16:34:20 -0700 | |
---|---|---|
committer | 2023-09-29 16:34:20 -0700 | |
commit | a97847a49475e774695c38cff07a71eadf608c05 (patch) | |
tree | 26867f9be2eddaa0b752189a27810ed4db6ed902 /src/bun.js/bindings/isBuiltinModule.cpp | |
parent | eddb0078b5c9ff49bf67c0f1b1c2c623f0480b77 (diff) | |
download | bun-a97847a49475e774695c38cff07a71eadf608c05.tar.gz bun-a97847a49475e774695c38cff07a71eadf608c05.tar.zst bun-a97847a49475e774695c38cff07a71eadf608c05.zip |
Implement virtual module support in `Bun.plugin` (#6167)
* Add support for `build.module` in `Bun.plugin`
* Another test
* Update docs
* Update isBuiltinModule.cpp
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com>
Diffstat (limited to 'src/bun.js/bindings/isBuiltinModule.cpp')
-rw-r--r-- | src/bun.js/bindings/isBuiltinModule.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/src/bun.js/bindings/isBuiltinModule.cpp b/src/bun.js/bindings/isBuiltinModule.cpp new file mode 100644 index 000000000..b8e69f479 --- /dev/null +++ b/src/bun.js/bindings/isBuiltinModule.cpp @@ -0,0 +1,98 @@ +#include "root.h" + +static constexpr ASCIILiteral builtinModuleNamesSortedLength[] = { + "fs"_s, + "os"_s, + "v8"_s, + "vm"_s, + "ws"_s, + "bun"_s, + "dns"_s, + "net"_s, + "sys"_s, + "tls"_s, + "tty"_s, + "url"_s, + "http"_s, + "path"_s, + "repl"_s, + "util"_s, + "wasi"_s, + "zlib"_s, + "dgram"_s, + "http2"_s, + "https"_s, + "assert"_s, + "buffer"_s, + "crypto"_s, + "domain"_s, + "events"_s, + "module"_s, + "stream"_s, + "timers"_s, + "undici"_s, + "bun:ffi"_s, + "bun:jsc"_s, + "cluster"_s, + "console"_s, + "process"_s, + "bun:wrap"_s, + "punycode"_s, + "bun:test"_s, + "bun:main"_s, + "readline"_s, + "_tls_wrap"_s, + "constants"_s, + "inspector"_s, + "bun:sqlite"_s, + "path/posix"_s, + "path/win32"_s, + "perf_hooks"_s, + "stream/web"_s, + "util/types"_s, + "_http_agent"_s, + "_tls_common"_s, + "async_hooks"_s, + "detect-libc"_s, + "fs/promises"_s, + "querystring"_s, + "_http_client"_s, + "_http_common"_s, + "_http_server"_s, + "_stream_wrap"_s, + "dns/promises"_s, + "trace_events"_s, + "assert/strict"_s, + "child_process"_s, + "_http_incoming"_s, + "_http_outgoing"_s, + "_stream_duplex"_s, + "string_decoder"_s, + "worker_threads"_s, + "stream/promises"_s, + "timers/promises"_s, + "_stream_readable"_s, + "_stream_writable"_s, + "stream/consumers"_s, + "_stream_transform"_s, + "readline/promises"_s, + "inspector/promises"_s, + "_stream_passthrough"_s, + "diagnostics_channel"_s, +}; + +namespace Bun { + +bool isBuiltinModule(const String &namePossiblyWithNodePrefix) { + String name = namePossiblyWithNodePrefix; + if (name.startsWith("node:"_s)) + name = name.substringSharingImpl(5); + + for (auto &builtinModule : builtinModuleNamesSortedLength) { + if (name == builtinModule) + return true; + } + return false; +} + +} // namespace Bun
\ No newline at end of file |