Commit Graph

155 Commits

Author SHA1 Message Date
Jarred Sumner
7b2ab994e5 Fix possible infinite loops 2022-03-31 04:29:40 -07:00
Jarred Sumner
3434b9ecf3 Implement error page for HTTP server 2022-03-24 19:08:20 -07:00
Jarred Sumner
b8c50936a6 [JS Printer] Fix bug with printing imports for bundled code 2022-03-19 00:45:17 -07:00
Jarred Sumner
8fad34a29b [JS Transpiler] Always print escape unicode identifiers, for now 2022-03-17 18:29:02 -07:00
Jarred Sumner
44b0c8153a Source Maps for client-side errors & columns 2022-03-11 00:03:09 -08:00
Jarred Sumner
1422055304 [bun.js] Support sourcemaps! 2022-03-10 05:39:46 -08:00
Jarred Sumner
3ca113059d Update js_printer.zig 2022-03-10 00:46:00 -08:00
Jarred Sumner
01b1fee284 69% perf improvement for long string literals 2022-03-09 04:00:19 -08:00
Jarred Sumner
026657d83b make the map slightly smaller 2022-03-09 03:58:32 -08:00
Jarred Sumner
e35895888e [JS Printer] Add function for printing a string as JSON 2022-03-09 02:37:42 -08:00
Jarred Sumner
7c5c6cd519 source maps work for app code in bun dev! 2022-03-06 07:35:16 -08:00
Jarred Sumner
51fbbea1d3 upgrade zig 2022-03-04 00:20:22 -08:00
Jarred Sumner
8c271e5640 [JS Printer] Fix edgecase with optional chaining, class static block initialization and private identifiers 2022-02-27 01:52:56 -08:00
Jarred Sumner
2e1e50486f misc cleanup 2022-02-24 00:12:40 -08:00
Jarred Sumner
e77a8db546 Fix assertion in JSPrinter 2022-02-22 15:27:09 -08:00
Jarred Sumner
3a0577ba96 Use an enum for Ref instead of a buggy packed struct
Fixes a printing bug with `Symbol`
2022-02-18 20:33:04 -08:00
Jarred Sumner
3db3413929 [JS Printer] fix edgecase with printing empty export 2022-02-18 02:32:57 -08:00
Jarred Sumner
83c0ad11ac [JS Printer] Print {\n} instead of ; for empty blocks 2022-02-17 03:46:04 -08:00
Jarred Sumner
6db46c6d00 Update js_printer.zig 2022-02-16 20:34:00 -08:00
Jarred Sumner
4ba0e7b7d8 [JS Printer] Fix missing space at end of object bindings
See also https://github.com/evanw/esbuild/pull/2025
2022-02-16 20:15:35 -08:00
Jarred Sumner
68e5b0d842 [js printer] slightly optimize indent / unindent 2022-02-16 03:41:35 -08:00
Jarred Sumner
fa6bb0fc7c [js printer] Remove symbol pool 2022-02-16 03:41:11 -08:00
Jarred Sumner
08e8eabc6f Revert "Remove usage of packed struct in Ref because packed is buggy in zig"
This reverts commit 2578f426b6.
2022-02-15 20:08:35 -08:00
Jarred Sumner
2578f426b6 Remove usage of packed struct in Ref because packed is buggy in zig 2022-02-15 13:47:18 -08:00
Jarred Sumner
b9d82ee402 [JS parser] Slightly better dead code elimination & optimize AST string comparison 2022-02-13 20:44:55 -08:00
Jarred Sumner
5ec5b657be use platform-independent file preallocation 2022-02-11 14:57:11 -08:00
Jarred Sumner
d4afa5477d Move __exportDefault transform to parser 2022-02-08 01:00:46 -08:00
Jarred Sumner
d43f7aa6aa Fix #117 2022-02-07 23:34:19 -08:00
Jarred Sumner
705325d6c5 Fix #117 2022-02-07 23:34:07 -08:00
Jarred Sumner
d47e0de175 [JS Printer] Fix printing edgecase with nested vars that use object destructuring 2022-02-01 14:41:36 -08:00
Jarred Sumner
711e0cef78 Handle null/undefined module.exports better 2022-01-29 23:43:28 -08:00
Jarred Sumner
73449bf433 [JS Printer] Fix CJS <> ESM interop edgecase
For code like this:

```js
module.exports = require("foo")
```

