aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-15 22:17:20 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-15 22:17:20 -0700
commit23357806183eff94632915239f7b98a4046eb3d7 (patch)
treeefdd9eae103bd29f2a914eccb1f4c2e0009d3fa1
parentbd11b04c18ef0ab5ba05b043829a729f45e53d5e (diff)
downloadbun-23357806183eff94632915239f7b98a4046eb3d7.tar.gz
bun-23357806183eff94632915239f7b98a4046eb3d7.tar.zst
bun-23357806183eff94632915239f7b98a4046eb3d7.zip
rename to bun
Former-commit-id: f982fc85fac3f0120e1851ad4027dd8413216439
-rw-r--r--.vscode/launch.json96
-rw-r--r--Makefile24
-rw-r--r--README.md34
-rw-r--r--buglogs/aug10.md11
-rw-r--r--build.zig10
-rw-r--r--demos/css-stress-test/.env1
-rw-r--r--demos/css-stress-test/.env.development1
-rw-r--r--demos/css-stress-test/.env.local1
-rw-r--r--demos/css-stress-test/nextjs-framework.tsx6
-rw-r--r--demos/css-stress-test/nexty/client.development.tsx162
-rw-r--r--demos/css-stress-test/nexty/package.json21
-rw-r--r--demos/css-stress-test/nexty/renderDocument.tsx4
-rw-r--r--demos/css-stress-test/nexty/server.development.tsx16
-rw-r--r--demos/css-stress-test/node_modules.jsb.zipbin143577 -> 0 bytes
-rw-r--r--demos/css-stress-test/package.json3
-rw-r--r--demos/css-stress-test/pages/index.tsx4
-rw-r--r--demos/css-stress-test/src/button.tsx1
-rw-r--r--demos/css-stress-test/src/colors.css24
-rw-r--r--demos/css-stress-test/test-pnpm.js2
-rw-r--r--packages/speedy-nextjs/package.json2
-rw-r--r--src/api/schema.d.ts6
-rw-r--r--src/api/schema.js6
-rw-r--r--src/api/schema.peechy2
-rw-r--r--src/api/schema.zig4
-rw-r--r--src/bundler.zig9
-rw-r--r--src/cli.zig8
-rw-r--r--src/feature_flags.zig2
-rw-r--r--src/hash_map.zig10
-rw-r--r--src/http.zig10
-rw-r--r--src/javascript/jsc/api/router.zig4
-rw-r--r--src/javascript/jsc/bindings/DefaultGlobal.cpp46
-rw-r--r--src/javascript/jsc/bindings/DefaultGlobal.h101
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp2
-rw-r--r--src/javascript/jsc/bindings/bindings.zig4
-rw-r--r--src/javascript/jsc/config.zig10
-rw-r--r--src/javascript/jsc/javascript.zig18
-rw-r--r--src/javascript/jsc/typescript.zig10
-rw-r--r--src/js_parser/js_parser.zig12
-rw-r--r--src/js_printer.zig12
-rw-r--r--src/main_javascript.zig6
-rw-r--r--src/node_module_bundle.zig2
-rw-r--r--src/options.zig14
-rw-r--r--src/runtime.footer.js2
-rw-r--r--src/runtime/hmr.ts10
-rw-r--r--src/test/fixtures/minifysyntax.js2
-rw-r--r--src/test/fixtures/nullish-coalesce.js2
-rw-r--r--src/test/fixtures/tsconfig.json2
-rw-r--r--types.d.ts4
-rw-r--r--types/globals.d.ts8
-rw-r--r--types/index.d.ts4
-rw-r--r--types/modules.d.ts13
51 files changed, 444 insertions, 324 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index b58f8b456..dced9e0df 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -4,48 +4,14 @@
{
"type": "lldb",
"request": "launch",
- "name": "Roujtes",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
- "args": [
- "./routes",
- "--resolve=dev",
- "--outdir=out"
- // "--origin=https://localhost:9000/"
- ],
- "cwd": "${workspaceFolder}/demos/css-stress-test",
- "console": "internalConsole"
- },
-
- {
- "type": "lldb",
- "request": "launch",
- "name": "SPJS Lazy Build",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/spjs",
- "args": ["src/test/fixtures/console.log.js"],
- "cwd": "${workspaceFolder}",
- "console": "internalConsole"
- },
-
- // {
- // "type": "lldb",
- // "request": "launch",
- // "name": "Test",
- // "program": "${workspaceFolder}/zig-out/bin/test",
- // "preLaunchTask": "test",
- // "args": ["/usr/local/bin/zig"],
- // "cwd": "${workspaceFolder}",
- // "console": "internalConsole"
- // },
- {
- "type": "lldb",
- "request": "launch",
"name": "Transpile small",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
"args": [
- "demos/css-stress-test/pages/index.tsx"
- // "--origin=https://localhost:9000/"
+ // "/Users/jarred/Desktop/webpack4.js"
+ // "/Users/jarred/Code/bun/demos/css-stress-test/nexty/node_modules/next/dist/build/utils.js"
+ "./dotenv-load-check.ts"
],
- "cwd": "${workspaceFolder}",
+ "cwd": "${workspaceFolder}/demos/css-stress-test",
"console": "internalConsole"
},
{
@@ -79,7 +45,7 @@
"type": "lldb",
"request": "launch",
"name": "Dev Launch",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
"args": [
"./simple.css",
"--resolve=dev",
@@ -94,8 +60,9 @@
"type": "lldb",
"request": "launch",
"name": "Demo Serve",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
- "args": ["--serve", "--origin=http://localhost:9000/"],
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
+ // "args": ["--serve", "--origin=http://localhost:3000"],
+ "args": ["--serve", "--origin=https://dev.jarredsumner.com"],
"cwd": "${workspaceFolder}/demos/css-stress-test",
"console": "internalConsole"
},
@@ -103,7 +70,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Lazy Build",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
"args": [
"./src/index.tsx",
"--resolve=lazy",
@@ -117,7 +84,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Build",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
"args": [
"./src/index.tsx",
"--resolve=dev",
@@ -133,7 +100,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo .jsb",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
"args": [
"./src/index.tsx",
"--resolve=lazy",
@@ -147,11 +114,12 @@
"type": "lldb",
"request": "launch",
"name": "Demo Build .jsb",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
"args": [
"--origin=http://localhost:9000/",
"--new-jsb",
- "--use=./nexty2"
+ "--use=ipwipwipwip-next-donotuse",
+ "--platform=browser"
],
"cwd": "${workspaceFolder}/demos/css-stress-test",
"console": "internalConsole"
@@ -160,8 +128,8 @@
"type": "lldb",
"request": "launch",
"name": "PNPM Resolve symlink",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
- "args": ["--resolve=dev", "test-pnpm.js"],
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
+ "args": ["--resolve=dev", "test-pnpm.js", "--platform=browser"],
"cwd": "${workspaceFolder}/demos/css-stress-test",
"console": "internalConsole"
},
@@ -169,7 +137,7 @@
"type": "lldb",
"request": "launch",
"name": "Demo Print .jsb",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
"args": ["./node_modules.jsb"],
"cwd": "${workspaceFolder}/demos/simple-react",
"console": "internalConsole"
@@ -179,7 +147,7 @@
"type": "lldb",
"request": "launch",
"name": "DAev Launch",
- "program": "${workspaceFolder}/build/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/macos-x86_64/bun",
"args": ["./simple.jsx", "--resolve=disable"],
"cwd": "${workspaceFolder}/src/test/fixtures",
"console": "internalConsole"
@@ -190,7 +158,7 @@
"request": "launch",
"mode": "debug",
"program": "/Users/jarred/Code/esbuild/cmd/esbuild",
- "cwd": "/Users/jarred/Code/esdev/src/test/fixtures",
+ "cwd": "/Users/jarred/Code/bun/src/test/fixtures",
"args": ["--bundle", "--outfile=out.esbuild.js", "await.ts"]
},
@@ -198,7 +166,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch (other)",
- // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
// "args": ["./simple.jsx", "--resolve=disable"],
// "cwd": "${workspaceFolder}/src/test/fixtures",
// "console": "internalConsole"
@@ -207,12 +175,12 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
// "preLaunchTask": "build",
// "args": [
// "--resolve=disable",
// "--cwd",
- // "/Users/jarredsumner/Code/esdev/src/test/fixtures",
+ // "/Users/jarredsumner/Code/bun/src/test/fixtures",
// "escape-chars.js"
// ],
// "cwd": "${workspaceFolder}",
@@ -222,7 +190,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
// "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -239,7 +207,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
// "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -256,7 +224,7 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
// // "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
@@ -275,8 +243,8 @@
"type": "lldb",
"request": "launch",
"name": "Rome",
- // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
- "program": "${workspaceFolder}/build/macos-x86_64/esdev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
+ "program": "${workspaceFolder}/build/macos-x86_64/bun",
// "preLaunchTask": "build",
"args": [
"--resolve=dev",
@@ -297,8 +265,8 @@
"type": "lldb",
"request": "launch",
"name": "Rome Dev",
- // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
- "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/bun",
// "preLaunchTask": "build",
"args": [
"--resolve=dev",
@@ -319,13 +287,13 @@
// "type": "lldb",
// "request": "launch",
// "name": "Dev Launch",
- // "program": "${workspaceFolder}/build/bin/debug/esdev",
+ // "program": "${workspaceFolder}/build/bin/debug/bun",
// "preLaunchTask": "build",
// "args": [
// "--resolve=dev",
// "--cwd",
// "/",
- // "/Users/jarredsumner/Code/esdev/src/test/fixtures/img-bug.js",
+ // "/Users/jarredsumner/Code/bun/src/test/fixtures/img-bug.js",
// "-o",
// "out"
// ],
diff --git a/Makefile b/Makefile
index 1902e2d9a..b2ee33fb3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-speedy: speedy-prod-native speedy-prod-wasi speedy-prod-wasm
+bun: bun-prod-native bun-prod-wasi bun-prod-wasm
api:
peechy --schema src/api/schema.peechy --esm src/api/schema.js --ts src/api/schema.d.ts --zig src/api/schema.zig
@@ -62,30 +62,30 @@ sizegen:
picohttp:
clang -O3 -g -c src/deps/picohttpparser.c -Isrc/deps -o src/deps/picohttpparser.o; cd ../../
-speedy-prod-native-macos: picohttp
+bun-prod-native-macos: picohttp
zig build -Drelease-fast -Dtarget=x86_64-macos-gnu
-speedy-prod-native-macos-lib:
+bun-prod-native-macos-lib:
zig build lib -Drelease-fast -Dtarget=x86_64-macos-gnu
-speedy-m1:
+bun-m1:
zig build -Drelease-fast -Dtarget=aarch64-macos-gnu
-speedy-prod-wasm:
+bun-prod-wasm:
zig build -Drelease-fast -Dtarget=wasm32-freestanding
-speedy-prod-wasi:
+bun-prod-wasi:
zig build -Drelease-fast -Dtarget=wasm32-wasi
-speedy-dev: speedy-dev-native speedy-dev-wasi speedy-dev-wasm
+bun-dev: bun-dev-native bun-dev-wasi bun-dev-wasm
-speedy-dev-native:
+bun-dev-native:
zig build
-speedy-dev-wasm:
+bun-dev-wasm:
zig build -Dtarget=wasm32-freestanding
-speedy-dev-wasi:
+bun-dev-wasi:
zig build -Dtarget=wasm32-wasi
@@ -138,9 +138,9 @@ bench-rome:
echo 'Line count:' && (find bench/rome/src -name '*.ts' && find bench/rome/src -name '*.js') | xargs wc -l | tail -n 1
-bench-rome-speedy: | bench/rome-verify
+bench-rome-bun: | bench/rome-verify
cd bench/rome/src
- /Users/jarred/Code/esdev/build/macos-x86_64/esdev --outdir=dist ./entry.ts
+ /Users/jarred/Code/bun/build/macos-x86_64/bun --outdir=dist ./entry.ts
github-rome:
mkdir -p github/rome
diff --git a/README.md b/README.md
index 18f32fb12..8dd920c18 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,10 @@
# A fast bundler & JS Runtime built for developer iteration cycle
-Speedy is a fast bundler, transpiler, and runtime environment for JavaScript & TypeScript. It also supports bundling CSS.
+Bun is a fast bundler, transpiler, and runtime environment for JavaScript & TypeScript. It also supports bundling CSS.
### Performance optimizations
-Here are some techniques Speedy uses to go fast. Most are small wins. Some are big.
+Here are some techniques Bun uses to go fast. Most are small wins. Some are big.
#### Compare comptime-known strings by nearest `(u64 || u32 || u16 || u8)`-sized integer
@@ -126,7 +126,7 @@ It's much faster to reuse the memory from reading the contents of the JavaScript
#### CSS ~Parser~ Scanner
-Speedy (currently) does not have a CSS Parser. But, it still processes CSS.
+Bun (currently) does not have a CSS Parser. But, it still processes CSS.
Most CSS processors work something like this:
@@ -136,7 +136,7 @@ Most CSS processors work something like this:
4. Perform 1 or more passes over the AST. For tools like PostCSS, every plugin typically adds 1+ passes over the AST. (visiting)
5. Print the source code (printing)
-Speedy's CSS Scanner scans, rewrites, and prints CSS in a single pass without generating an AST. It works like this:
+Bun's CSS Scanner scans, rewrites, and prints CSS in a single pass without generating an AST. It works like this:
1. Copy the CSS source code to a byte array
2. Iterate through every unicode codepoint, searching for lines starting with `@import` or property values with `url(`
@@ -146,15 +146,15 @@ Speedy's CSS Scanner scans, rewrites, and prints CSS in a single pass without ge
3. Write the import URL
4. When end of file is reached, flush to disk.
-Speedy's CSS Scanner is about 56x faster than PostCSS with the `postcss-import` and `postcss-url` plugins enabled (and sourcemaps disabled). On the other hand, auto-prefixing and minification won't work. Minifying whitespace is possible with some modifications, but minifiying CSS syntax correctly needs an AST.
+Bun's CSS Scanner is about 56x faster than PostCSS with the `postcss-import` and `postcss-url` plugins enabled (and sourcemaps disabled). On the other hand, auto-prefixing and minification won't work. Minifying whitespace is possible with some modifications, but minifiying CSS syntax correctly needs an AST.
This approach is fast, but not without tradeoffs!
-Speedy's CSS Scanner is based on esbuild's CSS Lexer. Thank you @evanwallace.
+Bun's CSS Scanner is based on esbuild's CSS Lexer. Thank you @evanwallace.
#### Compile-time generated JavaScript Parsers
-At the time of writing, there are 8 different comptime-generated variations of Speedy's JavaScript parser.
+At the time of writing, there are 8 different comptime-generated variations of Bun's JavaScript parser.
```zig
pub fn NewParser(
@@ -173,16 +173,16 @@ When this is `false`, branches that only apply to parsing TypeScript are removed
**Performance impact: +2%?**
```bash
-❯ 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'
```
When this is `false`, branches that only apply to parsing JSX are removed.
@@ -197,7 +197,7 @@ This is only used for application code when generating `node_modules.jsb`. This
comptime only_scan_imports_and_do_not_visit: bool,
```
-At runtime, Speedy chooses the appropriate JavaScript parser to use based on the `loader`. In practical terms, this moves all the branches checking whether a parsing step should be run from inside several tight loops to just once, before parsing starts.
+At runtime, Bun chooses the appropriate JavaScript parser to use based on the `loader`. In practical terms, this moves all the branches checking whether a parsing step should be run from inside several tight loops to just once, before parsing starts.
#### Max out per-process file handle limit automatically, leave file handles open.
@@ -209,13 +209,13 @@ This also enabled a kqueue-based File System watcher on macOS. FSEvents, the mor
### Architecture
-#### The Speedy Bundle Format
+#### The Bun Bundle Format
TODO: document
### Hot Module Reloading
-Speedy's Hot Module Reloader uses a custom binary protocol that's around 8x more space efficient than other bundlers.
+Bun's Hot Module Reloader uses a custom binary protocol that's around 8x more space efficient than other bundlers.
- File change notifications cost 9 bytes.
- Build metadata costs 13 bytes + length of the module path that was rebuilt + size of the built file.
@@ -224,13 +224,13 @@ For comparison, Vite's HMR implementation uses 104 bytes + length of the module
#### Instant CSS
-When using `<link rel="stylesheet">`, Speedy HMR "just works", with zero configuration and without modifying HTML.
+When using `<link rel="stylesheet">`, Bun HMR "just works", with zero configuration and without modifying HTML.
Here's how:
- On page load, CSS files are built per request
- When you make a change to a local CSS file, a file change notification is pushed over the websocket connection to the browser (HMR client)
- For the first update, instead of asking for a new file to build, it asks for a list of files that the file within the `<link rel="stylesheet">` imports, and any those `@import`, recursively. If `index.css` imports `link.css` and `link.css` imports `colors.css`, that list will include `index.css`, `link.css`, and `colors.css`.
-- Preserving import order, the link tags are replaced in a single DOM update. This time, an additional query string flag is added `?noimport` which tells the Speedy CSS Scanner to remove any `@import` statements from the built CSS file.
+- Preserving import order, the link tags are replaced in a single DOM update. This time, an additional query string flag is added `?noimport` which tells the Bun CSS Scanner to remove any `@import` statements from the built CSS file.
While this approach today is fast, there are more scalable alternatives to large codebases worth considering (such as, a bundling format that supports loading individual files unbundled). This may change in the near future.
diff --git a/buglogs/aug10.md b/buglogs/aug10.md
new file mode 100644
index 000000000..1ea87f2ce
--- /dev/null
+++ b/buglogs/aug10.md
@@ -0,0 +1,11 @@
+```
+ModuleNotFound on resolving "object-assign" from "/Users/jarred/Code/bun/demos/css-stress-test/node_modules/react-dom/cjs/"
+```
+
+Happens with `--platform=browser` when importing react while building the .jsb
+
+`object-assign` doesn't have a `main` field set. That's not a bug; this should work.
+
+The error doesn't happen when `main` is set in `object-assign`'s `package.json`.
+
+It turns out, this was a data race! It was fixed by disabling building .jsb in parallel
diff --git a/build.zig b/build.zig
index ca35b8c07..4f745b089 100644
--- a/build.zig
+++ b/build.zig
@@ -93,17 +93,17 @@ pub fn build(b: *std.build.Builder) void {
if (target.getOsTag() == .wasi) {
exe.enable_wasmtime = true;
- exe = b.addExecutable("esdev", "src/main_wasi.zig");
+ exe = b.addExecutable("bun", "src/main_wasi.zig");
exe.linkage = .dynamic;
exe.setOutputDir(output_dir);
} else if (target.getCpuArch().isWasm()) {
// exe = b.addExecutable(
- // "esdev",
+ // "bun",
// "src/main_wasm.zig",
// );
// exe.is_linking_libc = false;
// exe.is_dynamic = true;
- var lib = b.addExecutable("esdev", "src/main_wasm.zig");
+ var lib = b.addExecutable("bun", "src/main_wasm.zig");
lib.single_threaded = true;
// exe.want_lto = true;
// exe.linkLibrary(lib);
@@ -143,7 +143,7 @@ pub fn build(b: *std.build.Builder) void {
return;
} else {
- exe = b.addExecutable("esdev", "src/main.zig");
+ exe = b.addExecutable("bun", "src/main.zig");
}
// exe.setLibCFile("libc.txt");
exe.linkLibC();
@@ -292,7 +292,7 @@ pub fn build(b: *std.build.Builder) void {
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
- var log_step = b.addLog("Destination: {s}/{s}\n", .{ output_dir, "esdev" });
+ var log_step = b.addLog("Destination: {s}/{s}\n", .{ output_dir, "bun" });
log_step.step.dependOn(&exe.step);
var typings_cmd: *std.build.RunStep = typings_exe.run();
diff --git a/demos/css-stress-test/.env b/demos/css-stress-test/.env
deleted file mode 100644
index 0b3ef03c1..000000000
--- a/demos/css-stress-test/.env
+++ /dev/null
@@ -1 +0,0 @@
-NEXT_PUBLIC_TEST=1 \ No newline at end of file
diff --git a/demos/css-stress-test/.env.development b/demos/css-stress-test/.env.development
deleted file mode 100644
index 81dc6216e..000000000
--- a/demos/css-stress-test/.env.development
+++ /dev/null
@@ -1 +0,0 @@
-SO_MANY_DOT_ENVS=true
diff --git a/demos/css-stress-test/.env.local b/demos/css-stress-test/.env.local
deleted file mode 100644
index 1723445f0..000000000
--- a/demos/css-stress-test/.env.local
+++ /dev/null
@@ -1 +0,0 @@
-NEXT_PUBLIC_TEST=100 \ No newline at end of file
diff --git a/demos/css-stress-test/nextjs-framework.tsx b/demos/css-stress-test/nextjs-framework.tsx
index 38948e482..40aa52ba4 100644
--- a/demos/css-stress-test/nextjs-framework.tsx
+++ b/demos/css-stress-test/nextjs-framework.tsx
@@ -1,13 +1,13 @@
-import { renderNextJSPage } from "speedy-nextjs/server";
+import { renderNextJSPage } from "bun-nextjs/server";
addEventListener("fetch", (event: FetchEvent) => {
const AppComponent = module.requireFirst(
"pages/_app",
- "speedy-nextjs/pages/_app"
+ "bun-nextjs/pages/_app"
);
const Document = module.requireFirst(
"pages/_document",
- "speedy-nextjs/pages/_document"
+ "bun-nextjs/pages/_document"
);
});
diff --git a/demos/css-stress-test/nexty/client.development.tsx b/demos/css-stress-test/nexty/client.development.tsx
index 82bce03a8..b83d78e01 100644
--- a/demos/css-stress-test/nexty/client.development.tsx
+++ b/demos/css-stress-test/nexty/client.development.tsx
@@ -30,32 +30,168 @@ import {
createRouter,
makePublicRouterInstance,
} from "next/dist/client/router";
+import * as React from "react";
export const emitter: MittEmitter<string> = mitt();
+declare global {
+ interface Window {
+ /* test fns */
+ __NEXT_HYDRATED?: boolean;
+ __NEXT_HYDRATED_CB?: () => void;
+
+ /* prod */
+ __NEXT_PRELOADREADY?: (ids?: (string | number)[]) => void;
+ __NEXT_DATA__: NEXT_DATA;
+ __NEXT_P: any[];
+ }
+}
+
+type RenderRouteInfo = PrivateRouteInfo & {
+ App: AppComponent;
+ scroll?: { x: number; y: number } | null;
+};
+type RenderErrorProps = Omit<RenderRouteInfo, "Component" | "styleSheets">;
+
+const data: typeof window["__NEXT_DATA__"] = JSON.parse(
+ document.getElementById("__NEXT_DATA__")!.textContent!
+);
+window.__NEXT_DATA__ = data;
+
+const {
+ props: hydrateProps,
+ err: hydrateErr,
+ page,
+ query,
+ buildId,
+ assetPrefix,
+ runtimeConfig,
+ dynamicIds,
+ isFallback,
+ locale,
+ locales,
+ domainLocales,
+ isPreview,
+} = data;
+
+const prefix: string = assetPrefix || "";
+
+setConfig({
+ serverRuntimeConfig: {},
+ publicRuntimeConfig: runtimeConfig || {},
+});
+
+let asPath: string = getURL();
+
+// make sure not to attempt stripping basePath for 404s
+if (hasBasePath(asPath)) {
+ asPath = delBasePath(asPath);
+}
+
+const pageLoader: PageLoader = new PageLoader(buildId, prefix);
+
+const headManager: {
+ mountedInstances: Set<unknown>;
+ updateHead: (head: JSX.Element[]) => void;
+} = initHeadManager();
+const appElement: HTMLElement | null = document.getElementById("__next");
+
+let lastRenderReject: (() => void) | null;
+let webpackHMR: any;
+export let router: Router;
+let CachedApp: AppComponent, onPerfEntry: (metric: any) => void;
+
export default function boot(EntryPointNamespace, loader) {
_boot(EntryPointNamespace);
}
-function _boot(EntryPointNamespace) {
- const next_data_node = document.querySelector("#__NEXT_DATA__");
- if (!next_data_node) {
- throw new Error(
- "__NEXT_DATA__ is missing. That means something went wrong while rendering on the server."
- );
+class Container extends React.Component<{
+ fn: (err: Error, info?: any) => void;
+}> {
+ componentDidCatch(componentErr: Error, info: any) {
+ this.props.fn(componentErr, info);
+ }
+
+ componentDidMount() {
+ this.scrollToHash();
+
+ // We need to replace the router state if:
+ // - the page was (auto) exported and has a query string or search (hash)
+ // - it was auto exported and is a dynamic route (to provide params)
+ // - if it is a client-side skeleton (fallback render)
+ if (
+ router.isSsr &&
+ // We don't update for 404 requests as this can modify
+ // the asPath unexpectedly e.g. adding basePath when
+ // it wasn't originally present
+ page !== "/404" &&
+ page !== "/_error" &&
+ (isFallback ||
+ (data.nextExport &&
+ (isDynamicRoute(router.pathname) ||
+ location.search ||
+ process.env.__NEXT_HAS_REWRITES)) ||
+ (hydrateProps &&
+ hydrateProps.__N_SSG &&
+ (location.search || process.env.__NEXT_HAS_REWRITES)))
+ ) {
+ // update query on mount for exported pages
+ router.replace(
+ router.pathname +
+ "?" +
+ String(
+ assign(
+ urlQueryToSearchParams(router.query),
+ new URLSearchParams(location.search)
+ )
+ ),
+ asPath,
+ {
+ // @ts-ignore
+ // WARNING: `_h` is an internal option for handing Next.js
+ // client-side hydration. Your app should _never_ use this property.
+ // It may change at any time without notice.
+ _h: 1,
+ // Fallback pages must trigger the data fetch, so the transition is
+ // not shallow.
+ // Other pages (strictly updating query) happens shallowly, as data
+ // requirements would already be present.
+ shallow: !isFallback,
+ }
+ );
+ }
+ }
+
+ componentDidUpdate() {
+ this.scrollToHash();
}
- try {
- globalThis.NEXT_DATA = JSON.parse(next_data_node.innerHTML);
- } catch (error) {
- error.message = `Error parsing __NEXT_DATA__\n${error.message}`;
- throw error;
+ scrollToHash() {
+ let { hash } = location;
+ hash = hash && hash.substring(1);
+ if (!hash) return;
+
+ const el: HTMLElement | null = document.getElementById(hash);
+ if (!el) return;
+
+ // If we call scrollIntoView() in here without a setTimeout
+ // it won't scroll properly.
+ setTimeout(() => el.scrollIntoView(), 0);
}
- const props = { ...globalThis.NEXT_DATA.props };
+ render() {
+ return this.props.children;
+ }
+}
+let CachedComponent: React.ComponentType;
+
+function _boot(EntryPointNamespace) {
const PageComponent = EntryPointNamespace.default;
ReactDOM.hydrate(
- <App Component={PageComponent} pageProps={props.pageProps}></App>,
+ <Container fn={(error) => <div>{JSON.stringify(error)}</div>}>
+ <App Component={PageComponent} pageProps={data.props}></App>
+ </Container>,
+
document.querySelector("#__next")
);
}
diff --git a/demos/css-stress-test/nexty/package.json b/demos/css-stress-test/nexty/package.json
index ea9879069..359aa3f34 100644
--- a/demos/css-stress-test/nexty/package.json
+++ b/demos/css-stress-test/nexty/package.json
@@ -1,12 +1,16 @@
{
- "name": "nexty",
- "version": "1.0.0",
+ "name": "wipwipwipwip-next-donotuse",
+ "version": "4.0.0",
"description": "",
+ "main": "package.json",
"framework": {
"static": "public",
"assetPrefix": "_next/",
"router": {
- "dir": "pages",
+ "dir": [
+ "pages",
+ "src/pages"
+ ],
"extensions": [
".js",
".ts",
@@ -28,7 +32,8 @@
"process.env.__NEXT_HAS_REWRITES": "false",
"process.env.__NEXT_ANALYTICS_ID": "null",
"process.env.__NEXT_OPTIMIZE_CSS": "false",
- "process.env.__NEXT_CROSS_ORIGIN": "''"
+ "process.env.__NEXT_CROSS_ORIGIN": "''",
+ "process.env.__NEXT_STRICT_MODE": "false"
}
},
"server": {
@@ -44,7 +49,8 @@
"process.env.__NEXT_I18N_SUPPORT": "false",
"process.env.__NEXT_HAS_REWRITES": "false",
"process.env.__NEXT_ANALYTICS_ID": "null",
- "process.env.__NEXT_CROSS_ORIGIN": "''"
+ "process.env.__NEXT_CROSS_ORIGIN": "''",
+ "process.env.__NEXT_STRICT_MODE": "false"
}
}
}
@@ -58,8 +64,5 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
- "license": "ISC",
- "dependencies": {
- "next": "^11.1.0"
- }
+ "license": "ISC"
}
diff --git a/demos/css-stress-test/nexty/renderDocument.tsx b/demos/css-stress-test/nexty/renderDocument.tsx
index e5261d4c2..9fd2e8e07 100644
--- a/demos/css-stress-test/nexty/renderDocument.tsx
+++ b/demos/css-stress-test/nexty/renderDocument.tsx
@@ -468,7 +468,7 @@ export async function render({
isFallback: isFallback,
},
true,
- Wundle.origin,
+ Bun.origin,
null,
[], // renderOpts.locales,
null, //renderOpts.defaultLocale,
@@ -573,7 +573,7 @@ export async function render({
docComponentsRendered,
...renderOpts,
disableOptimizedLoading: false,
- canonicalBase: Wundle.origin,
+ canonicalBase: Bun.origin,
buildManifest: {
devFiles: [],
allFiles: [],
diff --git a/demos/css-stress-test/nexty/server.development.tsx b/demos/css-stress-test/nexty/server.development.tsx
index 9dfa07168..1f0eaee50 100644
--- a/demos/css-stress-test/nexty/server.development.tsx
+++ b/demos/css-stress-test/nexty/server.development.tsx
@@ -4,7 +4,7 @@ let buildId = 0;
var DocumentNamespacePromise;
-DocumentNamespacePromise = import(Wundle.routesDir + "_document");
+DocumentNamespacePromise = import(Bun.routesDir + "_document");
var DocumentLoaded = false;
var DocumentNamespace;
@@ -21,22 +21,22 @@ addEventListener("fetch", async (event: FetchEvent) => {
var appRoute;
try {
- appRoute = await import(Wundle.routesDir + "_app");
+ appRoute = await import(Bun.routesDir + "_app");
} catch (exception) {
appRoute = null;
}
- const appStylesheets = (Wundle.getImportedStyles() as string[]).slice();
- var route = Wundle.match(event);
+ const appStylesheets = (Bun.getImportedStyles() as string[]).slice();
+ var route = Bun.match(event);
// This imports the currently matched route.
const PageNamespace = await import(route.filePath);
// This returns all .css files that were imported in the line above.
// It's recursive, so any file that imports a CSS file will be included.
- const pageStylesheets = (Wundle.getImportedStyles() as string[]).slice();
+ const pageStylesheets = (Bun.getImportedStyles() as string[]).slice();
event.respondWith(
- await render({
+ render({
route,
PageNamespace,
appStylesheets,
@@ -44,7 +44,7 @@ addEventListener("fetch", async (event: FetchEvent) => {
DocumentNamespace,
AppNamespace: appRoute,
buildId,
- routePaths: Wundle.getRouteFiles(),
+ routePaths: Bun.getRouteFiles(),
})
);
buildId++;
@@ -53,7 +53,7 @@ addEventListener("fetch", async (event: FetchEvent) => {
// typescript isolated modules
export {};
-declare var Wundle: any;
+declare var Bun: any;
function getNextData(request: Request, route) {
return {
diff --git a/demos/css-stress-test/node_modules.jsb.zip b/demos/css-stress-test/node_modules.jsb.zip
deleted file mode 100644
index b24a7823b..000000000
--- a/demos/css-stress-test/node_modules.jsb.zip
+++ /dev/null
Binary files differ
diff --git a/demos/css-stress-test/package.json b/demos/css-stress-test/package.json
index a4b3e1f91..e45f6d1f2 100644
--- a/demos/css-stress-test/package.json
+++ b/demos/css-stress-test/package.json
@@ -15,7 +15,8 @@
"react-dom": "^17.0.2",
"react-form": "^4.0.1",
"react-hook-form": "^7.8.3",
- "url": "^0.11.0"
+ "url": "^0.11.0",
+ "wipwipwipwip-next-donotuse": "4.0.0"
},
"parcel": "parceldist/index.js",
"targets": {
diff --git a/demos/css-stress-test/pages/index.tsx b/demos/css-stress-test/pages/index.tsx
index aee3be2cf..95d190f81 100644
--- a/demos/css-stress-test/pages/index.tsx
+++ b/demos/css-stress-test/pages/index.tsx
@@ -1,5 +1,7 @@
import { Main } from "src/main";
-export default function IndexPage() {
+export function IndexPage() {
return <Main />;
}
+
+export default IndexPage;
diff --git a/demos/css-stress-test/src/button.tsx b/demos/css-stress-test/src/button.tsx
new file mode 100644
index 000000000..42207a6ca
--- /dev/null
+++ b/demos/css-stress-test/src/button.tsx
@@ -0,0 +1 @@
+export const Button = ({ children }) => <div>asdasasd{children}</div>;
diff --git a/demos/css-stress-test/src/colors.css b/demos/css-stress-test/src/colors.css
index d45bf4ffc..71d54c25c 100644
--- a/demos/css-stress-test/src/colors.css
+++ b/demos/css-stress-test/src/colors.css
@@ -1,14 +1,14 @@
:root {
- --timestamp: "12812";
- --interval: "8";
- --progress-bar: 11.83299999999997%;
- --spinner-1-muted: rgb(142, 6, 182);
- --spinner-1-primary: rgb(177, 8, 227);
- --spinner-2-muted: rgb(110, 148, 190);
- --spinner-2-primary: rgb(138, 185, 238);
- --spinner-3-muted: rgb(75, 45, 64);
- --spinner-3-primary: rgb(94, 56, 80);
- --spinner-4-muted: rgb(155, 129, 108);
- --spinner-4-primary: rgb(194, 161, 135);
- --spinner-rotate: 213deg;
+ --timestamp: "596";
+ --interval: "64";
+ --progress-bar: 33.167%;
+ --spinner-1-muted: rgb(42, 74, 66);
+ --spinner-1-primary: rgb(53, 93, 82);
+ --spinner-2-muted: rgb(90, 51, 192);
+ --spinner-2-primary: rgb(112, 64, 240);
+ --spinner-3-muted: rgb(157, 140, 68);
+ --spinner-3-primary: rgb(196, 175, 85);
+ --spinner-4-muted: rgb(86, 152, 66);
+ --spinner-4-primary: rgb(108, 190, 82);
+ --spinner-rotate: 237deg;
} \ No newline at end of file
diff --git a/demos/css-stress-test/test-pnpm.js b/demos/css-stress-test/test-pnpm.js
index b494d82dd..a0a27e463 100644
--- a/demos/css-stress-test/test-pnpm.js
+++ b/demos/css-stress-test/test-pnpm.js
@@ -1 +1 @@
-import jsx from "/Users/jarred/Code/esdev/demos/css-stress-test/node_modules/react/cjs/react-jsx-dev-runtime.development.js";
+import jsx from "/Users/jarred/Code/bun/demos/css-stress-test/node_modules/react/cjs/react-jsx-dev-runtime.development.js";
diff --git a/packages/speedy-nextjs/package.json b/packages/speedy-nextjs/package.json
index fef4256c9..cbe26e4c9 100644
--- a/packages/speedy-nextjs/package.json
+++ b/packages/speedy-nextjs/package.json
@@ -1,5 +1,5 @@
{
- "name": "speedy-nextjs",
+ "name": "bun-nextjs",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
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/*"]
},
diff --git a/types.d.ts b/types.d.ts
index 319d98760..1907de370 100644
--- a/types.d.ts
+++ b/types.d.ts
@@ -1,5 +1,5 @@
-interface SpeedyNodeModule extends NodeJS.Module {
+interface BunNodeModule extends NodeJS.Module {
requireFirst(...id: string[]): any;
}
-declare var module: SpeedyNodeModule;
+declare var module: BunNodeModule;
diff --git a/types/globals.d.ts b/types/globals.d.ts
index 3d6c0c07c..99648be33 100644
--- a/types/globals.d.ts
+++ b/types/globals.d.ts
@@ -1,8 +1,10 @@
-// Speedy.js v
+// Bun.js v
declare global {
-
- function addEventListener(name: "fetch", callback: (event: FetchEvent) => void): void;
+ function addEventListener(
+ name: "fetch",
+ callback: (event: FetchEvent) => void
+ ): void;
}
declare global {
diff --git a/types/index.d.ts b/types/index.d.ts
index 4e2dfc32c..83d1d6555 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -1,4 +1,4 @@
/// <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" />
diff --git a/types/modules.d.ts b/types/modules.d.ts
index 3ea7d0437..23c59b0ed 100644
--- a/types/modules.d.ts
+++ b/types/modules.d.ts
@@ -1,8 +1,7 @@
-// Speedy.js v
-
-/** 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. */
-declare module "speedy.js/router" {
+// Bun.js v
+/** 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. */
+declare module "bun.js/router" {
/** Match a {@link https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent FetchEvent} to a `Route` from the local filesystem. Returns `null` if there is no match. */
function match(event: FetchEvent): Route | null;
@@ -27,19 +26,19 @@ declare module "speedy.js/router" {
* `"blog/posts/[id]"`
* `"blog/posts/[id]/[[...slug]]"`
* `"blog"`
- */
+ */
readonly name: string;
/**
* Route parameters as a key-value object
- *
+ *
* @example
* ```js
* console.assert(router.query.id === "123");
* console.assert(router.pathname === "/blog/posts/123");
* console.assert(router.route === "blog/posts/[id]");
* ```
- */
+ */
readonly query: Record<string, string | string[]>;
/** Synchronously load & evaluate the file corresponding to the route. Returns the exports of the route. This is similar to `await import(route.filepath)`, except it's synchronous. It is recommended to use this function instead of `import`. */