angular-rust-plugins 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +22 -0
  2. package/{dist/binding → binding}/angular-binding.darwin-arm64.node +0 -0
  3. package/binding/index.d.ts +13 -0
  4. package/{dist/binding → binding}/index.js +110 -132
  5. package/package.json +35 -44
  6. package/dist/README.md +0 -306
  7. package/dist/binding/index.d.ts +0 -13
  8. package/dist/package.json +0 -77
  9. /package/{dist/binding → binding}/package.json +0 -0
  10. /package/{dist/compiler → compiler}/index.cjs +0 -0
  11. /package/{dist/compiler → compiler}/index.cjs.map +0 -0
  12. /package/{dist/compiler → compiler}/index.d.cts +0 -0
  13. /package/{dist/compiler → compiler}/index.d.ts +0 -0
  14. /package/{dist/compiler → compiler}/index.js +0 -0
  15. /package/{dist/compiler → compiler}/index.js.map +0 -0
  16. /package/{dist/compiler → compiler}/vite.cjs +0 -0
  17. /package/{dist/compiler → compiler}/vite.cjs.map +0 -0
  18. /package/{dist/compiler → compiler}/vite.d.cts +0 -0
  19. /package/{dist/compiler → compiler}/vite.d.ts +0 -0
  20. /package/{dist/compiler → compiler}/vite.js +0 -0
  21. /package/{dist/compiler → compiler}/vite.js.map +0 -0
  22. /package/{dist/index.cjs → index.cjs} +0 -0
  23. /package/{dist/index.cjs.map → index.cjs.map} +0 -0
  24. /package/{dist/index.d.cts → index.d.cts} +0 -0
  25. /package/{dist/index.d.ts → index.d.ts} +0 -0
  26. /package/{dist/index.js → index.js} +0 -0
  27. /package/{dist/index.js.map → index.js.map} +0 -0
  28. /package/{dist/linker → linker}/esbuild.cjs +0 -0
  29. /package/{dist/linker → linker}/esbuild.cjs.map +0 -0
  30. /package/{dist/linker → linker}/esbuild.d.cts +0 -0
  31. /package/{dist/linker → linker}/esbuild.d.ts +0 -0
  32. /package/{dist/linker → linker}/esbuild.js +0 -0
  33. /package/{dist/linker → linker}/esbuild.js.map +0 -0
  34. /package/{dist/linker → linker}/index.cjs +0 -0
  35. /package/{dist/linker → linker}/index.cjs.map +0 -0
  36. /package/{dist/linker → linker}/index.d.cts +0 -0
  37. /package/{dist/linker → linker}/index.d.ts +0 -0
  38. /package/{dist/linker → linker}/index.js +0 -0
  39. /package/{dist/linker → linker}/index.js.map +0 -0
  40. /package/{dist/linker → linker}/rolldown.cjs +0 -0
  41. /package/{dist/linker → linker}/rolldown.cjs.map +0 -0
  42. /package/{dist/linker → linker}/rolldown.d.cts +0 -0
  43. /package/{dist/linker → linker}/rolldown.d.ts +0 -0
  44. /package/{dist/linker → linker}/rolldown.js +0 -0
  45. /package/{dist/linker → linker}/rolldown.js.map +0 -0
  46. /package/{dist/linker → linker}/vite.cjs +0 -0
  47. /package/{dist/linker → linker}/vite.cjs.map +0 -0
  48. /package/{dist/linker → linker}/vite.d.cts +0 -0
  49. /package/{dist/linker → linker}/vite.d.ts +0 -0
  50. /package/{dist/linker → linker}/vite.js +0 -0
  51. /package/{dist/linker → linker}/vite.js.map +0 -0
  52. /package/{dist/types-BTaYbdhr.d.cts → types-BTaYbdhr.d.cts} +0 -0
  53. /package/{dist/types-BTaYbdhr.d.ts → types-BTaYbdhr.d.ts} +0 -0
package/README.md CHANGED
@@ -4,6 +4,14 @@ High-performance Angular linker and compiler plugins powered by Rust. Supports *
4
4
 
5
5
  This package bundles the Angular Rust binding - no additional dependencies needed!
6
6
 
7
+ ## ✨ Features
8
+
9
+ - ✅ **Standard Directives**: Full support for `*ngIf` (with `else`, `then`, `as`) and `*ngFor` (with all context variables).
10
+ - ✅ **Template Parity**: 100% output parity with NGTSC for template instructions and `consts` array sorting.
11
+ - ✅ **Change Detection**: Optimized listener emission for `OnPush` components.
12
+ - ✅ **Signal Support**: Full support for modern Angular signals (`input()`, `output()`, `computed()`, etc.).
13
+ - ✅ **Blazing Fast**: Uses the Rust-based compiler for ~3-5x faster compilation compared to standard TypeScript-based compilation.
14
+
7
15
  ## 🚀 Installation
8
16
 
