Michael H
31202ec210
In error messages, dim current cwd to help with identifying local code ( #22469 )
...
### What does this PR do?
<img width="577" height="273" alt="image"
src="https://github.com/user-attachments/assets/0b20f0a5-45d2-4acf-bb72-85d52f7f1bfb "
/>
not sure if its a good idea though.
### How did you verify your code works?
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
2025-09-15 23:41:50 -07:00
robobun
20dddd1819
feat(minify): optimize Error constructors by removing 'new' keyword ( #22493 )
...
## Summary
- Refactored `maybeMarkConstructorAsPure` to `minifyGlobalConstructor`
that returns `?Expr`
- Added minification optimizations for global constructors that work
identically with/without `new`
- Converts constructors to more compact forms: `new Object()` → `{}`,
`new Array()` → `[]`, etc.
- Fixed issue where minification was incorrectly applied to runtime
node_modules code
## Details
This PR refactors the existing `maybeMarkConstructorAsPure` function to
`minifyGlobalConstructor` and changes it to return an optional
expression. This enables powerful minification optimizations for global
constructors.
### Optimizations Added:
#### 1. Error Constructors (4 bytes saved each)
- `new Error(...)` → `Error(...)`
- `new TypeError(...)` → `TypeError(...)`
- `new SyntaxError(...)` → `SyntaxError(...)`
- `new RangeError(...)` → `RangeError(...)`
- `new ReferenceError(...)` → `ReferenceError(...)`
- `new EvalError(...)` → `EvalError(...)`
- `new URIError(...)` → `URIError(...)`
- `new AggregateError(...)` → `AggregateError(...)`
#### 2. Object Constructor
- `new Object()` → `{}` (11 bytes saved)
- `new Object({a: 1})` → `{a: 1}` (11 bytes saved)
- `new Object([1, 2])` → `[1, 2]` (11 bytes saved)
- `new Object(null)` → `{}` (15 bytes saved)
- `new Object(undefined)` → `{}` (20 bytes saved)
#### 3. Array Constructor
- `new Array()` → `[]` (10 bytes saved)
- `new Array(1, 2, 3)` → `[1, 2, 3]` (9 bytes saved)
- `new Array(5)` → `Array(5)` (4 bytes saved, preserves sparse array
semantics)
#### 4. Function and RegExp Constructors
- `new Function(...)` → `Function(...)` (4 bytes saved)
- `new RegExp(...)` → `RegExp(...)` (4 bytes saved)
### Important Fixes:
- Added check to prevent minification of node_modules code at runtime
(only applies during bundling)
- Preserved sparse array semantics for `new Array(number)`
- Extracted `callFromNew` helper to reduce code duplication
### Size Impact:
- React SSR bundle: 463 bytes saved
- Each optimization safely preserves JavaScript semantics
## Test plan
✅ All tests pass:
- Added comprehensive tests in `bundler_minify.test.ts`
- Verified Error constructors work identically with/without `new`
- Tested Object/Array literal conversions
- Ensured sparse array semantics are preserved
- Updated source map positions in `bundler_npm.test.ts`
🤖 Generated with [Claude Code](https://claude.ai/code )
---------
Co-authored-by: Claude Bot <claude-bot@bun.sh >
Co-authored-by: Claude <noreply@anthropic.com >
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com >
Co-authored-by: Dylan Conway <dylan.conway567@gmail.com >
2025-09-09 15:00:40 -07:00
Jarred Sumner
14b439a115
Fix formatters not running in CI + delete unnecessary files ( #19433 )
2025-05-08 23:22:16 -07:00
chloe caruso
f912e0abc4
hot module reloading for HTML import development mode ( #16955 )
2025-02-08 00:31:30 -08:00
Jarred Sumner
da2dd657b1
Fix various bugs with function names and source mappings involving eval and node:vm ( #16212 )
2025-01-07 20:21:50 -08:00
Jarred Sumner
774e30d383
Make originalLine and originalColumn getter calls not observable ( #15951 )
2024-12-23 03:40:51 -08:00
Jarred Sumner
cd6785771e
run prettier and add back format action ( #13722 )
2024-09-03 21:32:52 -07:00
Jarred Sumner
36f1bd3694
Truncate source lines in error messages ( #9832 )
...
* Truncate source lines in error messages
* Update .prettierignore
* trim
* fix
* try
* fix
* 1 more time
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com >
2024-04-03 02:46:10 -07:00
Meghan Denny
3a7df3f6c7
windows: add more passing test ( #8615 )
2024-02-01 13:45:47 -08:00
Dylan Conway
4f98336f86
fix(windows): fix installing non-ascii paths and make normalizeBuf generic ( #8608 )
...
* comptime type normalizeStringBuf
* delete
* revert
* revert revert
* revert
* remove unused
* remove unnecessary assert
* add comment
* remove normalize, need ../
* use Output.err
* update error message
* generic T suffix
* fix windows build
* more fix build
* more fix build
* mkdiratZ
* update test
* [autofix.ci] apply automated fixes
* update snapshot again
* fix merge
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-01-31 22:44:23 -08:00
dave caruso
072f2f15ea
ci: run windows tests and also run them concurrently ( #7758 )
2024-01-12 17:02:20 -08:00
Jarred Sumner
bf32d36e4c
Cleanup how build errors are displayed slightly ( #7223 )
...
* Cleanup error formatting a little
* Add error for using import statement with CommonJS-only features
* Update js_ast.zig
* Further tweaks to formatting, also print error.cause
* Add some snapshot tests for errors
* Make these snapshot tests
* Ignore mimalloc warnings
* Update error message parsing in bundling tests
* Increase timeout on the test
* Update expectBundled.ts
* Update test
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com >
2023-11-20 15:07:13 -08:00