aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json43
-rwxr-xr-xbun.lockbbin25603 -> 7689 bytes
-rw-r--r--examples/bun/tsconfig.json5
-rw-r--r--integration/bunjs-only-snippets/fs.test.js2
-rw-r--r--integration/bunjs-only-snippets/tsconfig.json14
-rw-r--r--package.json7
-rw-r--r--src/javascript/jsc/node/syscall.zig8
-rw-r--r--src/javascript/jsc/node/types.zig1
-rw-r--r--src/mimalloc_arena.zig8
-rw-r--r--src/yield.zig17
10 files changed, 83 insertions, 22 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index a5abe5387..071ceb977 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -292,7 +292,19 @@
"request": "launch",
"name": "bun test",
"program": "bun-debug",
- "args": ["wiptest", "transpiler"],
+ "args": ["wiptest"],
+ "cwd": "${workspaceFolder}/integration",
+ "env": {
+ "FORCE_COLOR": "1"
+ },
+ "console": "internalConsole"
+ },
+ {
+ "type": "lldb",
+ "request": "launch",
+ "name": "bun test current",
+ "program": "bun-debug",
+ "args": ["wiptest", "response.file"],
"cwd": "${workspaceFolder}/integration",
"env": {
"FORCE_COLOR": "1"
@@ -302,15 +314,40 @@
{
"type": "lldb",
"request": "launch",
+ "name": "bun http example",
+ "program": "bun-debug",
+ "args": ["run", "examples/bun/http.ts"],
+ "cwd": "${workspaceFolder}",
+ "env": {
+ "FORCE_COLOR": "1"
+ },
+ "console": "internalConsole"
+ },
+ {
+ "type": "lldb",
+ "request": "launch",
+ "name": "bun http file example",
+ "program": "bun-debug",
+ "args": ["run", "examples/bun/http-file.ts"],
+ "cwd": "${workspaceFolder}",
+ "env": {
+ "FORCE_COLOR": "1"
+ },
+ "console": "internalConsole"
+ },
+ {
+ "type": "lldb",
+ "request": "launch",
"name": "bun tes2t",
"program": "bun-debug",
- "args": ["build", "hello.jsx", "--platform=bun"],
- "cwd": "/Users/jarred/Desktop/",
+ "args": ["add", "imagemin-webpack-plugin"],
+ "cwd": "/tmp/testfoo",
"env": {
"FORCE_COLOR": "1"
},
"console": "internalConsole"
},
+
{
"type": "lldb",
"request": "launch",
diff --git a/bun.lockb b/bun.lockb
index 6c56d2268..a45acac04 100755
--- a/bun.lockb
+++ b/bun.lockb
Binary files differ
diff --git a/examples/bun/tsconfig.json b/examples/bun/tsconfig.json
index c4e7db2d8..a6c1f5d71 100644
--- a/examples/bun/tsconfig.json
+++ b/examples/bun/tsconfig.json
@@ -1,6 +1,11 @@
{
"compilerOptions": {
"lib": ["ESNext"],
+ "allowJs": true,
+ "checkJs": true,
+ "noEmit": true,
+ "target": "esnext",
+ "module": "esnext",
"types": ["../../types/bun"]
}
}
diff --git a/integration/bunjs-only-snippets/fs.test.js b/integration/bunjs-only-snippets/fs.test.js
index 8b5e0c867..660289152 100644
--- a/integration/bunjs-only-snippets/fs.test.js
+++ b/integration/bunjs-only-snippets/fs.test.js
@@ -1,4 +1,4 @@
-import { describe, it, expect } from "vitest";
+import { describe, it, expect } from "bun:test";
import {
mkdirSync,
existsSync,
diff --git a/integration/bunjs-only-snippets/tsconfig.json b/integration/bunjs-only-snippets/tsconfig.json
index e76eae4ac..fc416b882 100644
--- a/integration/bunjs-only-snippets/tsconfig.json
+++ b/integration/bunjs-only-snippets/tsconfig.json
@@ -1,10 +1,12 @@
{
"compilerOptions": {
- "lib": ["esnext", { "replace": "node", "with": "dom" }],
- "baseUrl": ".",
- "paths": {
- "foo/bar": ["baz.js"]
- },
- "typeRoots": ["./node_modules/@types"]
+ "lib": ["ESNext"],
+ "allowJs": true,
+ "checkJs": true,
+ "noEmit": true,
+ "moduleResolution": "node",
+ "downlevelIteration": true,
+ "module": "esnext",
+ "types": ["../../types/bun"]
}
}
diff --git a/package.json b/package.json
index 2eeea0108..d28c4f780 100644
--- a/package.json
+++ b/package.json
@@ -8,9 +8,8 @@
"build-fallback": "esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js"
},
"devDependencies": {
- "@types/node": "^16.9.2",
- "@types/puppeteer": "^5.4.4",
- "prettier": "^2.4.1"
+ "prettier": "^2.4.1",
+ "typescript": "4.6.3"
},
"version": "0.0.0"
-} \ No newline at end of file
+}
diff --git a/src/javascript/jsc/node/syscall.zig b/src/javascript/jsc/node/syscall.zig
index 736e5b809..397ecdb29 100644
--- a/src/javascript/jsc/node/syscall.zig
+++ b/src/javascript/jsc/node/syscall.zig
@@ -210,7 +210,6 @@ else
pub fn pread(fd: os.fd_t, buf: []u8, offset: i64) Maybe(usize) {
const adjusted_len = @minimum(buf.len, max_count);
-
const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned
while (true) {
const rc = pread_sym(fd, buf.ptr, adjusted_len, ioffset);
@@ -378,6 +377,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) Maybe([]u8) {
return .{ .result = out_buffer[0..len] };
},
.linux => {
+ // TODO: alpine linux may not have /proc/self
var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
const proc_path = std.fmt.bufPrintZ(procfs_buf[0..], "/proc/self/fd/{d}\x00", .{fd}) catch unreachable;
@@ -423,9 +423,9 @@ fn mmap(
return Maybe([]align(mem.page_size) u8){
.err = .{ .errno = @truncate(Syscall.Error.Int, @enumToInt(std.c.getErrno(@bitCast(i64, @ptrToInt(std.c.MAP.FAILED))))), .syscall = .mmap },
};
- }
-
- return Maybe([]align(mem.page_size) u8){.result = @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length] };
+ }
+
+ return Maybe([]align(mem.page_size) u8){ .result = @ptrCast([*]align(mem.page_size) u8, @alignCast(mem.page_size, rc))[0..length] };
}
pub fn mmapFile(path: [:0]const u8, flags: u32) Maybe([]align(mem.page_size) u8) {
diff --git a/src/javascript/jsc/node/types.zig b/src/javascript/jsc/node/types.zig
index f7c8ac967..f3beeef8d 100644
--- a/src/javascript/jsc/node/types.zig
+++ b/src/javascript/jsc/node/types.zig
@@ -232,7 +232,6 @@ pub fn CallbackTask(comptime Result: type) type {
callback: JSC.C.JSObjectRef,
option: Option,
success: bool = false,
- completion: AsyncIO.Completion,
pub const Option = union {
err: JSC.SystemError,
diff --git a/src/mimalloc_arena.zig b/src/mimalloc_arena.zig
index 2c2f493ce..70ce813a4 100644
--- a/src/mimalloc_arena.zig
+++ b/src/mimalloc_arena.zig
@@ -9,19 +9,21 @@ const Allocator = mem.Allocator;
const assert = std.debug.assert;
pub const Arena = struct {
- heap: *mimalloc.mi_heap_t = undefined,
+ heap: ?*mimalloc.mi_heap_t = null,
pub fn backingAllocator(this: Arena) Allocator {
- var arena = Arena{ .heap = this.heap.backing() };
+ var arena = Arena{ .heap = this.heap.?.backing() };
return arena.allocator();
}
pub fn allocator(this: Arena) Allocator {
- return Allocator{ .ptr = this.heap, .vtable = &c_allocator_vtable };
+ @setRuntimeSafety(false);
+ return Allocator{ .ptr = this.heap.?, .vtable = &c_allocator_vtable };
}
pub fn deinit(this: *Arena) void {
mimalloc.mi_heap_destroy(this.heap);
+ this.heap = null;
}
pub fn reset(this: *Arena) void {
diff --git a/src/yield.zig b/src/yield.zig
new file mode 100644
index 000000000..135bd7e52
--- /dev/null
+++ b/src/yield.zig
@@ -0,0 +1,17 @@
+pub fn Yield(comptime Type: anytype) type {
+ return struct {
+ frame: @Frame(Type) = undefined,
+ wait: bool = false,
+
+ pub fn set(this: *@This(), frame: anytype) void {
+ this.wait = true;
+ this.frame = frame.*;
+ }
+
+ pub fn maybeResume(this: *@This()) void {
+ if (!this.wait) return;
+ this.wait = false;
+ resume this.frame;
+ }
+ };
+}