diff options
author | 2021-09-05 14:27:00 -0700 | |
---|---|---|
committer | 2021-09-05 14:27:00 -0700 | |
commit | e43d3e995f8ca14a1ea887a5628ca0930ecfdf9d (patch) | |
tree | 2eca27aba4bd25ebb716658dcd5028212f2ec5f6 | |
parent | c20df72d7319ff55ed4e5c9c7ff1abaab951d0bd (diff) | |
download | bun-e43d3e995f8ca14a1ea887a5628ca0930ecfdf9d.tar.gz bun-e43d3e995f8ca14a1ea887a5628ca0930ecfdf9d.tar.zst bun-e43d3e995f8ca14a1ea887a5628ca0930ecfdf9d.zip |
package.json
Former-commit-id: 2299f44cc9092dad2ef48ea54af2555c192a723e
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | Makefile | 11 | ||||
-rw-r--r-- | README.md | 32 | ||||
-rw-r--r-- | package.json | 9 | ||||
-rw-r--r-- | src/watcher.zig | 73 |
5 files changed, 61 insertions, 68 deletions
diff --git a/.gitignore b/.gitignore index 8c53f9735..6d511368b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ zig-cache *.a profile.json -/package.json node_modules .swcrc yarn.lock @@ -62,4 +61,5 @@ src/node-fallbacks/out/* src/node-fallbacks/node_modules sign.json release/ -*.dmg
\ No newline at end of file +*.dmg +sign.*.json
\ No newline at end of file @@ -36,7 +36,11 @@ jsc-copy-headers: find src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} src/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders/JavaScriptCore \; jsc-build-mac-compile: - cd src/javascript/jsc/WebKit && ICU_INCLUDE_DIRS="/usr/local/opt/icu4c/include" ./Tools/Scripts/build-jsc --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_BUILD_TYPE=relwithdebinfo" && echo "Ignore the \"has no symbols\" errors" + cd src/javascript/jsc/WebKit && ICU_INCLUDE_DIRS="/usr/local/opt/icu4c/include" ./Tools/Scripts/build-jsc --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_BUILD_TYPE=relwithdebinfo -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64" && echo "Ignore the \"has no symbols\" errors" + +jsc-build-linux-compile: + cd src/javascript/jsc/WebKit && ./Tools/Scripts/build-jsc --jsc-only --cmakeargs="-DENABLE_STATIC_JSC=ON -DCMAKE_BUILD_TYPE=relwithdebinfo + jsc-build-mac: jsc-build-mac-compile jsc-build-mac-copy @@ -103,7 +107,10 @@ mimalloc: bun-link-lld-debug: clang++ $(BUN_LLD_FLAGS) \ build/debug/macos-x86_64/bun.o \ - -o build/debug/macos-x86_64/bun + -Wl,-dead_strip \ + -ftls-model=local-exec \ + -flto \ + -o build/debug/macos-x86_64/bun bun-link-lld-release: clang++ $(BUN_LLD_FLAGS) \ @@ -23,9 +23,9 @@ npm install -g bun-cli In your project folder root (where `package.json` is): ```bash -npm install bun-framework-next +npm install -D bun-framework-next bun bun --use next -open http://localhost:3000; bun +bun ``` Here are some features of Next.js that **aren't supported** yet: @@ -69,34 +69,9 @@ Here are examples of routing source code file paths: | src/index.tsx | /src/index.tsx | | pages/index.js | /pages/index.js | -## Using Bun without `bun dev` - -`bun dev` is the recommended way to use Bun. Today, Bun is primarily intended to speed up your frontend development iteration cycle. `bun` does not implement a JavaScript minifier yet, and does not implement all the optimizations other tools do for shrinking bundle size. That means you probably should look to other tools for bundling in production. To make this split smoother, Bun strives for ecosystem compatibility (e.g. by integrating with Next.js) - -``` -bun bun ./entry-point-1.js ./entry-point-2.jsx -bun build ./entry-point-1.js ./entry-point-2.jsx --origin https://localhost:3000 --outdir=./out -``` - -You can also pass Bun a folder, and it will assume all JavaScript-like files are entry-points. This lets you use Bun's native filesystem router without a framework. - -For a `routes` directory with these files: - -- `routes/index.js` -- `routes/hello/bar.js` -- `routes/hello/baz.jsx` -- `routes/wut/wat.jsx` - -This would be the corresponding command: - -```bash -bun bun ./routes -bun build ./routes --outdir=./out -``` - # The Bun Bundling Format -`bun bun` generates a `node_modules.bun` and (optionally) a `node_modules.server.bun`. This is a new binary file format that makes it very efficient to serialize/deserialize `node_modules`. With a 2.4 GHz 8-Core Intel Core i9, metadata for +`bun bun` generates a `node_modules.bun` and (optionally) a `node_modules.server.bun`. This is a new binary file format that makes it very efficient to serialize/deserialize `node_modules`. Unlike many other bundlers, `Bun` only bundles `node_modules`. This is great for development, where most people add/update packages much less frequently than app code (which is also great for caching in browsers). To make that distinction clear, the filename defaults to `node_modules.bun`. We recommend storing `node_modules.bun` in your git repository. Since it's a binary file, it shouldn't clutter your git history and it will make your entire frontend development team move faster if they don't have to re-bundle dependencies. @@ -114,7 +89,6 @@ Bun is a project with incredibly large scope, and it's early days. | [jsx](https://www.typescriptlang.org/tsconfig)\* in tsconfig.json | TypeScript Transpiler | | [TypeScript Decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) | TypeScript Transpiler | | `@jsxPragma` comments | JavaScript Transpiler | -| Un-quoted `.env` string values | .env loader | | Sharing `.bun` files | JavaScript Bundler | | [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) (in SSR) | Bun.js | | [setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) (in SSR) | Bun.js | diff --git a/package.json b/package.json new file mode 100644 index 000000000..0537f02ae --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "peechy": "^0.4.18" + }, + "scripts": { + "build-runtime": "esbuild --target=esnext --bundle src/runtime/index.ts --format=iife --platform=browser --global-name=BUN_RUNTIME > src/runtime.out.js; cat src/runtime.footer.js >> src/runtime.out.js", + "build-fallback": "esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js" + } +} diff --git a/src/watcher.zig b/src/watcher.zig index 5b4a8431a..9948a01da 100644 --- a/src/watcher.zig +++ b/src/watcher.zig @@ -258,43 +258,48 @@ pub fn NewWatcher(comptime ContextType: type) type { parent_hash: HashType, comptime copy_file_path: bool, ) !void { - // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html - var event = std.mem.zeroes(KEvent); + const index = this.eventlist_used; + const watchlist_id = this.watchlist.len; - event.flags = os.EV_ADD | os.EV_CLEAR | os.EV_ENABLE; - // we want to know about the vnode - event.filter = std.os.EVFILT_VNODE; + if (isMac) { - // monitor: - // - Write - // - Rename + // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html + var event = std.mem.zeroes(KEvent); - // we should monitor: - // - Delete - event.fflags = std.os.NOTE_WRITE | std.os.NOTE_RENAME | std.os.NOTE_DELETE; + event.flags = os.EV_ADD | os.EV_CLEAR | os.EV_ENABLE; + // we want to know about the vnode + event.filter = std.os.EVFILT_VNODE; - // id - event.ident = @intCast(usize, fd); + // monitor: + // - Write + // - Rename - const index = this.eventlist_used; - this.eventlist_used += 1; - const watchlist_id = this.watchlist.len; - // Store the hash for fast filtering later - event.udata = @intCast(usize, watchlist_id); - this.eventlist[index] = event; + // we should monitor: + // - Delete + event.fflags = std.os.NOTE_WRITE | std.os.NOTE_RENAME | std.os.NOTE_DELETE; - // This took a lot of work to figure out the right permutation - // Basically: - // - We register the event here. - // our while(true) loop above receives notification of changes to any of the events created here. - _ = std.os.system.kevent( - try this.getQueue(), - this.eventlist[index .. index + 1].ptr, - 1, - this.eventlist[index .. index + 1].ptr, - 0, - null, - ); + // id + event.ident = @intCast(usize, fd); + + this.eventlist_used += 1; + + // Store the hash for fast filtering later + event.udata = @intCast(usize, watchlist_id); + this.eventlist[index] = event; + + // This took a lot of work to figure out the right permutation + // Basically: + // - We register the event here. + // our while(true) loop above receives notification of changes to any of the events created here. + _ = std.os.system.kevent( + try this.getQueue(), + this.eventlist[index .. index + 1].ptr, + 1, + this.eventlist[index .. index + 1].ptr, + 0, + null, + ); + } this.watchlist.appendAssumeCapacity(.{ .file_path = if (copy_file_path) try this.allocator.dupe(u8, file_path) else file_path, @@ -323,6 +328,8 @@ pub fn NewWatcher(comptime ContextType: type) type { }; const parent_hash = Watcher.getHash(Fs.PathName.init(file_path).dirWithTrailingSlash()); + const index = this.eventlist_used; + const watchlist_id = this.watchlist.len; // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html var event = std.mem.zeroes(KEvent); @@ -334,17 +341,13 @@ pub fn NewWatcher(comptime ContextType: type) type { // monitor: // - Write // - Rename - - // we should monitor: // - Delete event.fflags = std.os.NOTE_WRITE | std.os.NOTE_RENAME | std.os.NOTE_DELETE; // id event.ident = @intCast(usize, fd); - const index = this.eventlist_used; this.eventlist_used += 1; - const watchlist_id = this.watchlist.len; // Store the hash for fast filtering later event.udata = @intCast(usize, watchlist_id); this.eventlist[index] = event; |