diff options
author | 2021-08-15 22:17:20 -0700 | |
---|---|---|
committer | 2021-08-15 22:17:20 -0700 | |
commit | 23357806183eff94632915239f7b98a4046eb3d7 (patch) | |
tree | efdd9eae103bd29f2a914eccb1f4c2e0009d3fa1 /src | |
parent | bd11b04c18ef0ab5ba05b043829a729f45e53d5e (diff) | |
download | bun-23357806183eff94632915239f7b98a4046eb3d7.tar.gz bun-23357806183eff94632915239f7b98a4046eb3d7.tar.zst bun-23357806183eff94632915239f7b98a4046eb3d7.zip |
rename to bun
Former-commit-id: f982fc85fac3f0120e1851ad4027dd8413216439
Diffstat (limited to 'src')
27 files changed, 158 insertions, 158 deletions
diff --git a/src/api/schema.d.ts b/src/api/schema.d.ts index 4e652ae81..021f20c3b 100644 --- a/src/api/schema.d.ts +++ b/src/api/schema.d.ts @@ -56,15 +56,15 @@ type uint32 = number; export enum Platform { browser = 1, node = 2, - speedy = 3 + bun = 3 } export const PlatformKeys = { 1: "browser", browser: "browser", 2: "node", node: "node", - 3: "speedy", - speedy: "speedy" + 3: "bun", + bun: "bun" } export enum JSXRuntime { automatic = 1, diff --git a/src/api/schema.js b/src/api/schema.js index 5149c1ffd..b5768117e 100644 --- a/src/api/schema.js +++ b/src/api/schema.js @@ -56,15 +56,15 @@ const Platform = { "3": 3, "browser": 1, "node": 2, - "speedy": 3 + "bun": 3 }; const PlatformKeys = { "1": "browser", "2": "node", - "3": "speedy", + "3": "bun", "browser": "browser", "node": "node", - "speedy": "speedy" + "bun": "bun" }; const JSXRuntime = { "1": 1, diff --git a/src/api/schema.peechy b/src/api/schema.peechy index 863c69d6a..4d2baaaef 100644 --- a/src/api/schema.peechy +++ b/src/api/schema.peechy @@ -20,7 +20,7 @@ smol ResolveMode { smol Platform { browser = 1; node = 2; - speedy = 3; + bun = 3; } smol JSXRuntime { diff --git a/src/api/schema.zig b/src/api/schema.zig index 60eceb1ad..56feccb75 100644 --- a/src/api/schema.zig +++ b/src/api/schema.zig @@ -353,8 +353,8 @@ _none, /// node node, - /// speedy - speedy, + /// bun + bun, _, diff --git a/src/bundler.zig b/src/bundler.zig index 0e731eeab..bf78c760d 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -141,7 +141,6 @@ pub const ServerEntryPoint = struct { bundler: *BundlerType, original_path: Fs.PathName, name: string, - ) !void { // This is *extremely* naive. @@ -594,10 +593,10 @@ pub fn NewBundler(cache_files: bool) type { } } - // The Speedy Bundle Format + // The Bun Bundle Format // Your entire node_modules folder in a single compact file designed for web browsers. // A binary JavaScript bundle format prioritizing bundle time and serialization/deserialization time - pub const magic_bytes = "#!/usr/bin/env speedy\n\n"; + pub const magic_bytes = "#!/usr/bin/env bun\n\n"; // This makes it possible to do ./path-to-bundle on posix systems you can see the raw JS contents // https://en.wikipedia.org/wiki/Magic_number_(programming)#In_files // Immediately after the magic bytes, the next character is a uint32 followed by a newline @@ -1815,10 +1814,10 @@ pub fn NewBundler(cache_files: bool) type { opts.enable_bundling = false; opts.transform_require_to_import = true; opts.can_import_from_bundle = bundler.options.node_modules_bundle != null; - opts.features.hot_module_reloading = bundler.options.hot_module_reloading and bundler.options.platform != .speedy; // and client_entry_point_ == null; + opts.features.hot_module_reloading = bundler.options.hot_module_reloading and bundler.options.platform != .bun; // and client_entry_point_ == null; opts.features.react_fast_refresh = opts.features.hot_module_reloading and jsx.parse and bundler.options.jsx.supports_fast_refresh; opts.filepath_hash_for_hmr = file_hash orelse 0; - opts.warn_about_unbundled_modules = bundler.options.platform != .speedy; + opts.warn_about_unbundled_modules = bundler.options.platform != .bun; const value = (bundler.resolver.caches.js.parse(allocator, opts, bundler.options.define, bundler.log, &source) catch null) orelse return null; return ParseResult{ .ast = value, diff --git a/src/cli.zig b/src/cli.zig index 3158f421c..5c1be01de 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -17,7 +17,7 @@ const panicky = @import("panic_handler.zig"); const sync = @import("./sync.zig"); const Api = @import("api/schema.zig").Api; const resolve_path = @import("./resolver/resolve_path.zig"); -const configureTransformOptionsForSpeedy = @import("./javascript/jsc/config.zig").configureTransformOptionsForSpeedy; +const configureTransformOptionsForBun = @import("./javascript/jsc/config.zig").configureTransformOptionsForBun; const clap = @import("clap"); const bundler = @import("bundler.zig"); @@ -132,8 +132,8 @@ pub const Cli = struct { clap.parseParam("--main-fields <STR>... Main fields to lookup in package.json. Defaults to --platform dependent") catch unreachable, clap.parseParam("--scan Instead of bundling or transpiling, print a list of every file imported by an entry point, recursively") catch unreachable, clap.parseParam("--new-jsb Generate a new node_modules.jsb file from node_modules and entry point(s)") catch unreachable, - clap.parseParam("--jsb <STR> Use a Speedy JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, - clap.parseParam("--jsb-for-server <STR> Use a server-only Speedy JavaScript Bundle (default: \"./node_modules.server.jsb\" if exists)") catch unreachable, + clap.parseParam("--jsb <STR> Use a Bun JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, + clap.parseParam("--jsb-for-server <STR> Use a server-only Bun JavaScript Bundle (default: \"./node_modules.server.jsb\" if exists)") catch unreachable, clap.parseParam("--use <STR> Use a JavaScript framework (package name or path to package)") catch unreachable, clap.parseParam("--production This sets the defaults to production. Applies to jsx & framework") catch unreachable, @@ -446,7 +446,7 @@ pub const Cli = struct { var server_bundler = try bundler.ServeBundler.init( allocator_, logs, - try configureTransformOptionsForSpeedy(allocator_, transform_args), + try configureTransformOptionsForBun(allocator_, transform_args), null, env_loader_, ); diff --git a/src/feature_flags.zig b/src/feature_flags.zig index be216e69c..52d2b2fcd 100644 --- a/src/feature_flags.zig +++ b/src/feature_flags.zig @@ -42,7 +42,7 @@ pub const react_specific_warnings = true; // I suspect it's like 3 undefined memory issues. // This was the command I ran to reproduce it: // for i in (seq 1000) -// command ../../build/debug/macos-x86_64/esdev --use=./nexty2 --new-jsb > /dev/null +// command ../../build/debug/macos-x86_64/bun --use=./nexty2 --new-jsb > /dev/null // end // It only happens 1 out of every N times, probably like 50. pub const parallel_jsb = false; diff --git a/src/hash_map.zig b/src/hash_map.zig index 73d3d9f98..1c5d86900 100644 --- a/src/hash_map.zig +++ b/src/hash_map.zig @@ -69,18 +69,18 @@ pub fn StringHashMapUnmanaged(comptime V: type) type { return HashMapUnmanaged([]const u8, V, hashString, eqlString, default_max_load_percentage); } -// ❯ hyperfine "./esdev.stringEqlNoPtrCheck --resolve=dev --cwd /Users/jarred/Code/esdev/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/esdev/bench/rome/src/out --origin=https://hello.com/" "./esdev-fd-rel-hash --resolve=dev --cwd /Users/jarred/Code/esdev/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/esdev/bench/rome/src/out --origin=https://hello.com/" --min-runs=50 -// Benchmark #1: ./esdev.stringEqlNoPtrCheck --resolve=dev --cwd /Users/jarred/Code/esdev/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/esdev/bench/rome/src/out --origin=https://hello.com/ +// ❯ hyperfine "./bun.stringEqlNoPtrCheck --resolve=dev --cwd /Users/jarred/Code/bun/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/bun/bench/rome/src/out --origin=https://hello.com/" "./bun-fd-rel-hash --resolve=dev --cwd /Users/jarred/Code/bun/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/bun/bench/rome/src/out --origin=https://hello.com/" --min-runs=50 +// Benchmark #1: ./bun.stringEqlNoPtrCheck --resolve=dev --cwd /Users/jarred/Code/bun/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/bun/bench/rome/src/out --origin=https://hello.com/ // Time (mean ± σ): 251.5 ms ± 7.8 ms [User: 110.0 ms, System: 135.7 ms] // Range (min … max): 239.0 ms … 281.1 ms 50 runs -// Benchmark #2: ./esdev-fd-rel-hash --resolve=dev --cwd /Users/jarred/Code/esdev/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/esdev/bench/rome/src/out --origin=https://hello.com/ +// Benchmark #2: ./bun-fd-rel-hash --resolve=dev --cwd /Users/jarred/Code/bun/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/bun/bench/rome/src/out --origin=https://hello.com/ // Time (mean ± σ): 249.3 ms ± 8.3 ms [User: 110.8 ms, System: 134.0 ms] // Range (min … max): 239.8 ms … 288.7 ms 50 runs // Summary -// './esdev-fd-rel-hash --resolve=dev --cwd /Users/jarred/Code/esdev/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/esdev/bench/rome/src/out --origin=https://hello.com/' ran -// 1.01 ± 0.05 times faster than './esdev.stringEqlNoPtrCheck --resolve=dev --cwd /Users/jarred/Code/esdev/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/esdev/bench/rome/src/out --origin=https://hello.com/' +// './bun-fd-rel-hash --resolve=dev --cwd /Users/jarred/Code/bun/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/bun/bench/rome/src/out --origin=https://hello.com/' ran +// 1.01 ± 0.05 times faster than './bun.stringEqlNoPtrCheck --resolve=dev --cwd /Users/jarred/Code/bun/bench/rome/src entry --platform=node --outdir=/Users/jarred/Code/bun/bench/rome/src/out --origin=https://hello.com/' pub fn eqlString(a: []const u8, b: []const u8) bool { return mem.eql(u8, a, b); } diff --git a/src/http.zig b/src/http.zig index 4a528626c..da7ebabda 100644 --- a/src/http.zig +++ b/src/http.zig @@ -131,7 +131,7 @@ pub const RequestContext = struct { match_file_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined, res_headers_count: usize = 0, - pub const bundle_prefix = "__speedy"; + pub const bundle_prefix = "__bun"; pub fn getFullURL(this: *RequestContext) [:0]const u8 { if (this.full_url.len == 0) { @@ -838,7 +838,7 @@ pub const RequestContext = struct { js_ast.Stmt.Data.Store.reset(); js_ast.Expr.Data.Store.reset(); - JavaScript.Wundle.flushCSSImports(); + JavaScript.Bun.flushCSSImports(); vm.flush(); try runLoop(vm); @@ -853,7 +853,7 @@ pub const RequestContext = struct { std.debug.assert(ZigGlobalObject.resetModuleRegistryMap(vm.global, module_map)); js_ast.Stmt.Data.Store.reset(); js_ast.Expr.Data.Store.reset(); - JavaScript.Wundle.flushCSSImports(); + JavaScript.Bun.flushCSSImports(); } var handler: *JavaScriptHandler = try channel.readItem(); @@ -1070,7 +1070,7 @@ pub const RequestContext = struct { ctx.appendHeader("Connection", "Upgrade"); ctx.appendHeader("Upgrade", "websocket"); ctx.appendHeader("Sec-WebSocket-Accept", key); - ctx.appendHeader("Sec-WebSocket-Protocol", "speedy-hmr"); + ctx.appendHeader("Sec-WebSocket-Protocol", "bun-hmr"); try ctx.writeStatus(101); try ctx.flushHeaders(); Output.println("101 - Websocket connected.", .{}); @@ -1808,7 +1808,7 @@ pub const Server = struct { try listener.listen(1280); const addr = try listener.getLocalAddress(); - Output.prettyln("<r>Started Speedy at <b><cyan>http://{s}<r>", .{addr}); + Output.prettyln("<r>Started Bun at <b><cyan>http://{s}<r>", .{addr}); Output.flush(); // var listener_handle = try std.os.kqueue(); // var change_list = std.mem.zeroes([2]os.Kevent); diff --git a/src/javascript/jsc/api/router.zig b/src/javascript/jsc/api/router.zig index 647dee2ea..143f8abb9 100644 --- a/src/javascript/jsc/api/router.zig +++ b/src/javascript/jsc/api/router.zig @@ -368,7 +368,7 @@ pub fn getScriptSrcString( // instead, we just store a boolean saying whether we should generate this whenever the script is requested // this is kind of bad. we should consider instead a way to inline the contents of the script. if (client_framework_enabled) { - JavaScript.Wundle.getPublicPath( + JavaScript.Bun.getPublicPath( Bundler.ClientEntryPoint.generateEntryPointPath( &entry_point_tempbuf, Fs.PathName.init(file_path), @@ -377,7 +377,7 @@ pub fn getScriptSrcString( writer, ); } else { - JavaScript.Wundle.getPublicPath(file_path, ScriptSrcStream.Writer, writer); + JavaScript.Bun.getPublicPath(file_path, ScriptSrcStream.Writer, writer); } } diff --git a/src/javascript/jsc/bindings/DefaultGlobal.cpp b/src/javascript/jsc/bindings/DefaultGlobal.cpp index 9ca83d267..d143835aa 100644 --- a/src/javascript/jsc/bindings/DefaultGlobal.cpp +++ b/src/javascript/jsc/bindings/DefaultGlobal.cpp @@ -1,6 +1,6 @@ -#include "root.h" #include "DefaultGlobal.h" +#include "root.h" #include <wtf/text/AtomStringImpl.h> @@ -25,26 +25,19 @@ #include "JSCInlines.h" - - class Script; namespace JSC { - class Identifier; - class JSObject; - class JSString; - -} - +class Identifier; +class JSObject; +class JSString; +} // namespace JSC +namespace Bun { - -namespace Wundle { - - - -// const ClassInfo DefaultGlobal::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(DefaultGlobal) }; -// const GlobalObjectMethodTable DefaultGlobal::s_globalObjectMethodTable = { +// const ClassInfo DefaultGlobal::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, +// CREATE_METHOD_TABLE(DefaultGlobal) }; const GlobalObjectMethodTable +// DefaultGlobal::s_globalObjectMethodTable = { // &supportsRichSourceInfo, // &shouldInterruptScript, // &javaScriptRuntimeFlags, @@ -64,13 +57,18 @@ namespace Wundle { // nullptr, // instantiateStreaming // }; - -// void DefaultGlobal::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception* exception) {} -// JSC::Identifier DefaultGlobal::moduleLoaderResolve(JSGlobalObject* globalObject, JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue val) { -// JSInternalPromise* DefaultGlobal::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString* specifierValue, JSValue, const SourceOrigin& sourceOrigin) { -// JSInternalPromise* DefaultGlobal::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader*, JSValue key, JSValue, JSValue) { -// JSC::JSObject* DefaultGlobal::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject, JSModuleLoader*loader, JSValue key, JSModuleRecord* record, JSValue value) { -// JSValue DefaultGlobal::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue resumeMode) { +// void DefaultGlobal::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception* +// exception) {} JSC::Identifier DefaultGlobal::moduleLoaderResolve(JSGlobalObject* globalObject, +// JSModuleLoader* loader, JSValue key, JSValue referrer, JSValue val) { JSInternalPromise* +// DefaultGlobal::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString* +// specifierValue, JSValue, const SourceOrigin& sourceOrigin) { JSInternalPromise* +// DefaultGlobal::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader*, JSValue key, +// JSValue, JSValue) { JSC::JSObject* +// DefaultGlobal::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject, +// JSModuleLoader*loader, JSValue key, JSModuleRecord* record, JSValue value) { JSValue +// DefaultGlobal::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader, +// JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue +// resumeMode) { // using namespace JSC; -}; +}; // namespace Bun diff --git a/src/javascript/jsc/bindings/DefaultGlobal.h b/src/javascript/jsc/bindings/DefaultGlobal.h index 6bc5eb0c9..ae174e049 100644 --- a/src/javascript/jsc/bindings/DefaultGlobal.h +++ b/src/javascript/jsc/bindings/DefaultGlobal.h @@ -1,65 +1,64 @@ -#pragma once +#pragma once namespace JSC { - class Structure; - class Identifier; - -} +class Structure; +class Identifier; +} // namespace JSC + +#include "JSCInlines.h" #include "root.h" #include <JavaScriptCore/JSGlobalObject.h> -#include "JSCInlines.h" using namespace JSC; - -namespace Wundle { +namespace Bun { class Script; class DefaultGlobal final : public JSC::JSGlobalObject { -public: - using Base = JSC::JSGlobalObject; - - DECLARE_EXPORT_INFO; - static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable; - - static constexpr bool needsDestruction = true; - template<typename CellType, SubspaceAccess mode> - static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return vm.apiGlobalObjectSpace<mode>(); - } - - static DefaultGlobal* create(JSC::VM& vm, JSC::Structure* structure) - { - auto* object = new (NotNull, allocateCell<DefaultGlobal>(vm.heap)) DefaultGlobal(vm, structure); - object->finishCreation(vm); - return object; - } - - static Structure* createStructure(JSC::VM& vm, JSC::JSValue prototype) - { - auto* result = Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info()); - result->setTransitionWatchpointIsLikelyToBeFired(true); - return result; - } - - static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, Exception*); - - static JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, JSModuleLoader*, JSC::JSString* moduleNameValue, JSValue parameters, const SourceOrigin&); - static JSC::Identifier moduleLoaderResolve(JSGlobalObject*, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue); - static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue); - static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, JSModuleLoader*, JSValue, JSModuleRecord*, JSValue); - static JSValue moduleLoaderEvaluate(JSGlobalObject*, JSModuleLoader*, JSValue, JSValue, JSValue, JSValue, JSValue); - - -private: - DefaultGlobal(JSC::VM& vm, JSC::Structure* structure) - : Base(vm, structure, &s_globalObjectMethodTable) - { } + public: + using Base = JSC::JSGlobalObject; + + DECLARE_EXPORT_INFO; + static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable; + + static constexpr bool needsDestruction = true; + template <typename CellType, SubspaceAccess mode> + static JSC::IsoSubspace *subspaceFor(JSC::VM &vm) { + return vm.apiGlobalObjectSpace<mode>(); + } + + static DefaultGlobal *create(JSC::VM &vm, JSC::Structure *structure) { + auto *object = new (NotNull, allocateCell<DefaultGlobal>(vm.heap)) DefaultGlobal(vm, structure); + object->finishCreation(vm); + return object; + } + + static Structure *createStructure(JSC::VM &vm, JSC::JSValue prototype) { + auto *result = + Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info()); + result->setTransitionWatchpointIsLikelyToBeFired(true); + return result; + } + + static void reportUncaughtExceptionAtEventLoop(JSGlobalObject *, Exception *); + + static JSInternalPromise *moduleLoaderImportModule(JSGlobalObject *, JSModuleLoader *, + JSC::JSString *moduleNameValue, + JSValue parameters, const SourceOrigin &); + static JSC::Identifier moduleLoaderResolve(JSGlobalObject *, JSModuleLoader *, JSValue keyValue, + JSValue referrerValue, JSValue); + static JSInternalPromise *moduleLoaderFetch(JSGlobalObject *, JSModuleLoader *, JSValue, JSValue, + JSValue); + static JSC::JSObject *moduleLoaderCreateImportMetaProperties(JSGlobalObject *, JSModuleLoader *, + JSValue, JSModuleRecord *, JSValue); + static JSValue moduleLoaderEvaluate(JSGlobalObject *, JSModuleLoader *, JSValue, JSValue, JSValue, + JSValue, JSValue); + + private: + DefaultGlobal(JSC::VM &vm, JSC::Structure *structure) + : Base(vm, structure, &s_globalObjectMethodTable) {} }; - -} - +} // namespace Bun diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index 45a68954e..762f8b5cc 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -340,7 +340,7 @@ JSC::JSObject *GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObje // metaProperties->putDirect(vm, Identifier::fromString(vm, "resolve"), // globalObject->globalThis() - // ->get(vm, Identifier::fromString("Wundle")) + // ->get(vm, Identifier::fromString("Bun")) // .getObject() // ->get(vm, Identifier::fromString("resolve"))); ); // RETURN_IF_EXCEPTION(scope, nullptr); diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index 28e34717d..d1c76a6bb 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -937,10 +937,10 @@ fn _JSCellStub(comptime str: []const u8) type { } } -fn _Wundle(comptime str: []const u8) type { +fn _Bun(comptime str: []const u8) type { if (is_bindgen) { return opaque { - pub const name = "Wundle::" ++ str ++ ""; + pub const name = "Bun::" ++ str ++ ""; }; } else { return opaque {}; diff --git a/src/javascript/jsc/config.zig b/src/javascript/jsc/config.zig index affb1df68..2f91e433d 100644 --- a/src/javascript/jsc/config.zig +++ b/src/javascript/jsc/config.zig @@ -15,7 +15,7 @@ const http = @import("../../http.zig"); usingnamespace @import("./node_env_buf_map.zig"); -pub const DefaultSpeedyDefines = struct { +pub const DefaultBunDefines = struct { pub const Keys = struct { const window = "window"; }; @@ -24,18 +24,18 @@ pub const DefaultSpeedyDefines = struct { }; }; -pub fn configureTransformOptionsForSpeedyVM(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { +pub fn configureTransformOptionsForBunVM(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { var args = _args; // args.serve = false; args.write = false; args.resolve = Api.ResolveMode.lazy; args.generate_node_module_bundle = false; - return try configureTransformOptionsForSpeedy(allocator, args); + return try configureTransformOptionsForBun(allocator, args); } -pub fn configureTransformOptionsForSpeedy(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { +pub fn configureTransformOptionsForBun(allocator: *std.mem.Allocator, _args: Api.TransformOptions) !Api.TransformOptions { var args = _args; - args.platform = Api.Platform.speedy; + args.platform = Api.Platform.bun; return args; } diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index 29ede6112..a462515b7 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -32,10 +32,10 @@ pub const GlobalClasses = [_]type{ EventListenerMixin.addEventListener(VirtualMachine), BuildError.Class, ResolveError.Class, - Wundle.Class, + Bun.Class, }; -pub const Wundle = struct { +pub const Bun = struct { threadlocal var css_imports_list_strings: [512]ZigString = undefined; threadlocal var css_imports_list: [512]Api.StringPointer = undefined; threadlocal var css_imports_list_tail: u16 = 0; @@ -198,12 +198,12 @@ pub const Wundle = struct { pub const Class = NewClass( void, .{ - .name = "Wundle", + .name = "Bun", .read_only = true, .ts = .{ .module = .{ - .path = "speedy.js/router", - .tsdoc = "Filesystem Router supporting dynamic routes, exact routes, catch-all routes, and optional catch-all routes. Implemented in native code and only available with Speedy.js.", + .path = "bun.js/router", + .tsdoc = "Filesystem Router supporting dynamic routes, exact routes, catch-all routes, and optional catch-all routes. Implemented in native code and only available with Bun.js.", }, }, }, @@ -213,14 +213,14 @@ pub const Wundle = struct { .ts = Router.match_type_definition, }, .getImportedStyles = .{ - .rfn = Wundle.getImportedStyles, + .rfn = Bun.getImportedStyles, .ts = d.ts{ .name = "getImportedStyles", .@"return" = "string[]", }, }, .getRouteFiles = .{ - .rfn = Wundle.getRouteFiles, + .rfn = Bun.getRouteFiles, .ts = d.ts{ .name = "getRouteFiles", .@"return" = "string[]", @@ -302,7 +302,7 @@ pub const VirtualMachine = struct { const bundler = try Bundler.init( allocator, log, - try configureTransformOptionsForSpeedyVM(allocator, _args), + try configureTransformOptionsForBunVM(allocator, _args), existing_bundle, env_loader, ); @@ -322,7 +322,7 @@ pub const VirtualMachine = struct { try VirtualMachine.vm.bundler.configureFramework(false); if (_args.serve orelse false) { - VirtualMachine.vm.bundler.linker.onImportCSS = Wundle.onImportCSS; + VirtualMachine.vm.bundler.linker.onImportCSS = Bun.onImportCSS; } var global_classes: [GlobalClasses.len]js.JSClassRef = undefined; diff --git a/src/javascript/jsc/typescript.zig b/src/javascript/jsc/typescript.zig index e10df2b2f..b2273cfd9 100644 --- a/src/javascript/jsc/typescript.zig +++ b/src/javascript/jsc/typescript.zig @@ -43,14 +43,14 @@ pub fn main() anyerror!void { try index_file.writeAll( \\/// <reference no-default-lib="true" /> \\/// <reference lib="esnext" /> - \\/// <reference types="speedy.js/types/globals" /> - \\/// <reference types="speedy.js/types/modules" /> + \\/// <reference types="bun.js/types/globals" /> + \\/// <reference types="bun.js/types/modules" /> \\ ); var global_file = try dir.createFile("globals.d.ts", .{}); try global_file.writeAll( - \\// Speedy.js v + \\// Bun.js v \\ \\ ); @@ -58,7 +58,7 @@ pub fn main() anyerror!void { var module_file = try dir.createFile("modules.d.ts", .{}); try module_file.writeAll( - \\// Speedy.js v + \\// Bun.js v \\ \\ ); @@ -79,7 +79,7 @@ pub fn main() anyerror!void { inline for (modules) |decl| { comptime var module: d.ts.module = decl.module; - const basepath = comptime module.path["speedy.js/".len..]; + const basepath = comptime module.path["bun.js/".len..]; if (std.fs.path.dirname(basepath)) |dirname| { try dir.makePath(dirname); } diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index cf36c89e6..1840cd302 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -2991,7 +2991,7 @@ pub fn NewParser( // If we're auto-importing JSX and it's bundled, we use the bundled version // This means we need to transform from require(react) to react() - // unless we're building inside of speedy, then it's just normal commonjs + // unless we're building inside of bun, then it's just normal commonjs pub fn callUnbundledRequire(p: *P, require_args: []Expr) Expr { return p.callRuntime(require_args[0].loc, "__require", require_args); } @@ -14294,16 +14294,16 @@ pub fn NewParser( } // Doing this seems to yield a 1% performance improvement parsing larger files -// ❯ hyperfine "../../build/macos-x86_64/esdev node_modules/react-dom/cjs/react-dom.development.js --resolve=disable" "../../esdev.before-comptime-js-parser node_modules/react-dom/cjs/react-dom.development.js --resolve=disable" --min-runs=500 -// Benchmark #1: ../../build/macos-x86_64/esdev node_modules/react-dom/cjs/react-dom.development.js --resolve=disable +// ❯ hyperfine "../../build/macos-x86_64/bun node_modules/react-dom/cjs/react-dom.development.js --resolve=disable" "../../bun.before-comptime-js-parser node_modules/react-dom/cjs/react-dom.development.js --resolve=disable" --min-runs=500 +// Benchmark #1: ../../build/macos-x86_64/bun node_modules/react-dom/cjs/react-dom.development.js --resolve=disable // Time (mean ± σ): 25.1 ms ± 1.1 ms [User: 20.4 ms, System: 3.1 ms] // Range (min … max): 23.5 ms … 31.7 ms 500 runs -// Benchmark #2: ../../esdev.before-comptime-js-parser node_modules/react-dom/cjs/react-dom.development.js --resolve=disable +// Benchmark #2: ../../bun.before-comptime-js-parser node_modules/react-dom/cjs/react-dom.development.js --resolve=disable // Time (mean ± σ): 25.6 ms ± 1.3 ms [User: 20.9 ms, System: 3.1 ms] // Range (min … max): 24.1 ms … 39.7 ms 500 runs -// '../../build/macos-x86_64/esdev node_modules/react-dom/cjs/react-dom.development.js --resolve=disable' ran -// 1.02 ± 0.07 times faster than '../../esdev.before-comptime-js-parser node_modules/react-dom/cjs/react-dom.development.js --resolve=disable' +// '../../build/macos-x86_64/bun node_modules/react-dom/cjs/react-dom.development.js --resolve=disable' ran +// 1.02 ± 0.07 times faster than '../../bun.before-comptime-js-parser node_modules/react-dom/cjs/react-dom.development.js --resolve=disable' const JavaScriptParser = NewParser(.{}); const JSXParser = NewParser(.{ .jsx = true }); const TSXParser = NewParser(.{ .jsx = true, .typescript = true }); diff --git a/src/js_printer.zig b/src/js_printer.zig index fbbf90404..d2e97532c 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -197,7 +197,7 @@ pub fn NewPrinter( comptime Writer: type, comptime Linker: type, comptime rewrite_esm_to_cjs: bool, - comptime speedy: bool, + comptime bun: bool, ) type { return struct { symbols: Symbol.Map, @@ -394,7 +394,7 @@ pub fn NewPrinter( pub fn printSymbol(p: *Printer, ref: Ref) void { debug("<printSymbol>\n {s}", .{ref}); defer debugl("</printSymbol>"); - if (speedy) { + if (bun) { if (p.options.require_ref) |require| { if (ref.eql(require)) { return p.printIdentifier("module.require"); @@ -752,7 +752,7 @@ pub fn NewPrinter( p.printSpaceBeforeIdentifier(); - if (speedy) { + if (bun) { p.print("module.require("); } else { p.print("require("); @@ -3182,7 +3182,7 @@ pub fn NewPrinter( p.printSymbol(s.default_name.?.ref.?); p.print(" = "); p.printLoadFromBundle(s.import_record_index); - if (!speedy) { + if (!bun) { p.print(".default"); } @@ -3197,7 +3197,7 @@ pub fn NewPrinter( p.printSymbol(s.default_name.?.ref.?); p.print(" = "); p.printSymbol(s.namespace_ref); - if (!speedy) { + if (!bun) { p.print(".default"); } p.printSemicolonAfterStatement(); @@ -3326,7 +3326,7 @@ pub fn NewPrinter( } } pub fn printLoadFromBundle(p: *Printer, import_record_index: u32) void { - if (speedy) { + if (bun) { const record = p.import_records[import_record_index]; p.print("module.require(\""); p.print(record.path.text); diff --git a/src/main_javascript.zig b/src/main_javascript.zig index 8529d5584..0f29d280b 100644 --- a/src/main_javascript.zig +++ b/src/main_javascript.zig @@ -159,8 +159,8 @@ pub const Cli = struct { clap.parseParam("--main-fields <STR>... Main fields to lookup in package.json. Defaults to --platform dependent") catch unreachable, clap.parseParam("--scan Instead of bundling or transpiling, print a list of every file imported by an entry point, recursively") catch unreachable, clap.parseParam("--new-jsb Generate a new node_modules.jsb file from node_modules and entry point(s)") catch unreachable, - clap.parseParam("--jsb <STR> Use a Speedy JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, - // clap.parseParam("--no-jsb Use a Speedy JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, + clap.parseParam("--jsb <STR> Use a Bun JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, + // clap.parseParam("--no-jsb Use a Bun JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, clap.parseParam("<POS>... Entry points to use") catch unreachable, }; @@ -334,7 +334,7 @@ pub const Cli = struct { .node_modules_bundle_path = node_modules_bundle_path, .public_dir = if (args.option("--public-dir")) |public_dir| allocator.dupe(u8, public_dir) catch unreachable else null, .write = write, - .platform = .speedy, + .platform = .bun, .serve = serve, .inject = inject, .entry_points = entry_points, diff --git a/src/node_module_bundle.zig b/src/node_module_bundle.zig index 63bb678d7..2208c8b9a 100644 --- a/src/node_module_bundle.zig +++ b/src/node_module_bundle.zig @@ -45,7 +45,7 @@ pub const NodeModuleBundle = struct { bytecode_cache_fetcher: Fs.BytecodeCacheFetcher = Fs.BytecodeCacheFetcher{}, - pub const magic_bytes = "#!/usr/bin/env speedy\n\n"; + pub const magic_bytes = "#!/usr/bin/env bun\n\n"; threadlocal var jsbundle_prefix: [magic_bytes.len + 5]u8 = undefined; // TODO: support preact-refresh, others by not hard coding diff --git a/src/options.zig b/src/options.zig index 583ecb5dd..ab8b18710 100644 --- a/src/options.zig +++ b/src/options.zig @@ -250,12 +250,12 @@ pub const ModuleType = enum { pub const Platform = enum { neutral, browser, - speedy, + bun, node, pub inline fn isClient(this: Platform) bool { return switch (this) { - .speedy => false, + .bun => false, else => true, }; } @@ -266,7 +266,7 @@ pub const Platform = enum { pub inline fn processBrowserDefineValue(this: Platform) ?string { return switch (this) { .browser => browser_define_value_true, - .speedy, .node => browser_define_value_false, + .bun, .node => browser_define_value_false, else => null, }; } @@ -315,7 +315,7 @@ pub const Platform = enum { return switch (plat orelse api.Api.Platform._none) { .node => .node, .browser => .browser, - .speedy => .speedy, + .bun => .bun, else => .browser, }; } @@ -352,7 +352,7 @@ pub const Platform = enum { // which will crash or fail to be bundled when targeting the browser. var listc = [_]string{ MAIN_FIELD_NAMES[0], MAIN_FIELD_NAMES[1], MAIN_FIELD_NAMES[2] }; array.set(Platform.browser, &listc); - array.set(Platform.speedy, &listc); + array.set(Platform.bun, &listc); // The neutral platform is for people that don't want esbuild to try to // pick good defaults for their platform. In that case, the list of main @@ -822,7 +822,7 @@ pub const BundleOptions = struct { .node => { opts.import_path_format = .relative_nodejs; }, - .speedy => { + .bun => { // If we're doing SSR, we want all the URLs to be the same as what it would be in the browser // If we're not doing SSR, we want all the import paths to be absolute opts.import_path_format = if (opts.import_path_format == .absolute_url) .absolute_url else .absolute_path; @@ -967,7 +967,7 @@ pub const BundleOptions = struct { }, error.AccessDenied => { Output.prettyErrorln( - "error: access denied when trying to open dir: \"{s}\".\nPlease re-open Speedy with access to this folder or pass a different folder via \"--public-dir\". Note: --public-dir is relative to --cwd (or the process' current working directory).\n\nThe public folder is where static assets such as images, fonts, and .html files go.", + "error: access denied when trying to open dir: \"{s}\".\nPlease re-open Bun with access to this folder or pass a different folder via \"--public-dir\". Note: --public-dir is relative to --cwd (or the process' current working directory).\n\nThe public folder is where static assets such as images, fonts, and .html files go.", .{opts.routes.static_dir}, ); std.process.exit(1); diff --git a/src/runtime.footer.js b/src/runtime.footer.js index 6217cc396..4171dd163 100644 --- a/src/runtime.footer.js +++ b/src/runtime.footer.js @@ -1,6 +1,6 @@ // --- // Public exports from runtime -// Compatible with Speedy's Runtime Environment and web browsers. +// Compatible with Bun's Runtime Environment and web browsers. export var $$m = "$primordials" in globalThis ? $primordials.require : SPEEDY_RUNTIME.$$m; export var __HMRModule = SPEEDY_RUNTIME.__HMRModule; diff --git a/src/runtime/hmr.ts b/src/runtime/hmr.ts index 4e91a8a42..f67bb3178 100644 --- a/src/runtime/hmr.ts +++ b/src/runtime/hmr.ts @@ -423,7 +423,7 @@ var __HMRModule, __FastRefreshModule, __HMRClient; const baseURL = new URL(location.origin + "/_api.hmr"); baseURL.protocol = location.protocol === "https:" ? "wss" : "ws"; - this.socket = new WebSocket(baseURL.toString(), ["speedy-hmr"]); + this.socket = new WebSocket(baseURL.toString(), ["bun-hmr"]); this.socket.binaryType = "arraybuffer"; this.socket.onclose = this.handleClose; this.socket.onerror = this.handleError; @@ -1143,19 +1143,19 @@ var __HMRModule, __FastRefreshModule, __HMRClient; var __hmrlog = { debug(...args) { - // console.debug("[speedy]", ...args); + // console.debug("[bun]", ...args); console.debug(...args); }, error(...args) { - // console.error("[speedy]", ...args); + // console.error("[bun]", ...args); console.error(...args); }, log(...args) { - // console.log("[speedy]", ...args); + // console.log("[bun]", ...args); console.log(...args); }, warn(...args) { - // console.warn("[speedy]", ...args); + // console.warn("[bun]", ...args); console.warn(...args); }, }; diff --git a/src/test/fixtures/minifysyntax.js b/src/test/fixtures/minifysyntax.js new file mode 100644 index 000000000..21ed3e53b --- /dev/null +++ b/src/test/fixtures/minifysyntax.js @@ -0,0 +1,2 @@ +<meta>hi</meta>; +console.log(process.env() ? true : false); diff --git a/src/test/fixtures/nullish-coalesce.js b/src/test/fixtures/nullish-coalesce.js new file mode 100644 index 000000000..deb1d9e04 --- /dev/null +++ b/src/test/fixtures/nullish-coalesce.js @@ -0,0 +1,2 @@ +const bar = true; +const foo = false || false; diff --git a/src/test/fixtures/tsconfig.json b/src/test/fixtures/tsconfig.json index b594d9102..3408c09f1 100644 --- a/src/test/fixtures/tsconfig.json +++ b/src/test/fixtures/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "baseUrl": "/Users/jarredsumner/Code/esdev/src/test/fixtures", + "baseUrl": "/Users/jarredsumner/Code/bun/src/test/fixtures", "paths": { "components": ["components/*"] }, |