9
17
  ```bash
@@ -277,6 +285,20 @@ Ensure your `tsconfig.json` includes:
277
285
 
278
286
  The compiler plugin includes HMR support for `.html` template files. When you modify a template, the corresponding component will be recompiled automatically.
279
287
 
288
+ ## 💡 Advanced Directive Support
289
+
290
+ The compiler now achieves full feature parity with the standard Angular compiler for core structural directives:
291
+
292
+ ### `*ngFor` Support
293
+ - **Full Context Access**: Support for `index`, `count`, `first`, `last`, `even`, `odd`.
294
+ - **Performance**: Automatic optimization of context access in event listeners.
295
+ - **Parity**: Identical `consts` array ordering through source-span sorting.
296
+
297
+ ### `*ngIf` Support
298
+ - **Complex Templates**: Support for `else` and `then` templates with `TemplateRef` extraction.
299
+ - **As Syntax**: Support for the `as` local variable binding (e.g., `*ngIf="obs$ | async as val"`).
300
+ - **Context Isolation**: Correct variable scoping and restoration for nested conditionals.
301
+
280
302
  ## ⚡ Performance
281
303
 
282
304
  **2-5x faster** than TypeScript-based Angular compiler with lower memory usage.
@@ -0,0 +1,13 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ export declare function linkFile(sourceCode: string, filename: string): string;
7
+ export declare class Compiler {
8
+ constructor();
9
+ compile(filename: string, content: string): string;
10
+ constructor();
11
+ compile(filename: string, content: string): string;
12
+ linkFile(filename: string, sourceCode: string): string;
13
+ }
@@ -5,26 +5,26 @@
5
5
  /* auto-generated by NAPI-RS */
6
6
 
7
7
  const { existsSync, readFileSync } = require('fs')
8
- const { join } = require('path')
8
+ const { join } = require('path');
9
9
 
10
- const { platform, arch } = process
10
+ const { platform, arch } = process;
11
11
 
12
- let nativeBinding = null
13
- let localFileExisted = false
14
- let loadError = null
12
+ let nativeBinding = null;
13
+ let localFileExisted = false;
14
+ let loadError = null;
15
15
 
16
16
  function isMusl() {
17
17
  // For Node 10
18
18
  if (!process.report || typeof process.report.getReport !== 'function') {
19
19
  try {
20
- const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
- return readFileSync(lddPath, 'utf8').includes('musl')
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim();
21
+ return readFileSync(lddPath, 'utf8').includes('musl');
22
22
  } catch (e) {
23
- return true
23
+ return true;
24
24
  }
25
25
  } else {
26
- const { glibcVersionRuntime } = process.report.getReport().header
27
- return !glibcVersionRuntime
26
+ const { glibcVersionRuntime } = process.report.getReport().header;
27
+ return !glibcVersionRuntime;
28
28
  }
29
29
  }
30
30
 
@@ -32,285 +32,263 @@ switch (platform) {
32
32
  case 'android':
33
33
  switch (arch) {
34
34
  case 'arm64':
35
- localFileExisted = existsSync(join(__dirname, 'angular-binding.android-arm64.node'))
35
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.android-arm64.node'));
36
36
  try {
37
37
  if (localFileExisted) {
38
- nativeBinding = require('./angular-binding.android-arm64.node')
38
+ nativeBinding = require('./angular-binding.android-arm64.node');
39
39
  } else {
40
- nativeBinding = require('angular-rust-binding-android-arm64')
40
+ nativeBinding = require('angular-rust-binding-android-arm64');
41
41
  }
42
42
  } catch (e) {
43
- loadError = e
43
+ loadError = e;
44
44
  }
45
- break
45
+ break;
46
46
  case 'arm':
47
- localFileExisted = existsSync(join(__dirname, 'angular-binding.android-arm-eabi.node'))
47
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.android-arm-eabi.node'));
48
48
  try {
49
49
  if (localFileExisted) {
50
- nativeBinding = require('./angular-binding.android-arm-eabi.node')
50
+ nativeBinding = require('./angular-binding.android-arm-eabi.node');
51
51
  } else {
52
- nativeBinding = require('angular-rust-binding-android-arm-eabi')
52
+ nativeBinding = require('angular-rust-binding-android-arm-eabi');
53
53
  }
54
54
  } catch (e) {
55
- loadError = e
55
+ loadError = e;
56
56
  }
57
- break
57
+ break;
58
58
  default:
59
- throw new Error(`Unsupported architecture on Android ${arch}`)
59
+ throw new Error(`Unsupported architecture on Android ${arch}`);
60
60
  }
61
- break
61
+ break;
62
62
  case 'win32':
63
63
  switch (arch) {
64
64
  case 'x64':
65
- localFileExisted = existsSync(
66
- join(__dirname, 'angular-binding.win32-x64-msvc.node')
67
- )
65
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.win32-x64-msvc.node'));
68
66
  try {
69
67
  if (localFileExisted) {
70
- nativeBinding = require('./angular-binding.win32-x64-msvc.node')
68
+ nativeBinding = require('./angular-binding.win32-x64-msvc.node');
71
69
  } else {
72
- nativeBinding = require('angular-rust-binding-win32-x64-msvc')
70
+ nativeBinding = require('angular-rust-binding-win32-x64-msvc');
73
71
  }
74
72
  } catch (e) {
75
- loadError = e
73
+ loadError = e;
76
74
  }
77
- break
75
+ break;
78
76
  case 'ia32':
79
- localFileExisted = existsSync(
80
- join(__dirname, 'angular-binding.win32-ia32-msvc.node')
81
- )
77
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.win32-ia32-msvc.node'));
82
78
  try {
83
79
  if (localFileExisted) {
84
- nativeBinding = require('./angular-binding.win32-ia32-msvc.node')
80
+ nativeBinding = require('./angular-binding.win32-ia32-msvc.node');
85
81
  } else {
86
- nativeBinding = require('angular-rust-binding-win32-ia32-msvc')
82
+ nativeBinding = require('angular-rust-binding-win32-ia32-msvc');
87
83
  }
88
84
  } catch (e) {
89
- loadError = e
85
+ loadError = e;
90
86
  }
91
- break
87
+ break;
92
88
  case 'arm64':
93
- localFileExisted = existsSync(
94
- join(__dirname, 'angular-binding.win32-arm64-msvc.node')
95
- )
89
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.win32-arm64-msvc.node'));
96
90
  try {
97
91
  if (localFileExisted) {
98
- nativeBinding = require('./angular-binding.win32-arm64-msvc.node')
92
+ nativeBinding = require('./angular-binding.win32-arm64-msvc.node');
99
93
  } else {
100
- nativeBinding = require('angular-rust-binding-win32-arm64-msvc')
94
+ nativeBinding = require('angular-rust-binding-win32-arm64-msvc');
101
95
  }
102
96
  } catch (e) {
103
- loadError = e
97
+ loadError = e;
104
98
  }
105
- break
99
+ break;
106
100
  default:
107
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
101
+ throw new Error(`Unsupported architecture on Windows: ${arch}`);
108
102
  }
109
- break
103
+ break;
110
104
  case 'darwin':
111
- localFileExisted = existsSync(join(__dirname, 'angular-binding.darwin-universal.node'))
105
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.darwin-universal.node'));
112
106
  try {
113
107
  if (localFileExisted) {
114
- nativeBinding = require('./angular-binding.darwin-universal.node')
108
+ nativeBinding = require('./angular-binding.darwin-universal.node');
115
109
  } else {
116
- nativeBinding = require('angular-rust-binding-darwin-universal')
110
+ nativeBinding = require('angular-rust-binding-darwin-universal');
117
111
  }
118
- break
112
+ break;
119
113
  } catch {}
120
114
  switch (arch) {
121
115
  case 'x64':
122
- localFileExisted = existsSync(join(__dirname, 'angular-binding.darwin-x64.node'))
116
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.darwin-x64.node'));
123
117
  try {
124
118
  if (localFileExisted) {
125
- nativeBinding = require('./angular-binding.darwin-x64.node')
119
+ nativeBinding = require('./angular-binding.darwin-x64.node');
126
120
  } else {
127
- nativeBinding = require('angular-rust-binding-darwin-x64')
121
+ nativeBinding = require('angular-rust-binding-darwin-x64');
128
122
  }
129
123
  } catch (e) {
130
- loadError = e
124
+ loadError = e;
131
125
  }
132
- break
126
+ break;
133
127
  case 'arm64':
134
- localFileExisted = existsSync(
135
- join(__dirname, 'angular-binding.darwin-arm64.node')
136
- )
128
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.darwin-arm64.node'));
137
129
  try {
138
130
  if (localFileExisted) {
139
- nativeBinding = require('./angular-binding.darwin-arm64.node')
131
+ nativeBinding = require('./angular-binding.darwin-arm64.node');
140
132
  } else {
141
- nativeBinding = require('angular-rust-binding-darwin-arm64')
133
+ nativeBinding = require('angular-rust-binding-darwin-arm64');
142
134
  }
143
135
  } catch (e) {
144
- loadError = e
136
+ loadError = e;
145
137
  }
146
- break
138
+ break;
147
139
  default:
148
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
140
+ throw new Error(`Unsupported architecture on macOS: ${arch}`);
149
141
  }
150
- break
142
+ break;
151
143
  case 'freebsd':
152
144
  if (arch !== 'x64') {
153
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
145
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
154
146
  }
155
- localFileExisted = existsSync(join(__dirname, 'angular-binding.freebsd-x64.node'))
147
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.freebsd-x64.node'));
156
148
  try {
157
149
  if (localFileExisted) {
158
- nativeBinding = require('./angular-binding.freebsd-x64.node')
150
+ nativeBinding = require('./angular-binding.freebsd-x64.node');
159
151
  } else {
160
- nativeBinding = require('angular-rust-binding-freebsd-x64')
152
+ nativeBinding = require('angular-rust-binding-freebsd-x64');
161
153
  }
162
154
  } catch (e) {
163
- loadError = e
155
+ loadError = e;
164
156
  }
165
- break
157
+ break;
166
158
  case 'linux':
167
159
  switch (arch) {
168
160
  case 'x64':
169
161
  if (isMusl()) {
170
- localFileExisted = existsSync(
171
- join(__dirname, 'angular-binding.linux-x64-musl.node')
172
- )
162
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.linux-x64-musl.node'));
173
163
  try {
174
164
  if (localFileExisted) {
175
- nativeBinding = require('./angular-binding.linux-x64-musl.node')
165
+ nativeBinding = require('./angular-binding.linux-x64-musl.node');
176
166
  } else {
177
- nativeBinding = require('angular-rust-binding-linux-x64-musl')
167
+ nativeBinding = require('angular-rust-binding-linux-x64-musl');
178
168
  }
179
169
  } catch (e) {
180
- loadError = e
170
+ loadError = e;
181
171
  }
182
172
  } else {
183
- localFileExisted = existsSync(
184
- join(__dirname, 'angular-binding.linux-x64-gnu.node')
185
- )
173
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.linux-x64-gnu.node'));
186
174
  try {
187
175
  if (localFileExisted) {
188
- nativeBinding = require('./angular-binding.linux-x64-gnu.node')
176
+ nativeBinding = require('./angular-binding.linux-x64-gnu.node');
189
177
  } else {
190
- nativeBinding = require('angular-rust-binding-linux-x64-gnu')
178
+ nativeBinding = require('angular-rust-binding-linux-x64-gnu');
191
179
  }
192
180
  } catch (e) {
193
- loadError = e
181
+ loadError = e;
194
182
  }
195
183
  }
196
- break
184
+ break;
197
185
  case 'arm64':
198
186
  if (isMusl()) {
199
- localFileExisted = existsSync(
200
- join(__dirname, 'angular-binding.linux-arm64-musl.node')
201
- )
187
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.linux-arm64-musl.node'));
202
188
  try {
203
189
  if (localFileExisted) {
204
- nativeBinding = require('./angular-binding.linux-arm64-musl.node')
190
+ nativeBinding = require('./angular-binding.linux-arm64-musl.node');
205
191
  } else {
206
- nativeBinding = require('angular-rust-binding-linux-arm64-musl')
192
+ nativeBinding = require('angular-rust-binding-linux-arm64-musl');
207
193
  }
208
194
  } catch (e) {
209
- loadError = e
195
+ loadError = e;
210
196
  }
211
197
  } else {
212
- localFileExisted = existsSync(
213
- join(__dirname, 'angular-binding.linux-arm64-gnu.node')
214
- )
198
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.linux-arm64-gnu.node'));
215
199
  try {
216
200
  if (localFileExisted) {
217
- nativeBinding = require('./angular-binding.linux-arm64-gnu.node')
201
+ nativeBinding = require('./angular-binding.linux-arm64-gnu.node');
218
202
  } else {
219
- nativeBinding = require('angular-rust-binding-linux-arm64-gnu')
203
+ nativeBinding = require('angular-rust-binding-linux-arm64-gnu');
220
204
  }
221
205
  } catch (e) {
222
- loadError = e
206
+ loadError = e;
223
207
  }
224
208
  }
225
- break
209
+ break;
226
210
  case 'arm':
227
211
  if (isMusl()) {
228
212
  localFileExisted = existsSync(
229
213
  join(__dirname, 'angular-binding.linux-arm-musleabihf.node')
230
- )
214
+ );
231
215
  try {
232
216
  if (localFileExisted) {
233
- nativeBinding = require('./angular-binding.linux-arm-musleabihf.node')
217
+ nativeBinding = require('./angular-binding.linux-arm-musleabihf.node');
234
218
  } else {
235
- nativeBinding = require('angular-rust-binding-linux-arm-musleabihf')
219
+ nativeBinding = require('angular-rust-binding-linux-arm-musleabihf');
236
220
  }
237
221
  } catch (e) {
238
- loadError = e
222
+ loadError = e;
239
223
  }
240
224
  } else {
241
225
  localFileExisted = existsSync(
242
226
  join(__dirname, 'angular-binding.linux-arm-gnueabihf.node')
243
- )
227
+ );
244
228
  try {
245
229
  if (localFileExisted) {
246
- nativeBinding = require('./angular-binding.linux-arm-gnueabihf.node')
230
+ nativeBinding = require('./angular-binding.linux-arm-gnueabihf.node');
247
231
  } else {
248
- nativeBinding = require('angular-rust-binding-linux-arm-gnueabihf')
232
+ nativeBinding = require('angular-rust-binding-linux-arm-gnueabihf');
249
233
  }
250
234
  } catch (e) {
251
- loadError = e
235
+ loadError = e;
252
236
  }
253
237
  }
254
- break
238
+ break;
255
239
  case 'riscv64':
256
240
  if (isMusl()) {
257
- localFileExisted = existsSync(
258
- join(__dirname, 'angular-binding.linux-riscv64-musl.node')
259
- )
241
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.linux-riscv64-musl.node'));
260
242
  try {
261
243
  if (localFileExisted) {
262
- nativeBinding = require('./angular-binding.linux-riscv64-musl.node')
244
+ nativeBinding = require('./angular-binding.linux-riscv64-musl.node');
263
245
  } else {
264
- nativeBinding = require('angular-rust-binding-linux-riscv64-musl')
246
+ nativeBinding = require('angular-rust-binding-linux-riscv64-musl');
265
247
  }
266
248
  } catch (e) {
267
- loadError = e
249
+ loadError = e;
268
250
  }
269
251
  } else {
270
- localFileExisted = existsSync(
271
- join(__dirname, 'angular-binding.linux-riscv64-gnu.node')
272
- )
252
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.linux-riscv64-gnu.node'));
273
253
  try {
274
254
  if (localFileExisted) {
275
- nativeBinding = require('./angular-binding.linux-riscv64-gnu.node')
255
+ nativeBinding = require('./angular-binding.linux-riscv64-gnu.node');
276
256
  } else {
277
- nativeBinding = require('angular-rust-binding-linux-riscv64-gnu')
257
+ nativeBinding = require('angular-rust-binding-linux-riscv64-gnu');
278
258
  }
279
259
  } catch (e) {
280
- loadError = e
260
+ loadError = e;
281
261
  }
282
262
  }
283
- break
263
+ break;
284
264
  case 's390x':
285
- localFileExisted = existsSync(
286
- join(__dirname, 'angular-binding.linux-s390x-gnu.node')
287
- )
265
+ localFileExisted = existsSync(join(__dirname, 'angular-binding.linux-s390x-gnu.node'));
288
266
  try {
289
267
  if (localFileExisted) {
290
- nativeBinding = require('./angular-binding.linux-s390x-gnu.node')
268
+ nativeBinding = require('./angular-binding.linux-s390x-gnu.node');
291
269
  } else {
292
- nativeBinding = require('angular-rust-binding-linux-s390x-gnu')
270
+ nativeBinding = require('angular-rust-binding-linux-s390x-gnu');
293
271
  }
294
272
  } catch (e) {
295
- loadError = e
273
+ loadError = e;
296
274
  }
297
- break
275
+ break;
298
276
  default:
299
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
277
+ throw new Error(`Unsupported architecture on Linux: ${arch}`);
300
278
  }
301
- break
279
+ break;
302
280
  default:
303
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
281
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
304
282
  }
305
283
 
306
284
  if (!nativeBinding) {
307
285
  if (loadError) {
308
- throw loadError
286
+ throw loadError;
309
287
  }
310
- throw new Error(`Failed to load native binding`)
288
+ throw new Error(`Failed to load native binding`);
311
289
  }
312
290
 
313
- const { Compiler, linkFile } = nativeBinding
291
+ const { Compiler, linkFile } = nativeBinding;
314
292
 
315
- module.exports.Compiler = Compiler
316
- module.exports.linkFile = linkFile
293
+ module.exports.Compiler = Compiler;
294
+ module.exports.linkFile = linkFile;
package/package.json CHANGED
@@ -1,66 +1,62 @@
1
1
  {
2
2
  "name": "angular-rust-plugins",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Angular plugins for bundlers (Vite, esbuild, Rolldown, Webpack, Rspack) - powered by Rust compiler",
5
5
  "author": "Truonglv4",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
- "main": "./dist/index.cjs",
9
- "module": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
8
+ "main": "./index.cjs",
9
+ "module": "./index.js",
10
+ "types": "./index.d.ts",
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./dist/index.d.ts",
14
- "import": "./dist/index.js",
15
- "require": "./dist/index.cjs"
13
+ "types": "./index.d.ts",
14
+ "import": "./index.js",
15
+ "require": "./index.cjs"
16
16
  },
17
17
  "./linker": {
18
- "types": "./dist/linker/index.d.ts",
19
- "import": "./dist/linker/index.js",
20
- "require": "./dist/linker/index.cjs"
18
+ "types": "./linker/index.d.ts",
19
+ "import": "./linker/index.js",
20
+ "require": "./linker/index.cjs"
21
21
  },
22
22
  "./linker/vite": {
23
- "types": "./dist/linker/vite.d.ts",
24
- "import": "./dist/linker/vite.js",
25
- "require": "./dist/linker/vite.cjs"
23
+ "types": "./linker/vite.d.ts",
24
+ "import": "./linker/vite.js",
25
+ "require": "./linker/vite.cjs"
26
26
  },
27
27
  "./linker/esbuild": {
28
- "types": "./dist/linker/esbuild.d.ts",
29
- "import": "./dist/linker/esbuild.js",
30
- "require": "./dist/linker/esbuild.cjs"
28
+ "types": "./linker/esbuild.d.ts",
29
+ "import": "./linker/esbuild.js",
30
+ "require": "./linker/esbuild.cjs"
31
31
  },
32
32
  "./linker/rolldown": {
33
- "types": "./dist/linker/rolldown.d.ts",
34
- "import": "./dist/linker/rolldown.js",
35
- "require": "./dist/linker/rolldown.cjs"
33
+ "types": "./linker/rolldown.d.ts",
34
+ "import": "./linker/rolldown.js",
35
+ "require": "./linker/rolldown.cjs"
36
36
  },
37
37
  "./compiler": {
38
- "types": "./dist/compiler/index.d.ts",
39
- "import": "./dist/compiler/index.js",
40
- "require": "./dist/compiler/index.cjs"
38
+ "types": "./compiler/index.d.ts",
39
+ "import": "./compiler/index.js",
40
+ "require": "./compiler/index.cjs"
41
41
  },
42
42
  "./compiler/vite": {
43
- "types": "./dist/compiler/vite.d.ts",
44
- "import": "./dist/compiler/vite.js",
45
- "require": "./dist/compiler/vite.cjs"
43
+ "types": "./compiler/vite.d.ts",
44
+ "import": "./compiler/vite.js",
45
+ "require": "./compiler/vite.cjs"
46
46
  }
47
47
  },
48
48
  "files": [
49
- "dist",
50
- "README.md"
49
+ "binding",
50
+ "linker",
51
+ "compiler",
52
+ "index.js",
53
+ "index.cjs",
54
+ "index.d.ts",
55
+ "index.d.cts",
56
+ "*.map",
57
+ "types-*.d.ts",
58
+ "types-*.d.cts"
51
59
  ],
52
- "scripts": {
53
- "copy-binding": "rm -rf src/binding && mkdir -p src/binding && cp ../binding/index.js ../binding/index.d.ts ../binding/*.node src/binding/ 2>/dev/null || true && echo '{\"type\":\"commonjs\"}' > src/binding/package.json",
54
- "copy-binding-to-dist": "mkdir -p dist/binding && cp src/binding/* dist/binding/",
55
- "copy-package": "cp package.dist.json dist/package.json",
56
- "copy-docs": "cp README.md dist/",
57
- "build": "npm run copy-binding && tsup && npm run copy-binding-to-dist && npm run copy-package && npm run copy-docs",
58
- "build:full": "cd ../binding && npm run build && cd ../linker-plugins && npm run build",
59
- "dev": "tsup --watch",
60
- "prepublishOnly": "npm run build",
61
- "pack:dist": "cd dist && npm pack",
62
- "publish": "cd dist && npm publish"
63
- },
64
60
  "keywords": [
65
61
  "angular",
66
62
  "linker",
@@ -77,10 +73,5 @@
77
73
  "repository": {
78
74
  "type": "git",
79
75
  "url": "https://github.com/truonglvos/angular-rust-compiler/tree/main/packages/linker-plugins"
80
- },
81
- "devDependencies": {
82
- "tsup": "^8.3.5",
83
- "typescript": "^5.7.2",
84
- "vite": "^6.0.0"
85
76
  }
86
77
  }
package/dist/README.md DELETED
@@ -1,306 +0,0 @@
1
- # angular-rust-plugins
2
-
3
- High-performance Angular linker and compiler plugins powered by Rust. Supports **Vite**, **esbuild**, **Rolldown**, and more bundlers coming soon.
4
-
5
- This package bundles the Angular Rust binding - no additional dependencies needed!
6
-
7
- ## 🚀 Installation
8
-
9
- ```bash
10
- npm install angular-rust-plugins
11
- ```
12
-
13
- ## 📋 Quick Start
14
-
15
- ### 1. Create `index.html`
16
-
17
- Create an `index.html` file at the root of your project:
18
-
19
- ```html
20
- <!doctype html>
21
- <html lang="en">
22
- <head>
23
- <meta charset="utf-8">
24
- <title>My Angular App</title>
25
- <base href="/">
26
- <meta name="viewport" content="width=device-width, initial-scale=1">
27
- <link rel="icon" type="image/x-icon" href="favicon.ico">
28
- </head>
29
- <body>
30
- <app-root></app-root>
31
- <script type="module" src="/src/main.ts"></script>
32
- </body>
33
- </html>
34
- ```
35
-
36
- ### 2. Create `vite.config.mjs`
37
-
38
- ```js
39
- import { defineConfig } from "vite";
40
- import { angularLinkerRolldownPlugin } from "angular-rust-plugins/linker/rolldown";
41
- import { angularCompilerVitePlugin } from "angular-rust-plugins/compiler/vite";
42
-
43
- export default defineConfig({
44
- plugins: [
45
- // Linker plugin - processes @angular/* packages in node_modules
46
- angularLinkerRolldownPlugin(),
47
- // Compiler plugin - compiles your .ts files with Angular decorators
48
- angularCompilerVitePlugin(),
49
- ],
50
- resolve: {
51
- extensions: [".ts", ".js", ".json"],
52
- },
53
- server: {
54
- port: 4200,
55
- },
56
- optimizeDeps: {
57
- // Exclude Angular packages from pre-bundling so linker plugin can process them
58
- exclude: [
59
- "@angular/core",
60
- "@angular/common",
61
- "@angular/platform-browser",
62
- "@angular/router",
63
- "@angular/forms",
64
- ],
65
- // Still include zone.js and rxjs which don't need linking
66
- include: ["zone.js", "rxjs", "rxjs/operators"],
67
- },
68
- });
69
- ```
70
-
71
- ### 3. Run dev server
72
-
73
- ```bash
74
- npx vite
75
- ```
76
-
77
- ## 📖 Complete Configuration Examples
78
-
79
- ### Full Angular Setup with Vite (Recommended)
80
-
81
- ```js
82
- // vite.config.mjs
83
- import { defineConfig } from "vite";
84
- import { angularLinkerRolldownPlugin } from "angular-rust-plugins/linker/rolldown";
85
- import { angularCompilerVitePlugin } from "angular-rust-plugins/compiler/vite";
86
-
87
- export default defineConfig({
88
- plugins: [
89
- angularLinkerRolldownPlugin({ debug: false }),
90
- angularCompilerVitePlugin({ debug: false }),
91
- ],
92
- resolve: {
93
- extensions: [".ts", ".js", ".json"],
94
- },
95
- server: {
96
- port: 4200,
97
- open: true, // Open browser automatically
98
- },
99
- build: {
100
- target: "esnext",
101
- sourcemap: true,
102
- },
103
- optimizeDeps: {
104
- exclude: [
105
- "@angular/core",
106
- "@angular/common",
107
- "@angular/platform-browser",
108
- "@angular/router",
109
- "@angular/forms",
110
- "@angular/animations",
111
- "@angular/platform-browser-dynamic",
112
- ],
113
- include: ["zone.js", "rxjs", "rxjs/operators"],
114
- },
115
- });
116
- ```
117
-
118
- ### Linker Only (Vite) - For existing Angular projects
119
-
120
- If you only need the linker (for pre-AOT compiled Angular libraries):
121
-
122
- ```js
123
- import { defineConfig } from "vite";
124
- import { angularLinkerVitePlugin } from "angular-rust-plugins/linker/vite";
125
-
126
- export default defineConfig({
127
- plugins: [angularLinkerVitePlugin()],
128
- optimizeDeps: {
129
- exclude: ["@angular/core", "@angular/common", "@angular/platform-browser"],
130
- },
131
- });
132
- ```
133
-
134
- ### Linker with Rolldown (for Vite 6+)
135
-
136
- ```js
137
- import { defineConfig } from "vite";
138
- import { angularLinkerRolldownPlugin } from "angular-rust-plugins/linker/rolldown";
139
-
140
- export default defineConfig({
141
- plugins: [angularLinkerRolldownPlugin()],
142
- optimizeDeps: {
143
- exclude: ["@angular/core", "@angular/common", "@angular/platform-browser"],
144
- },
145
- });
146
- ```
147
-
148
- ### Linker with esbuild
149
-
150
- ```js
151
- import esbuild from "esbuild";
152
- import { angularLinkerEsbuildPlugin } from "angular-rust-plugins/linker/esbuild";
153
-
154
- esbuild.build({
155
- entryPoints: ["src/main.ts"],
156
- bundle: true,
157
- outfile: "dist/bundle.js",
158
- plugins: [angularLinkerEsbuildPlugin()],
159
- });
160
- ```
161
-
162
- ## 📦 Package Exports
163
-
164
- | Export Path | Description |
165
- | -------------------------------------- | ---------------------------------- |
166
- | `angular-rust-plugins` | All plugins |
167
- | **Linker Plugins** | |
168
- | `angular-rust-plugins/linker` | All linker plugins |
169
- | `angular-rust-plugins/linker/vite` | Vite linker plugin (esbuild-based) |
170
- | `angular-rust-plugins/linker/esbuild` | esbuild linker plugin |
171
- | `angular-rust-plugins/linker/rolldown` | Rolldown linker plugin |
172
- | **Compiler Plugins** | |
173
- | `angular-rust-plugins/compiler` | All compiler plugins |
174
- | `angular-rust-plugins/compiler/vite` | Vite compiler plugin |
175
-
176
- ## ⚙️ Options
177
-
178
- ### Linker Options
179
-
180
- ```ts
181
- interface LinkerOptions {
182
- debug?: boolean; // Enable debug logging (default: false)
183
- bindingPath?: string; // Custom path to binding (optional)
184
- }
185
- ```
186
-
187
- ### Compiler Options
188
-
189
- ```ts
190
- interface CompilerOptions {
191
- debug?: boolean; // Enable debug logging (default: false)
192
- bindingPath?: string; // Custom path to binding (optional)
193
- }
194
- ```
195
-
196
- ## 📁 Project Structure
197
-
198
- Your Angular project should have this structure:
199
-
200
- ```
201
- my-angular-app/
202
- ├── index.html # Entry HTML file
203
- ├── vite.config.mjs # Vite configuration
204
- ├── package.json
205
- ├── tsconfig.json
206
- ├── src/
207
- │ ├── main.ts # Bootstrap entry
208
- │ ├── styles.css # Global styles
209
- │ └── app/
210
- │ ├── app.ts # Root component
211
- │ ├── app.html # Root template
212
- │ └── app.config.ts # App configuration
213
- └── public/
214
- └── favicon.ico
215
- ```
216
-
217
- ### Example `src/main.ts`
218
-
219
- ```ts
220
- import { bootstrapApplication } from "@angular/platform-browser";
221
- import { appConfig } from "./app/app.config";
222
- import { App } from "./app/app";
223
-
224
- bootstrapApplication(App, appConfig).catch((err) => console.error(err));
225
- ```
226
-
227
- ### Example `src/app/app.ts`
228
-
229
- ```ts
230
- import { Component } from "@angular/core";
231
-
232
- @Component({
233
- selector: "app-root",
234
- standalone: true,
235
- templateUrl: "./app.html",
236
- styleUrl: "./app.css",
237
- })
238
- export class App {
239
- title = "My Angular App";
240
- }
241
- ```
242
-
243
- ## 🔧 Troubleshooting
244
-
245
- ### Angular packages not being linked
246
-
247
- Make sure Angular packages are excluded from `optimizeDeps`:
248
-
249
- ```js
250
- optimizeDeps: {
251
- exclude: [
252
- "@angular/core",
253
- "@angular/common",
254
- "@angular/platform-browser",
255
- // Add other @angular/* packages you use
256
- ],
257
- }
258
- ```
259
-
260
- ### TypeScript compilation errors
261
-
262
- Ensure your `tsconfig.json` includes:
263
-
264
- ```json
265
- {
266
- "compilerOptions": {
267
- "target": "ES2022",
268
- "module": "ES2022",
269
- "moduleResolution": "bundler",
270
- "experimentalDecorators": true,
271
- "emitDecoratorMetadata": true
272
- }
273
- }
274
- ```
275
-
276
- ### HMR (Hot Module Replacement)
277
-
278
- The compiler plugin includes HMR support for `.html` template files. When you modify a template, the corresponding component will be recompiled automatically.
279
-
280
- ## ⚡ Performance
281
-
282
- **2-5x faster** than TypeScript-based Angular compiler with lower memory usage.
283
-
284
- | Metric | angular-rust-plugins | Angular CLI |
285
- | --------------- | -------------------- | ----------- |
286
- | Initial compile | ~500ms | ~2000ms |
287
- | HMR update | ~50ms | ~200ms |
288
- | Memory usage | ~100MB | ~500MB |
289
-
290
- ## 🔧 Development
291
-
292
- ```bash
293
- # Build with current binding
294
- npm run build
295
-
296
- # Rebuild binding and plugin
297
- npm run build:full
298
- ```
299
-
300
- ## 📝 License
301
-
302
- MIT
303
-
304
- ---
305
-
306
- **Built with ❤️ using Rust**
@@ -1,13 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- export declare function linkFile(sourceCode: string, filename: string): string
7
- export declare class Compiler {
8
- constructor()
9
- compile(filename: string, content: string): string
10
- constructor()
11
- compile(filename: string, content: string): string
12
- linkFile(filename: string, sourceCode: string): string
13
- }
package/dist/package.json DELETED
@@ -1,77 +0,0 @@
1
- {
2
- "name": "angular-rust-plugins",
3
- "version": "0.2.0",
4
- "description": "Angular plugins for bundlers (Vite, esbuild, Rolldown, Webpack, Rspack) - powered by Rust compiler",
5
- "author": "Truonglv4",
6
- "license": "MIT",
7
- "type": "module",
8
- "main": "./index.cjs",
9
- "module": "./index.js",
10
- "types": "./index.d.ts",
11
- "exports": {
12
- ".": {
13
- "types": "./index.d.ts",
14
- "import": "./index.js",
15
- "require": "./index.cjs"
16
- },
17
- "./linker": {
18
- "types": "./linker/index.d.ts",
19
- "import": "./linker/index.js",
20
- "require": "./linker/index.cjs"
21
- },
22
- "./linker/vite": {
23
- "types": "./linker/vite.d.ts",
24
- "import": "./linker/vite.js",
25
- "require": "./linker/vite.cjs"
26
- },
27
- "./linker/esbuild": {
28
- "types": "./linker/esbuild.d.ts",
29
- "import": "./linker/esbuild.js",
30
- "require": "./linker/esbuild.cjs"
31
- },
32
- "./linker/rolldown": {
33
- "types": "./linker/rolldown.d.ts",
34
- "import": "./linker/rolldown.js",
35
- "require": "./linker/rolldown.cjs"
36
- },
37
- "./compiler": {
38
- "types": "./compiler/index.d.ts",
39
- "import": "./compiler/index.js",
40
- "require": "./compiler/index.cjs"
41
- },
42
- "./compiler/vite": {
43
- "types": "./compiler/vite.d.ts",
44
- "import": "./compiler/vite.js",
45
- "require": "./compiler/vite.cjs"
46
- }
47
- },
48
- "files": [
49
- "binding",
50
- "linker",
51
- "compiler",
52
- "index.js",
53
- "index.cjs",
54
- "index.d.ts",
55
- "index.d.cts",
56
- "*.map",
57
- "types-*.d.ts",
58
- "types-*.d.cts"
59
- ],
60
- "keywords": [
61
- "angular",
62
- "linker",
63
- "compiler",
64
- "vite",
65
- "esbuild",
66
- "rolldown",
67
- "webpack",
68
- "rspack",
69
- "rust",
70
- "aot",
71
- "bundler"
72
- ],
73
- "repository": {
74
- "type": "git",
75
- "url": "https://github.com/truonglvos/angular-rust-compiler/tree/main/packages/linker-plugins"
76
- }
77
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes