diff options
author | 2021-05-27 14:38:28 -0700 | |
---|---|---|
committer | 2021-05-27 14:38:28 -0700 | |
commit | 81f3a52e8958df0f65450832c10e94c0ada21858 (patch) | |
tree | b0ed47d2f97135e581f264399b0509210a1c23e5 /src | |
parent | feb7adcd087f1999daad4058dc7864aed6fc4796 (diff) | |
download | bun-81f3a52e8958df0f65450832c10e94c0ada21858.tar.gz bun-81f3a52e8958df0f65450832c10e94c0ada21858.tar.zst bun-81f3a52e8958df0f65450832c10e94c0ada21858.zip |
Error message for using node builtins outside of platform == .node
Former-commit-id: 3bcce51fa4d740b1e6ddf465919ec987f995e402
Diffstat (limited to 'src')
-rw-r--r-- | src/options.zig | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/src/options.zig b/src/options.zig index 33f13209c..afa45e039 100644 --- a/src/options.zig +++ b/src/options.zig @@ -43,6 +43,10 @@ pub const ExternalModules = struct { suffix: string, }; + pub fn isNodeBuiltin(str: string) bool { + return NodeBuiltinsMap.has(str); + } + pub fn init( allocator: *std.mem.Allocator, fs: *Fs.FileSystem.Implementation, @@ -156,6 +160,65 @@ pub const ExternalModules = struct { "worker_threads", "zlib", }; + + pub const NodeBuiltinsMap = std.ComptimeStringMap(bool, .{ + .{ "_http_agent", true }, + .{ "_http_client", true }, + .{ "_http_common", true }, + .{ "_http_incoming", true }, + .{ "_http_outgoing", true }, + .{ "_http_server", true }, + .{ "_stream_duplex", true }, + .{ "_stream_passthrough", true }, + .{ "_stream_readable", true }, + .{ "_stream_transform", true }, + .{ "_stream_wrap", true }, + .{ "_stream_writable", true }, + .{ "_tls_common", true }, + .{ "_tls_wrap", true }, + .{ "assert", true }, + .{ "async_hooks", true }, + .{ "buffer", true }, + .{ "child_process", true }, + .{ "cluster", true }, + .{ "console", true }, + .{ "constants", true }, + .{ "crypto", true }, + .{ "dgram", true }, + .{ "diagnostics_channel", true }, + .{ "dns", true }, + .{ "domain", true }, + .{ "events", true }, + .{ "fs", true }, + .{ "http", true }, + .{ "http2", true }, + .{ "https", true }, + .{ "inspector", true }, + .{ "module", true }, + .{ "net", true }, + .{ "os", true }, + .{ "path", true }, + .{ "perf_hooks", true }, + .{ "process", true }, + .{ "punycode", true }, + .{ "querystring", true }, + .{ "readline", true }, + .{ "repl", true }, + .{ "stream", true }, + .{ "string_decoder", true }, + .{ "sys", true }, + .{ "timers", true }, + .{ "tls", true }, + .{ "trace_events", true }, + .{ "tty", true }, + .{ "url", true }, + .{ "util", true }, + .{ "v8", true }, + .{ "vm", true }, + .{ "wasi", true }, + .{ "worker_threads", true }, + .{ "zlib", true }, + }); }; pub const ModuleType = enum { @@ -472,7 +535,7 @@ pub const BundleOptions = struct { resolved_defines, ), .loaders = loaders, - .output_dir = try fs.joinAlloc(allocator, &output_dir_parts), + .output_dir = try fs.absAlloc(allocator, &output_dir_parts), .platform = Platform.from(transform.platform), .write = transform.write orelse false, .external = undefined, |