If `"foo"` is bundled, we should access it as the namespace reference from the bundle. Previously, we assumed it would be a property access.
2022-01-29 23:43:10 -08:00
Jarred Sumner
97d17904d3 Update AST layout to store capacity for items
We want to be able to push to the list
2022-01-28 19:26:03 -08:00
Jarred Sumner
87c95d45f7 Reset imported_module_ids 2022-01-22 15:00:25 -08:00
Jarred Sumner
7a87e41ab8 Update js_printer.zig 2022-01-21 03:36:27 -08:00
Jarred Sumner
d3a93d5273 fs.*Sync(), bun wiptest, and More ™ (#106)
* very very wip

* almost ready to fix the errors

* Update identity_context.zig

* Update base.zig

* [bun test] It runs successfully

* Remove unnecessary call

* [Bun.js] Improve JS <> Zig unicode string interop

This fixes longstanding unicode bugs with `console.log` & `fetch`.

I believe @evanwashere reported this first awhile ago

* [Bun.js] Implement `Object.is()` binding and a way to set a timeout for script execution

* Update PLCrashReport.zig

* [Bun.js] Make `console.log` more closely match Node.js and Deno

* [Bun.js] Implement formatting specifier for console.*

* Implement `console.clear()`

* bug fix

* Support console.clear()

* Buffer stderr

* [bun test] Begin implementing Node.js `fs`

* Update darwin_c.zig

* Implement more of `fs`

* `mkdir`, `mkdir` recursive, `mkdtemp`

* `open`, `read` (and pread)

* Move some things into more files

* Implement readdir

* `readFile`, `readLink`, and `realpath`

* `writeFile`, `symlink`, `chown`, `rename`, `stat`, `unlink`, `truncate`

* `lutimes`

* Implement `SystemError` and begin wiring up the `fs` module

* `"fs"` - Most of the arguments / validation

* `fs` - Rest of the arguments / validations

* Begin wiring up the `fs` module

* Fix all the build errors

* support printing typed arrays in console.log

* It...works?

* Support `require("fs")`, `import fs from 'fs';`, `import * as fs from 'fs'`

* Fix a couple bugs

* get rid of the crash reporter for now

* Update fs.exports.js

* [bun.js] slight improvement to startup time

* [bun.js] Improve error message printing

* [Bun.js] Add `Bun.gc()` to run the garbage collector manually and report heap size

* [Bun.js] Add Bun.generateHeapSnapshot to return what JS types are using memory

* [Bun.js] Add `Bun.shrink()` to tell JSC to shrink the VM size

* Improve encoding reader

* [bun.js] Improve callback & microtask performance

* Update node_fs.zig

* Implement `console.assert`

* simple test

* [Bun.js] Prepare for multiple globals/realms to support testing

* Create callbacks-overhead.mjs

* Update http.zig

* [Bun.js] Implement `queueMicrotask`

* Add test for queueMicrotask

* 😪

* [Bun.js] Implement `process.versions`, `process.pid`, `process.ppid`, `process.nextTick`, `process.versions`,

* Implement `process.env.toJSON()`

* [Bun.js] Improve performance of `fs.existsSync`

* 💅

* [Bun.js] Implement `process.chdir(str)` and `process.cwd()`, support up to 4 args in `process.nextTick`

* Make creating Zig::Process lazy

* Split processi nto separte file

* [Bun.js] Node.js Streams - Part 1/?

* [Bun.js] Node.js streams 2/?

* WIP streams

* fix crash

* Reduce allocations in many places

* swap

* Make `bun` start 2ms faster

* Always use an apiLock()

* libBacktrace doesn't really work yet

* Fix crash in the upgrade checker

* Clean up code for importing the runtime when not bundling

* 📷

* Update linker.zig

* 68!

* backtrace

* no, really backtrace

* Fix

* Linux fixes

* Fixes on Linux

* Update mimalloc

* [bun test] Automatically scan for {.test,_test,.spec,_spec}.{jsx,tsx,js,cts,mts,ts,cjs}
2022-01-19 02:29:07 -08:00
Jarred Sumner
3cd129544e [JS Parser] Reduce memory usage by ~8% 2022-01-05 13:12:11 -08:00
Jarred Sumner
5311219de7 dead code 2022-01-03 22:26:24 -08:00
luke miles
7f33846005 copy: replace Bun with bun (#99)
Most CLI tools have the style convention of referring to themselves in
lowercase. It is, after all, the name that users type in when using
the tool. This PR maintains that convention in bun.

"Drop the uppercase B, it's cleaner"
2022-01-02 03:09:51 -08:00
Jarred Sumner
e75c711c68 Upgrade to latest Zig, remove dependency on patched version of Zig (#96)
* Prepare to upgrade zig

* zig fmt

* AllocGate

* Update data_url.zig

* wip

* few files

* just headers now?

* I think everything works?

* Update mimalloc

* Update hash_map.zig

* Perf improvements to compensate for Allocgate

* Bump

* 📷

* Update bun.lockb

* Less branching

* [js parser] Slightly reduce memory usage

* Update js_parser.zig

* WIP remove unused

* [JS parser] WIP support for `with` keyword

* Remove more dead code

* Fix all the build errors!

* cleanup

* Move `network_thread` up

* Bump peechy

* Update README.md
2021-12-30 21:12:32 -08:00
Jarred Sumner
336a4b6ac2 Prepare to run unit tests & remove some dead code (#92)
* Remove some dead code

* 💀 code

* Fix the zig tests

* [JS Printer] Print integers faster & less scientific notation on decimals

* 💀 dead code

* skip

* Run all the unit tests
2021-12-27 18:06:31 -08:00
Jarred Sumner
2e9af40bca [transpiler] Don't insert import statements for disabled require() 2021-12-16 17:56:32 -08:00
Jarred Sumner
39af1ccc7c Update js_printer.zig 2021-12-16 01:48:50 -08:00
Jarred Sumner
0f853a2fee Update js_printer.zig 2021-12-16 01:33:07 -08:00
Jarred Sumner
92f3efeac2 [bundler][JS transpiler] Improve reliability of ESM <> CommonJS interop
This fixes a number of issues caused by not using live bindings when referencing bundled code. This also fixes an issue with libraries looping over `Object.keys(moduleNamespace)`
2021-12-16 01:29:45 -08:00
Jarred Sumner
8af6ad7278 wip fix live bindings 2021-12-15 17:08:04 -08:00
Jarred Sumner
01d1f1d258 Fix #66
embarassing!
2021-11-15 15:51:39 -08:00
Jarred Sumner
bba74499e5 [JS Printer] Don't escape slashes 2021-11-15 15:39:21 -08:00
Jarred Sumner
1a60d7df98 [JS Printer] Fix bug with template literals 2021-11-15 15:38:49 -08:00
Jarred Sumner
241525947c [JS Printer] Fix bug with optional chain 2021-11-08 15:37:31 -08:00