Skip to content

Commit 9855e53

Browse files
committed
save
1 parent 7eccdec commit 9855e53

23 files changed

+2471
-94
lines changed

crates/oxc_angular_compiler/src/pipeline/phases/temporary_variables.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,15 @@ fn generate_temporaries_for_update<'a>(
305305
}
306306

307307
/// Creates a DeclareVarStmt without an initializer.
308-
/// This matches Angular's behavior for temp variable declarations: `const tmp_X_Y;`
308+
/// This matches Angular's behavior for temp variable declarations: `var tmp_X_Y;`
309+
/// Note: Angular uses `var` (not `const`) for uninitialized temp variables.
310+
/// See: packages/compiler/src/output/abstract_js_emitter.ts line 6760
309311
fn create_declare_var_statement<'a>(allocator: &'a Allocator, name: &str) -> OutputStatement<'a> {
310312
OutputStatement::DeclareVar(oxc_allocator::Box::new_in(
311313
DeclareVarStmt {
312314
name: Atom::from(allocator.alloc_str(name)),
313315
value: None,
314-
modifiers: StmtModifier::FINAL,
316+
modifiers: StmtModifier::NONE, // Use `var` since there's no initializer
315317
leading_comment: None,
316318
source_span: None,
317319
},

crates/oxc_angular_compiler/tests/snapshots/integration_test__conditional_alias_with_binding_and_listener.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function TestComponent_Conditional_0_Template(rf,ctx) {
2727
function TestComponent_Template(rf,ctx) {
2828
if ((rf & 1)) { i0.ɵɵconditionalCreate(0,TestComponent_Conditional_0_Template,4,3); }
2929
if ((rf & 2)) {
30-
const tmp_0_0;
30+
var tmp_0_0;
3131
i0.ɵɵconditional(((tmp_0_0 = ctx.getParent(ctx.renderedOptions))? 0: -1),tmp_0_0);
3232
}
3333
}

crates/oxc_angular_compiler/tests/snapshots/integration_test__conditional_alias_with_listener.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function TestComponent_Conditional_0_Template(rf,ctx) {
2020
function TestComponent_Template(rf,ctx) {
2121
if ((rf & 1)) { i0.ɵɵconditionalCreate(0,TestComponent_Conditional_0_Template,4,0); }
2222
if ((rf & 2)) {
23-
const tmp_0_0;
23+
var tmp_0_0;
2424
i0.ɵɵconditional(((tmp_0_0 = ctx.getParent(ctx.renderedOptions))? 0: -1),tmp_0_0);
2525
}
2626
}

crates/oxc_angular_compiler/tests/snapshots/integration_test__if_alias_with_switch.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function TestComponent_Conditional_0_Template(rf,ctx) {
3737
i0.ɵɵtext(4,"\n");
3838
}
3939
if ((rf & 2)) {
40-
const tmp_2_0;
40+
var tmp_2_0;
4141
i0.ɵɵadvance();
4242
i0.ɵɵconditional((((tmp_2_0 = ctx.message.type) === "ConfirmNewCredential")? 1: ((tmp_2_0 === "PickCredential")? 2: 3)));
4343
}
@@ -48,7 +48,7 @@ function TestComponent_Template(rf,ctx) {
4848
i0.ɵɵpipe(1,"async");
4949
}
5050
if ((rf & 2)) {
51-
const tmp_0_0;
51+
var tmp_0_0;
5252
i0.ɵɵconditional(((tmp_0_0 = i0.ɵɵpipeBind1(1,1,ctx.data$))? 0: -1),tmp_0_0);
5353
}
5454
}

crates/oxc_angular_compiler/tests/snapshots/integration_test__pipe_in_if_object_literal.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function TestComponent_Template(rf,ctx) {
2323
i0.ɵɵpipe(2,"async");
2424
}
2525
if ((rf & 2)) {
26-
const tmp_0_0;
26+
var tmp_0_0;
2727
i0.ɵɵconditional(((tmp_0_0 = i0.ɵɵpureFunction2(5,_c0,i0.ɵɵpipeBind1(1,1,ctx.value),
2828
i0.ɵɵpipeBind1(2,3,ctx.overlay)))? 0: -1),tmp_0_0);
2929
}

crates/oxc_angular_compiler/tests/snapshots/integration_test__switch_block.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function TestComponent_Template(rf,ctx) {
3333
if ((rf & 1)) { i0.ɵɵconditionalCreate(0,TestComponent_Case_0_Template,4,0)(1,TestComponent_Case_1_Template,
3434
4,0)(2,TestComponent_Case_2_Template,4,0); }
3535
if ((rf & 2)) {
36-
const tmp_0_0;
36+
var tmp_0_0;
3737
i0.ɵɵconditional((((tmp_0_0 = ctx.value) === 1)? 0: ((tmp_0_0 === 2)? 1: 2)));
3838
}
3939
}

crates/oxc_angular_compiler/tests/snapshots/integration_test__switch_inside_for.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function TestComponent_For_1_Template(rf,ctx) {
3838
i0.ɵɵtext(4," ");
3939
}
4040
if ((rf & 2)) {
41-
const tmp_10_0;
41+
var tmp_10_0;
4242
const item_r1 = ctx.$implicit;
4343
i0.ɵɵadvance();
4444
i0.ɵɵconditional((((tmp_10_0 = item_r1.type) === "a")? 1: ((tmp_10_0 === "b")? 2: 3)));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
dist/
6+
7+
# Logs
8+
*.log
9+
npm-debug.log*
10+
pnpm-debug.log*
11+
12+
# IDE
13+
.idea/
14+
.vscode/
15+
*.swp
16+
*.swo
17+
18+
# OS files
19+
.DS_Store
20+
Thumbs.db
21+
22+
# Benchmark artifacts
23+
stats.json
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Bitwarden Web Vault - OXC Angular Benchmark
2+
3+
This benchmark compares the build performance of the OXC Angular Compiler (via Vite) against Angular's `@ngtools/webpack` (bitwarden's existing webpack build).
4+
5+
## Prerequisites
6+
7+
1. **Clone bitwarden-clients** repository as a sibling to the oxc repository:
8+
9+
```bash
10+
cd ~/workspace/github # or wherever your repos are
11+
git clone https://github.com/bitwarden/clients.git bitwarden-clients
12+
```
13+
14+
2. **Install bitwarden dependencies**:
15+
16+
```bash
17+
cd bitwarden-clients
18+
pnpm install
19+
```
20+
21+
3. **Install benchmark dependencies**:
22+
```bash
23+
cd oxc/napi/angular-compiler/benchmarks/bitwarden
24+
pnpm install
25+
```
26+
27+
## Usage
28+
29+
### Run Full Benchmark
30+
31+
Runs both cold build and incremental build comparisons:
32+
33+
```bash
34+
pnpm benchmark
35+
```
36+
37+
### Run Specific Benchmarks
38+
39+
```bash
40+
# Only cold build comparison
41+
pnpm benchmark --cold
42+
43+
# Only incremental build comparison
44+
pnpm benchmark --incremental
45+
46+
# Only test Vite/OXC build (skip webpack)
47+
pnpm benchmark --vite-only
48+
49+
# Only test Webpack build (skip Vite)
50+
pnpm benchmark --webpack-only
51+
52+
# Custom number of iterations
53+
pnpm benchmark --iterations=5
54+
55+
# Verbose output
56+
pnpm benchmark --verbose
57+
```
58+
59+
### Development Server
60+
61+
Start the Vite dev server for interactive testing:
62+
63+
```bash
64+
pnpm dev
65+
```
66+
67+
### Production Build
68+
69+
Build with Vite/OXC only:
70+
71+
```bash
72+
pnpm build
73+
```
74+
75+
## Configuration
76+
77+
### Path Customization
78+
79+
If your bitwarden-clients repository is in a different location, update the `BITWARDEN_ROOT` path in:
80+
81+
- `vite.config.ts`
82+
- `benchmark.ts`
83+
- `postcss.config.cjs`
84+
- `tailwind.config.cjs`
85+
- `tsconfig.app.json`
86+
87+
### Vite Configuration
88+
89+
The `vite.config.ts` includes:
90+
91+
- **vite-tsconfig-paths**: Resolves 70+ path aliases from bitwarden's tsconfig
92+
- **@oxc/vite-plugin-angular**: OXC's Angular compiler plugin
93+
- **SCSS preprocessing**: With proper include paths for bitwarden's styles
94+
- **PostCSS**: Matching bitwarden's configuration (tailwind, autoprefixer, etc.)
95+
- **process.env polyfills**: For bitwarden's environment variable usage
96+
97+
## What's Being Compared
98+
99+
| Aspect | Vite/OXC | Webpack/@ngtools |
100+
| ---------------- | ------------------- | ----------------------------- |
101+
| Bundler | Vite (esbuild) | Webpack |
102+
| Angular Compiler | OXC (Rust) | @ngtools/webpack (TypeScript) |
103+
| CSS Processing | Vite's CSS pipeline | MiniCssExtractPlugin |
104+
| Source Maps | Vite native | Webpack devtool |
105+
106+
## Expected Results
107+
108+
Based on initial testing, OXC's Rust-based Angular compiler typically provides:
109+
110+
- **Cold builds**: 2-5x faster than webpack
111+
- **Incremental builds**: 5-10x faster than webpack
112+
- **Output size**: Comparable (may vary based on tree-shaking differences)
113+
114+
## Troubleshooting
115+
116+
### "bitwarden-clients not found"
117+
118+
Ensure the bitwarden-clients repository is cloned to the expected location (sibling to oxc directory).
119+
120+
### "Failed to resolve import"
121+
122+
Path aliases may need adjustment. Check that:
123+
124+
1. bitwarden's `tsconfig.base.json` is accessible
125+
2. vite-tsconfig-paths plugin is configured correctly
126+
127+
### "Cannot find module '@angular/...'"
128+
129+
Run `pnpm install` in both the benchmark directory and bitwarden-clients.
130+
131+
### Style/CSS errors
132+
133+
SCSS include paths may need adjustment based on bitwarden's structure.

0 commit comments

Comments
 (0)