From 57a06745a48093c25d0f4729ccea41a918d6427d Mon Sep 17 00:00:00 2001 From: dave caruso Date: Thu, 7 Sep 2023 04:58:44 -0700 Subject: [PATCH] Progress for Next.js (#4468) * L * ipc * asdfghjkl * dfghjk * it works! * types * patches for next.js * sdfghj * wsdfgn,./ * this * yolo * okay loser * asdfghjk * add some more APIs * MESS * sdfghjkl * remove native events from streams * stuff * remove lazy(primordials) test * debugging * okay * less fake extensions object * fix `Buffer.toString()` args logic * fix deserialize * make tests work * add test for `Buffer.toString` args * Update server.zig * remove test * update test * Update spawn-streaming-stdin.test.ts * fix linux build * Update fs.test.ts * cli message improvements * dfshaj * Fix fs.watch bug maybe? * remove --------- Co-authored-by: Dylan Conway --- .vscode/launch.json | 2 +- bench/expect-to-equal/README.md | 2 +- docs/bundler/executables.md | 2 +- docs/bundler/index.md | 2 +- docs/runtime/nodejs-apis.md | 10 +- packages/bun-ecosystem/src/runner.ts | 2 +- packages/bun-types/bun.d.ts | 32 + packages/bun-types/module.d.ts | 2 +- packages/bun-usockets/src/libusockets.h | 3 + packages/bun-usockets/src/socket.c | 40 + src/bun.js/api/bun.classes.ts | 5 + src/bun.js/api/bun.zig | 1 + src/bun.js/api/bun/subprocess.zig | 159 +- src/bun.js/bindings/CommonJSModuleRecord.cpp | 8 +- src/bun.js/bindings/ImportMetaObject.cpp | 14 + src/bun.js/bindings/JSBuffer.cpp | 69 +- src/bun.js/bindings/JSReadableHelper.cpp | 263 - src/bun.js/bindings/JSReadableHelper.h | 13 - src/bun.js/bindings/JSReadableState.cpp | 426 - src/bun.js/bindings/JSReadableState.h | 154 - src/bun.js/bindings/Process.cpp | 78 + src/bun.js/bindings/Process.lut.h | 267 +- src/bun.js/bindings/Serialization.cpp | 49 + src/bun.js/bindings/ZigGeneratedClasses.cpp | 32 + src/bun.js/bindings/ZigGlobalObject.cpp | 64 +- src/bun.js/bindings/ZigGlobalObject.h | 13 +- src/bun.js/bindings/bindings.zig | 7 + src/bun.js/bindings/generated_classes.zig | 3 + src/bun.js/bindings/webcore/EventEmitter.h | 2 + src/bun.js/ipc.zig | 238 + src/bun.js/javascript.zig | 127 +- src/bun.js/module_loader.zig | 362 +- src/bun.js/modules/NodeModuleModule.h | 44 +- src/bun.js/node/node_fs_watcher.zig | 11 +- src/bun.js/node/types.zig | 2 +- src/bun.js/rare_data.zig | 18 + src/bun.zig | 7 + src/bunfig.zig | 24 +- src/cli.zig | 288 +- src/cli/bunx_command.zig | 26 +- src/cli/create_command.zig | 2 +- src/cli/discord_command.zig | 2 +- src/cli/init_command.zig | 2 +- src/cli/package_manager_command.zig | 4 +- src/cli/test_command.zig | 11 +- src/deps/uws.zig | 26 +- src/js/_codegen/build-modules.ts | 2 +- src/js/_codegen/replacements.ts | 4 +- src/js/builtins.d.ts | 1 - src/js/builtins/Module.ts | 1 - src/js/node/async_hooks.ts | 2 + src/js/node/child_process.js | 93 +- src/js/node/fs.js | 2 +- src/js/node/fs.promises.ts | 35 + src/js/node/http.ts | 5 +- src/js/node/stream.js | 427 +- src/js/node/v8.ts | 21 +- src/js/out/InternalModuleRegistryConstants.h | 84 +- src/js/out/ResolvedSourceTag.zig | 10 +- src/js/out/WebCoreJSBuiltins.cpp | 3918 +++++----- src/js/out/WebCoreJSBuiltins.d.ts | 144 +- src/js/out/WebCoreJSBuiltins.h | 6938 ++++++++--------- src/js/private.d.ts | 17 +- src/js/thirdparty/ws.js | 15 + src/linker.zig | 508 +- src/open.zig | 18 +- src/report.zig | 4 +- src/sys.zig | 4 +- test/js/bun/resolve/import-meta.test.js | 8 +- .../bun/spawn/spawn-streaming-stdin.test.ts | 2 +- test/js/node/buffer.test.js | 26 +- test/js/node/fs/fs.test.ts | 10 +- test/js/node/stream/bufferlist.test.ts | 25 +- 73 files changed, 7878 insertions(+), 7364 deletions(-) delete mode 100644 src/bun.js/bindings/JSReadableHelper.cpp delete mode 100644 src/bun.js/bindings/JSReadableHelper.h delete mode 100644 src/bun.js/bindings/JSReadableState.cpp delete mode 100644 src/bun.js/bindings/JSReadableState.h create mode 100644 src/bun.js/bindings/Serialization.cpp create mode 100644 src/bun.js/ipc.zig diff --git a/.vscode/launch.json b/.vscode/launch.json index 862c583a5b..c5da977885 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,7 @@ "request": "launch", "name": "bun test [file]", "program": "bun-debug", - "args": ["test", "${file}"], + "args": ["create", "--help"], // The cwd here must be the same as in CI. Or you will cause test failures that only happen in CI. "cwd": "${workspaceFolder}/test", "env": { diff --git a/bench/expect-to-equal/README.md b/bench/expect-to-equal/README.md index d9023f4a73..3e7e3594b7 100644 --- a/bench/expect-to-equal/README.md +++ b/bench/expect-to-equal/README.md @@ -10,7 +10,7 @@ To run in Bun: ```bash # so it doesn't run the vitest one -bun wiptest expect-to-equal.test.js +bun test expect-to-equal.test.js ``` To run in Jest: diff --git a/docs/bundler/executables.md b/docs/bundler/executables.md index 081d570500..b654ec8102 100644 --- a/docs/bundler/executables.md +++ b/docs/bundler/executables.md @@ -28,7 +28,7 @@ All imported files and packages are bundled into the executable, along with a co - `--outdir` β€” use `outfile` instead. - `--external` - `--splitting` -- `--publicPath` +- `--public-path` {% /callout %} diff --git a/docs/bundler/index.md b/docs/bundler/index.md index bfbed2077c..585a6ac52a 100644 --- a/docs/bundler/index.md +++ b/docs/bundler/index.md @@ -960,7 +960,7 @@ By specifying `.` as `root`, the generated file structure will look like this: A prefix to be appended to any import paths in bundled code. - + In many cases, generated bundles will contain no `import` statements. After all, the goal of bundling is to combine all of the code into a single file. However there are a number of cases with the generated bundles will contain `import` statements. diff --git a/docs/runtime/nodejs-apis.md b/docs/runtime/nodejs-apis.md index 1dc0c04b69..2bdc1fe507 100644 --- a/docs/runtime/nodejs-apis.md +++ b/docs/runtime/nodejs-apis.md @@ -18,7 +18,7 @@ This page is updated regularly to reflect compatibility status of the latest ver ### [`node:child_process`](https://nodejs.org/api/child_process.html) -🟑 Missing IPC, `Stream` stdio, `proc.gid`, `proc.uid`, advanced serialization. +🟑 Missing `Stream` stdio, `proc.gid`, `proc.uid`. IPC has partial support and only current only works with other `bun` processes. ### [`node:cluster`](https://nodejs.org/api/cluster.html) @@ -26,7 +26,7 @@ This page is updated regularly to reflect compatibility status of the latest ver ### [`node:console`](https://nodejs.org/api/console.html) -🟒 Recommended to use `console` global instead +🟑 Missing `Console` constructor. ### [`node:crypto`](https://nodejs.org/api/crypto.html) @@ -146,7 +146,7 @@ This page is updated regularly to reflect compatibility status of the latest ver ### [`node:util`](https://nodejs.org/api/util.html) -🟑 Missing `util.MIMEParams` `util.MIMEType` `util.formatWithOptions()` `util.getSystemErrorMap()` `util.getSystemErrorName()` `util.parseArgs()` `util.stripVTControlCharacters()` `util.transferableAbortController()` `util.transferableAbortSignal()`. +🟑 Missing `util.MIMEParams` `util.MIMEType` `util.getSystemErrorMap()` `util.getSystemErrorName()` `util.parseArgs()` `util.stripVTControlCharacters()` `util.transferableAbortController()` `util.transferableAbortSignal()`. ### [`node:v8`](https://nodejs.org/api/v8.html) @@ -166,7 +166,7 @@ This page is updated regularly to reflect compatibility status of the latest ver ### [`node:zlib`](https://nodejs.org/api/zlib.html) -🟑 Missing `zlib.brotli*`. Some methods are not optimized. +🟑 Missing `zlib.brotli*`. Has not been optimized.