@ngrs/vite 0.0.0-stage → 0.1.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.
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
1
+ # `@ngrs/vite`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Native Rust Angular compiler, HMR & Ivy linker plugin for **Vite 8 (Rolldown)** and **Vitest** (`@ngrs/vite/testing`).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -D @ngrs/vite
9
+ ```
10
+
11
+ ## Usage (`vite.config.ts`)
12
+
13
+ ```ts
14
+ import { defineConfig } from 'vite';
15
+ import { angular } from '@ngrs/vite';
16
+
17
+ export default defineConfig({
18
+ plugins: [angular()],
19
+ });
20
+ ```
21
+
22
+ ## Vitest + `happy-dom` (`vitest.config.mts`)
23
+
24
+ ```ts
25
+ import { defineConfig } from 'vitest/config';
26
+ import { angularTesting } from '@ngrs/vite/testing';
27
+
28
+ export default defineConfig({
29
+ plugins: [angularTesting({ inlineStyleLanguage: 'scss' })],
30
+ });
31
+ ```
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@ngrs/vite",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Native Rust Angular compiler & Ivy linker plugins for Vite, powered by @ngrs/napi",
5
+ "type": "module",
6
+ "main": "./src/index.cjs",
7
+ "module": "./src/index.mjs",
8
+ "types": "./src/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./src/index.d.ts",
12
+ "import": "./src/index.mjs",
13
+ "require": "./src/index.cjs"
14
+ },
15
+ "./testing": {
16
+ "types": "./src/testing.d.ts",
17
+ "import": "./src/testing.mjs",
18
+ "require": "./src/testing.cjs"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "src"
24
+ ],
25
+ "dependencies": {
26
+ "@ngrs/napi": "0.1.0"
27
+ },
28
+ "peerDependencies": {
29
+ "happy-dom": ">=15.0.0 || ^20.0.0",
30
+ "sass": ">=1.60.0",
31
+ "vite": ">=6.0.0 || ^8.0.0"
32
+ },
33
+ "peerDependenciesMeta": {
34
+ "happy-dom": {
35
+ "optional": true
36
+ },
37
+ "sass": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "engines": {
42
+ "node": ">=18.19.0"
43
+ },
44
+ "keywords": [
45
+ "angular",
46
+ "vite",
47
+ "rolldown",
48
+ "vitest",
49
+ "hmr",
50
+ "rust"
51
+ ],
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "license": "MIT",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/truonglv95/ngrs.git",
59
+ "directory": "packages/vite"
60
+ },
61
+ "homepage": "https://github.com/truonglv95/ngrs#readme",
62
+ "bugs": {
63
+ "url": "https://github.com/truonglv95/ngrs/issues"
64
+ }
65
+ }
package/src/index.cjs ADDED
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ let esmPromise;
4
+ function loadEsm() {
5
+ if (!esmPromise) {
6
+ esmPromise = import('./index.mjs');
7
+ }
8
+ return esmPromise;
9
+ }
10
+
11
+ /**
12
+ * CommonJS wrapper returning Vite async plugin promises compatible with Vite's plugin resolution.
13
+ */
14
+ function angular(options = {}) {
15
+ return [
16
+ loadEsm().then((m) => m.angularCompilerPlugin(options)),
17
+ loadEsm().then((m) => m.angularLinkerPlugin(options)),
18
+ ];
19
+ }
20
+
21
+ module.exports = angular;
22
+ module.exports.angular = angular;
23
+ module.exports.default = angular;
24
+ module.exports.loadEsm = loadEsm;
package/src/index.d.ts ADDED
@@ -0,0 +1,132 @@
1
+ import type { NapiDiagnostic, NapiFileReplacement } from '@ngrs/napi';
2
+ import type { Plugin } from 'vite';
3
+
4
+ export interface AngularStylePreprocessorOptions {
5
+ includePaths?: string[];
6
+ sass?: Record<string, unknown>;
7
+ }
8
+
9
+ export interface CollectedComponentStyle {
10
+ file: string;
11
+ css: string;
12
+ size: number;
13
+ }
14
+
15
+ export interface AngularLinkerOptions {
16
+ sourceMapping?: boolean;
17
+ linkerJitMode?: boolean;
18
+ unknownDeclarationVersionHandling?: 'ignore' | 'warn' | 'error';
19
+ optimizeForBundling?: boolean;
20
+ }
21
+
22
+ export interface AngularVitePluginOptions {
23
+ /**
24
+ * Path to `tsconfig.app.json` or `tsconfig.json` (defaults to `tsconfig.app.json` if present,
25
+ * otherwise `tsconfig.json`).
26
+ */
27
+ tsconfig?: string;
28
+ /**
29
+ * Workspace root directory used to resolve relative paths.
30
+ */
31
+ workspaceRoot?: string;
32
+ /**
33
+ * File replacements (`angular.json` `fileReplacements` array).
34
+ */
35
+ fileReplacements?: NapiFileReplacement[];
36
+ /**
37
+ * Enable Angular Hot Module Replacement (defaults to `true` in `serve`, `false` in `build`).
38
+ */
39
+ hmr?: boolean;
40
+ /**
41
+ * Emit source maps from Angular & Ivy linker compilation.
42
+ */
43
+ sourceMap?: boolean;
44
+ /**
45
+ * Angular compilation mode (`'full' | 'partial' | 'experimental-local'`). Defaults to `'full'`.
46
+ */
47
+ compilationMode?: 'full' | 'partial' | 'experimental-local';
48
+ /**
49
+ * Stylesheet language for inline styles (`'css' | 'scss' | 'sass' | 'less'`).
50
+ */
51
+ inlineStyleLanguage?: 'css' | 'scss' | 'sass' | 'less';
52
+ /**
53
+ * Options forwarded to Sass/SCSS preprocessors (`includePaths`, `sass`).
54
+ */
55
+ stylePreprocessorOptions?: AngularStylePreprocessorOptions;
56
+ /**
57
+ * Enable JIT mode for the Angular Ivy linker.
58
+ */
59
+ jit?: boolean;
60
+ /**
61
+ * Handling strategy for unknown partial declaration versions in `node_modules`.
62
+ */
63
+ unknownDeclarationVersionHandling?: 'ignore' | 'warn' | 'error';
64
+ /**
65
+ * Override automatic Vite 8 Rolldown detection (`'rolldownVersion' in vite`) for `optimizeDeps`.
66
+ */
67
+ useRolldown?: boolean;
68
+ /**
69
+ * Do not fail `vite build` on Angular/TypeScript diagnostic errors.
70
+ */
71
+ ignoreDiagnostics?: boolean;
72
+ /**
73
+ * Optional observer callback receiving compiler diagnostics after each build/rebuild.
74
+ */
75
+ onDiagnostics?: (diagnostics: NapiDiagnostic[]) => void;
76
+ /**
77
+ * Optional observer callback receiving component stylesheet byte sizes (used for budget checks).
78
+ */
79
+ onComponentStylesCollected?: (styles: CollectedComponentStyle[]) => void;
80
+ /**
81
+ * Emit `.d.ts` declaration files in `NapiProjectCompiler` (defaults to `false` for bundler builds).
82
+ */
83
+ emitDts?: boolean;
84
+ /**
85
+ * Overlap Angular template type-checking on a background Rust OS thread concurrently with
86
+ * Rolldown bundling during one-shot `vite build` (defaults to `true`).
87
+ */
88
+ deferTypecheck?: boolean;
89
+ /**
90
+ * Enable pure-class IIFE wrapping + metadata elision on linked `node_modules` packages during
91
+ * production builds so Rolldown tree-shakes unused framework classes.
92
+ */
93
+ optimizeForBundling?: boolean;
94
+ /**
95
+ * Override `supportTestBed` (`ɵsetClassMetadata` emission) during production builds.
96
+ */
97
+ supportTestBed?: boolean;
98
+ /**
99
+ * Override `supportJitMode` during production builds.
100
+ */
101
+ supportJitMode?: boolean;
102
+ /**
103
+ * Enable Vitest / Angular TestBed compilation mode (`tsconfig.spec.json` + `supportTestBed: true`).
104
+ */
105
+ test?: boolean;
106
+ }
107
+
108
+ export declare const isRolldownVite: boolean;
109
+
110
+ export declare function formatDiagnostics(
111
+ diagnostics: NapiDiagnostic[],
112
+ rootDir?: string,
113
+ ): {
114
+ warnings: string[];
115
+ errors: string[];
116
+ firstError?: NapiDiagnostic;
117
+ };
118
+
119
+ export declare function createRolldownLinkerPlugin(options?: AngularLinkerOptions): {
120
+ name: string;
121
+ transform(code: string, id: string): { code: string; map: unknown } | null;
122
+ };
123
+
124
+ export declare function createEsbuildLinkerPlugin(options?: AngularLinkerOptions): {
125
+ name: string;
126
+ setup(build: unknown): void;
127
+ };
128
+
129
+ export declare function angularCompilerPlugin(options?: AngularVitePluginOptions): Plugin;
130
+ export declare function angularLinkerPlugin(options?: AngularVitePluginOptions): Plugin;
131
+ export declare function angular(options?: AngularVitePluginOptions): Plugin[];
132
+ export default angular;