angular-rust-plugins 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 +118 -0
- package/binding/angular-binding.darwin-arm64.node +0 -0
- package/binding/index.d.ts +13 -0
- package/binding/index.js +316 -0
- package/binding/package.json +1 -0
- package/compiler/index.cjs +135 -0
- package/compiler/index.cjs.map +1 -0
- package/compiler/index.d.cts +12 -0
- package/compiler/index.d.ts +12 -0
- package/compiler/index.js +107 -0
- package/compiler/index.js.map +1 -0
- package/compiler/vite.cjs +135 -0
- package/compiler/vite.cjs.map +1 -0
- package/compiler/vite.d.cts +41 -0
- package/compiler/vite.d.ts +41 -0
- package/compiler/vite.js +109 -0
- package/compiler/vite.js.map +1 -0
- package/index.cjs +479 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +8 -0
- package/index.d.ts +8 -0
- package/index.js +438 -0
- package/index.js.map +1 -0
- package/linker/esbuild.cjs +125 -0
- package/linker/esbuild.cjs.map +1 -0
- package/linker/esbuild.d.cts +39 -0
- package/linker/esbuild.d.ts +39 -0
- package/linker/esbuild.js +99 -0
- package/linker/esbuild.js.map +1 -0
- package/linker/index.cjs +372 -0
- package/linker/index.cjs.map +1 -0
- package/linker/index.d.cts +6 -0
- package/linker/index.d.ts +6 -0
- package/linker/index.js +333 -0
- package/linker/index.js.map +1 -0
- package/linker/rolldown.cjs +135 -0
- package/linker/rolldown.cjs.map +1 -0
- package/linker/rolldown.d.cts +36 -0
- package/linker/rolldown.d.ts +36 -0
- package/linker/rolldown.js +109 -0
- package/linker/rolldown.js.map +1 -0
- package/linker/vite.cjs +184 -0
- package/linker/vite.cjs.map +1 -0
- package/linker/vite.d.cts +58 -0
- package/linker/vite.d.ts +58 -0
- package/linker/vite.js +155 -0
- package/linker/vite.js.map +1 -0
- package/package.json +77 -0
- package/types-BTaYbdhr.d.cts +45 -0
- package/types-BTaYbdhr.d.ts +45 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/compiler/vite.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
var compilerInstance = null;
|
|
6
|
+
function getCompiler(options) {
|
|
7
|
+
if (compilerInstance) {
|
|
8
|
+
return compilerInstance;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
let binding;
|
|
12
|
+
if (options?.bindingPath) {
|
|
13
|
+
const require2 = createRequire(import.meta.url);
|
|
14
|
+
binding = require2(options.bindingPath);
|
|
15
|
+
} else {
|
|
16
|
+
const currentFileUrl = import.meta.url;
|
|
17
|
+
const currentFilePath = fileURLToPath(currentFileUrl);
|
|
18
|
+
const currentDir = dirname(currentFilePath);
|
|
19
|
+
const require2 = createRequire(currentFileUrl);
|
|
20
|
+
const possiblePaths = [
|
|
21
|
+
join(currentDir, "..", "binding"),
|
|
22
|
+
// dist/compiler/../binding
|
|
23
|
+
join(currentDir, "..", "..", "binding"),
|
|
24
|
+
// in case of deeper nesting
|
|
25
|
+
join(currentDir, "binding")
|
|
26
|
+
// same directory
|
|
27
|
+
];
|
|
28
|
+
let loadedBinding = null;
|
|
29
|
+
let lastError = null;
|
|
30
|
+
for (const bindingPath of possiblePaths) {
|
|
31
|
+
try {
|
|
32
|
+
loadedBinding = require2(bindingPath);
|
|
33
|
+
break;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
lastError = e;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!loadedBinding) {
|
|
39
|
+
throw lastError || new Error("Could not find binding in any expected location");
|
|
40
|
+
}
|
|
41
|
+
binding = loadedBinding;
|
|
42
|
+
}
|
|
43
|
+
compilerInstance = new binding.Compiler();
|
|
44
|
+
return compilerInstance;
|
|
45
|
+
} catch (e) {
|
|
46
|
+
throw new Error(`Failed to load Angular Rust binding. Error: ${e}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function angularCompilerVitePlugin(options) {
|
|
50
|
+
const debug = options?.debug ?? false;
|
|
51
|
+
let compiler;
|
|
52
|
+
return {
|
|
53
|
+
name: "angular-rust-compiler",
|
|
54
|
+
enforce: "pre",
|
|
55
|
+
transform(code, id) {
|
|
56
|
+
if (!compiler) {
|
|
57
|
+
compiler = getCompiler(options);
|
|
58
|
+
}
|
|
59
|
+
if (id.includes("node_modules")) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (!id.endsWith(".ts") || id.endsWith(".d.ts")) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (debug) {
|
|
66
|
+
console.log(`[Angular Compiler] Compiling: ${id}`);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const result = compiler.compile(id, code);
|
|
70
|
+
if (result.startsWith("/* Error")) {
|
|
71
|
+
console.error(`[Angular Compiler Error] ${id}:
|
|
72
|
+
${result}`);
|
|
73
|
+
throw new Error(`Rust Compilation Failed for ${id}`);
|
|
74
|
+
}
|
|
75
|
+
if (debug) {
|
|
76
|
+
console.log(`[Angular Compiler] Successfully compiled: ${id}`);
|
|
77
|
+
}
|
|
78
|
+
return { code: result, map: null };
|
|
79
|
+
} catch (e) {
|
|
80
|
+
console.error(`[Angular Compiler Failed] ${id}:`, e);
|
|
81
|
+
throw e;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
handleHotUpdate({ file, server }) {
|
|
85
|
+
if (file.endsWith(".html")) {
|
|
86
|
+
const tsFile = file.replace(/\.html$/, ".ts");
|
|
87
|
+
if (debug) {
|
|
88
|
+
console.log(`[HMR] HTML changed: ${file}`);
|
|
89
|
+
console.log(`[HMR] Invalidating TS: ${tsFile}`);
|
|
90
|
+
}
|
|
91
|
+
const mod = server.moduleGraph.getModuleById(tsFile);
|
|
92
|
+
if (mod) {
|
|
93
|
+
server.moduleGraph.invalidateModule(mod);
|
|
94
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
95
|
+
return [];
|
|
96
|
+
} else {
|
|
97
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
angularCompilerVitePlugin
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/compiler/vite.ts"],"sourcesContent":["/**\n * Angular Compiler Plugin for Vite\n *\n * This plugin compiles Angular TypeScript files using the Rust-based Angular compiler.\n * Use with the linker plugin for a complete Angular build solution.\n *\n * @example\n * ```js\n * import { angularCompilerVitePlugin } from 'angular-rust-plugins/compiler/vite';\n * import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [\n * angularLinkerVitePlugin(),\n * angularCompilerVitePlugin(),\n * ],\n * });\n * ```\n */\n\nimport type { Plugin, HmrContext } from \"vite\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nexport interface CompilerOptions {\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom path to the Angular Rust binding package\n */\n bindingPath?: string;\n}\n\nfunction getCompiler(options?: CompilerOptions): CompilerBinding {\n if (compilerInstance) {\n return compilerInstance;\n }\n\n try {\n let binding: { Compiler: new () => CompilerBinding };\n\n if (options?.bindingPath) {\n const require = createRequire(import.meta.url);\n binding = require(options.bindingPath);\n } else {\n // Load from bundled binding directory\n // Use import.meta.url to get the actual location of this file\n const currentFileUrl = import.meta.url;\n const currentFilePath = fileURLToPath(currentFileUrl);\n const currentDir = dirname(currentFilePath);\n const require = createRequire(currentFileUrl);\n\n // Try multiple possible binding locations\n const possiblePaths = [\n join(currentDir, \"..\", \"binding\"), // dist/compiler/../binding\n join(currentDir, \"..\", \"..\", \"binding\"), // in case of deeper nesting\n join(currentDir, \"binding\"), // same directory\n ];\n\n let loadedBinding: { Compiler: new () => CompilerBinding } | null = null;\n let lastError: unknown = null;\n\n for (const bindingPath of possiblePaths) {\n try {\n loadedBinding = require(bindingPath);\n break;\n } catch (e) {\n lastError = e;\n }\n }\n\n if (!loadedBinding) {\n throw (\n lastError ||\n new Error(\"Could not find binding in any expected location\")\n );\n }\n\n binding = loadedBinding;\n }\n\n compilerInstance = new binding.Compiler();\n return compilerInstance;\n } catch (e) {\n throw new Error(`Failed to load Angular Rust binding. Error: ${e}`);\n }\n}\n\n/**\n * Creates a Vite plugin for Angular Rust compiler\n * Compiles .ts files (except .d.ts) using the Rust compiler\n */\nexport function angularCompilerVitePlugin(options?: CompilerOptions): Plugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-rust-compiler\",\n enforce: \"pre\",\n\n transform(code: string, id: string) {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Skip node_modules - those are handled by linker, not compiler\n if (id.includes(\"node_modules\")) {\n return null;\n }\n\n // Only process TypeScript files, skip declaration files\n if (!id.endsWith(\".ts\") || id.endsWith(\".d.ts\")) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Compiling: ${id}`);\n }\n\n try {\n const result = compiler.compile(id, code);\n\n if (result.startsWith(\"/* Error\")) {\n console.error(`[Angular Compiler Error] ${id}:\\n${result}`);\n throw new Error(`Rust Compilation Failed for ${id}`);\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Successfully compiled: ${id}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Compiler Failed] ${id}:`, e);\n throw e;\n }\n },\n\n handleHotUpdate({ file, server }: HmrContext) {\n // When HTML template changes, invalidate the corresponding TS file\n if (file.endsWith(\".html\")) {\n const tsFile = file.replace(/\\.html$/, \".ts\");\n\n if (debug) {\n console.log(`[HMR] HTML changed: ${file}`);\n console.log(`[HMR] Invalidating TS: ${tsFile}`);\n }\n\n const mod = server.moduleGraph.getModuleById(tsFile);\n if (mod) {\n server.moduleGraph.invalidateModule(mod);\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n return [];\n } else {\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n return [];\n }\n }\n },\n };\n}\n\nexport default angularCompilerVitePlugin;\n"],"mappings":";AAsBA,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAG9B,IAAI,mBAA2C;AAe/C,SAAS,YAAY,SAA4C;AAC/D,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,QAAI;AAEJ,QAAI,SAAS,aAAa;AACxB,YAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,gBAAUA,SAAQ,QAAQ,WAAW;AAAA,IACvC,OAAO;AAGL,YAAM,iBAAiB,YAAY;AACnC,YAAM,kBAAkB,cAAc,cAAc;AACpD,YAAM,aAAa,QAAQ,eAAe;AAC1C,YAAMA,WAAU,cAAc,cAAc;AAG5C,YAAM,gBAAgB;AAAA,QACpB,KAAK,YAAY,MAAM,SAAS;AAAA;AAAA,QAChC,KAAK,YAAY,MAAM,MAAM,SAAS;AAAA;AAAA,QACtC,KAAK,YAAY,SAAS;AAAA;AAAA,MAC5B;AAEA,UAAI,gBAAgE;AACpE,UAAI,YAAqB;AAEzB,iBAAW,eAAe,eAAe;AACvC,YAAI;AACF,0BAAgBA,SAAQ,WAAW;AACnC;AAAA,QACF,SAAS,GAAG;AACV,sBAAY;AAAA,QACd;AAAA,MACF;AAEA,UAAI,CAAC,eAAe;AAClB,cACE,aACA,IAAI,MAAM,iDAAiD;AAAA,MAE/D;AAEA,gBAAU;AAAA,IACZ;AAEA,uBAAmB,IAAI,QAAQ,SAAS;AACxC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,UAAM,IAAI,MAAM,+CAA+C,CAAC,EAA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AE,MAAM,eAAe,MAAM,IAAI,CAAC;AACjD,iBAAO,CAAC;AAAA,QACV,OAAO;AACL,iBAAO,GAAG,KAAK,EAAE,MAAM,eAAe,MAAM,IAAI,CAAC;AACjD,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["require"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/compiler/vite.ts
|
|
21
|
+
var vite_exports = {};
|
|
22
|
+
__export(vite_exports, {
|
|
23
|
+
angularCompilerVitePlugin: () => angularCompilerVitePlugin,
|
|
24
|
+
default: () => vite_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(vite_exports);
|
|
27
|
+
var import_module = require("module");
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_url = require("url");
|
|
30
|
+
var import_meta = {};
|
|
31
|
+
var compilerInstance = null;
|
|
32
|
+
function getCompiler(options) {
|
|
33
|
+
if (compilerInstance) {
|
|
34
|
+
return compilerInstance;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
let binding;
|
|
38
|
+
if (options?.bindingPath) {
|
|
39
|
+
const require2 = (0, import_module.createRequire)(import_meta.url);
|
|
40
|
+
binding = require2(options.bindingPath);
|
|
41
|
+
} else {
|
|
42
|
+
const currentFileUrl = import_meta.url;
|
|
43
|
+
const currentFilePath = (0, import_url.fileURLToPath)(currentFileUrl);
|
|
44
|
+
const currentDir = (0, import_path.dirname)(currentFilePath);
|
|
45
|
+
const require2 = (0, import_module.createRequire)(currentFileUrl);
|
|
46
|
+
const possiblePaths = [
|
|
47
|
+
(0, import_path.join)(currentDir, "..", "binding"),
|
|
48
|
+
// dist/compiler/../binding
|
|
49
|
+
(0, import_path.join)(currentDir, "..", "..", "binding"),
|
|
50
|
+
// in case of deeper nesting
|
|
51
|
+
(0, import_path.join)(currentDir, "binding")
|
|
52
|
+
// same directory
|
|
53
|
+
];
|
|
54
|
+
let loadedBinding = null;
|
|
55
|
+
let lastError = null;
|
|
56
|
+
for (const bindingPath of possiblePaths) {
|
|
57
|
+
try {
|
|
58
|
+
loadedBinding = require2(bindingPath);
|
|
59
|
+
break;
|
|
60
|
+
} catch (e) {
|
|
61
|
+
lastError = e;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!loadedBinding) {
|
|
65
|
+
throw lastError || new Error("Could not find binding in any expected location");
|
|
66
|
+
}
|
|
67
|
+
binding = loadedBinding;
|
|
68
|
+
}
|
|
69
|
+
compilerInstance = new binding.Compiler();
|
|
70
|
+
return compilerInstance;
|
|
71
|
+
} catch (e) {
|
|
72
|
+
throw new Error(`Failed to load Angular Rust binding. Error: ${e}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function angularCompilerVitePlugin(options) {
|
|
76
|
+
const debug = options?.debug ?? false;
|
|
77
|
+
let compiler;
|
|
78
|
+
return {
|
|
79
|
+
name: "angular-rust-compiler",
|
|
80
|
+
enforce: "pre",
|
|
81
|
+
transform(code, id) {
|
|
82
|
+
if (!compiler) {
|
|
83
|
+
compiler = getCompiler(options);
|
|
84
|
+
}
|
|
85
|
+
if (id.includes("node_modules")) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
if (!id.endsWith(".ts") || id.endsWith(".d.ts")) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
if (debug) {
|
|
92
|
+
console.log(`[Angular Compiler] Compiling: ${id}`);
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const result = compiler.compile(id, code);
|
|
96
|
+
if (result.startsWith("/* Error")) {
|
|
97
|
+
console.error(`[Angular Compiler Error] ${id}:
|
|
98
|
+
${result}`);
|
|
99
|
+
throw new Error(`Rust Compilation Failed for ${id}`);
|
|
100
|
+
}
|
|
101
|
+
if (debug) {
|
|
102
|
+
console.log(`[Angular Compiler] Successfully compiled: ${id}`);
|
|
103
|
+
}
|
|
104
|
+
return { code: result, map: null };
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.error(`[Angular Compiler Failed] ${id}:`, e);
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
handleHotUpdate({ file, server }) {
|
|
111
|
+
if (file.endsWith(".html")) {
|
|
112
|
+
const tsFile = file.replace(/\.html$/, ".ts");
|
|
113
|
+
if (debug) {
|
|
114
|
+
console.log(`[HMR] HTML changed: ${file}`);
|
|
115
|
+
console.log(`[HMR] Invalidating TS: ${tsFile}`);
|
|
116
|
+
}
|
|
117
|
+
const mod = server.moduleGraph.getModuleById(tsFile);
|
|
118
|
+
if (mod) {
|
|
119
|
+
server.moduleGraph.invalidateModule(mod);
|
|
120
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
121
|
+
return [];
|
|
122
|
+
} else {
|
|
123
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
var vite_default = angularCompilerVitePlugin;
|
|
131
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
132
|
+
0 && (module.exports = {
|
|
133
|
+
angularCompilerVitePlugin
|
|
134
|
+
});
|
|
135
|
+
//# sourceMappingURL=vite.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/compiler/vite.ts"],"sourcesContent":["/**\n * Angular Compiler Plugin for Vite\n *\n * This plugin compiles Angular TypeScript files using the Rust-based Angular compiler.\n * Use with the linker plugin for a complete Angular build solution.\n *\n * @example\n * ```js\n * import { angularCompilerVitePlugin } from 'angular-rust-plugins/compiler/vite';\n * import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [\n * angularLinkerVitePlugin(),\n * angularCompilerVitePlugin(),\n * ],\n * });\n * ```\n */\n\nimport type { Plugin, HmrContext } from \"vite\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nexport interface CompilerOptions {\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom path to the Angular Rust binding package\n */\n bindingPath?: string;\n}\n\nfunction getCompiler(options?: CompilerOptions): CompilerBinding {\n if (compilerInstance) {\n return compilerInstance;\n }\n\n try {\n let binding: { Compiler: new () => CompilerBinding };\n\n if (options?.bindingPath) {\n const require = createRequire(import.meta.url);\n binding = require(options.bindingPath);\n } else {\n // Load from bundled binding directory\n // Use import.meta.url to get the actual location of this file\n const currentFileUrl = import.meta.url;\n const currentFilePath = fileURLToPath(currentFileUrl);\n const currentDir = dirname(currentFilePath);\n const require = createRequire(currentFileUrl);\n\n // Try multiple possible binding locations\n const possiblePaths = [\n join(currentDir, \"..\", \"binding\"), // dist/compiler/../binding\n join(currentDir, \"..\", \"..\", \"binding\"), // in case of deeper nesting\n join(currentDir, \"binding\"), // same directory\n ];\n\n let loadedBinding: { Compiler: new () => CompilerBinding } | null = null;\n let lastError: unknown = null;\n\n for (const bindingPath of possiblePaths) {\n try {\n loadedBinding = require(bindingPath);\n break;\n } catch (e) {\n lastError = e;\n }\n }\n\n if (!loadedBinding) {\n throw (\n lastError ||\n new Error(\"Could not find binding in any expected location\")\n );\n }\n\n binding = loadedBinding;\n }\n\n compilerInstance = new binding.Compiler();\n return compilerInstance;\n } catch (e) {\n throw new Error(`Failed to load Angular Rust binding. Error: ${e}`);\n }\n}\n\n/**\n * Creates a Vite plugin for Angular Rust compiler\n * Compiles .ts files (except .d.ts) using the Rust compiler\n */\nexport function angularCompilerVitePlugin(options?: CompilerOptions): Plugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-rust-compiler\",\n enforce: \"pre\",\n\n transform(code: string, id: string) {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Skip node_modules - those are handled by linker, not compiler\n if (id.includes(\"node_modules\")) {\n return null;\n }\n\n // Only process TypeScript files, skip declaration files\n if (!id.endsWith(\".ts\") || id.endsWith(\".d.ts\")) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Compiling: ${id}`);\n }\n\n try {\n const result = compiler.compile(id, code);\n\n if (result.startsWith(\"/* Error\")) {\n console.error(`[Angular Compiler Error] ${id}:\\n${result}`);\n throw new Error(`Rust Compilation Failed for ${id}`);\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Successfully compiled: ${id}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Compiler Failed] ${id}:`, e);\n throw e;\n }\n },\n\n handleHotUpdate({ file, server }: HmrContext) {\n // When HTML template changes, invalidate the corresponding TS file\n if (file.endsWith(\".html\")) {\n const tsFile = file.replace(/\\.html$/, \".ts\");\n\n if (debug) {\n console.log(`[HMR] HTML changed: ${file}`);\n console.log(`[HMR] Invalidating TS: ${tsFile}`);\n }\n\n const mod = server.moduleGraph.getModuleById(tsFile);\n if (mod) {\n server.moduleGraph.invalidateModule(mod);\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n return [];\n } else {\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n return [];\n }\n }\n },\n };\n}\n\nexport default angularCompilerVitePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,oBAA8B;AAC9B,kBAA8B;AAC9B,iBAA8B;AAxB9B;AA2BA,IAAI,mBAA2C;AAe/C,SAAS,YAAY,SAA4C;AAC/D,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,QAAI;AAEJ,QAAI,SAAS,aAAa;AACxB,YAAMA,eAAU,6BAAc,YAAY,GAAG;AAC7C,gBAAUA,SAAQ,QAAQ,WAAW;AAAA,IACvC,OAAO;AAGL,YAAM,iBAAiB,YAAY;AACnC,YAAM,sBAAkB,0BAAc,cAAc;AACpD,YAAM,iBAAa,qBAAQ,eAAe;AAC1C,YAAMA,eAAU,6BAAc,cAAc;AAG5C,YAAM,gBAAgB;AAAA,YACpB,kBAAK,YAAY,MAAM,SAAS;AAAA;AAAA,YAChC,kBAAK,YAAY,MAAM,MAAM,SAAS;AAAA;AAAA,YACtC,kBAAK,YAAY,SAAS;AAAA;AAAA,MAC5B;AAEA,UAAI,gBAAgE;AACpE,UAAI,YAAqB;AAEzB,iBAAW,eAAe,eAAe;AACvC,YAAI;AACF,0BAAgBA,SAAQ,WAAW;AACnC;AAAA,QACF,SAAS,GAAG;AACV,sBAAY;AAAA,QACd;AAAA,MACF;AAEA,UAAI,CAAC,eAAe;AAClB,cACE,aACA,IAAI,MAAM,iDAAiD;AAAA,MAE/D;AAEA,gBAAU;AAAA,IACZ;AAEA,uBAAmB,IAAI,QAAQ,SAAS;AACxC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,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B,GAAG;AACvC,iBAAO,GAAG,KAAK,EAAE,MAAM,eAAe,MAAM,IAAI,CAAC;AACjD,iBAAO,CAAC;AAAA,QACV,OAAO;AACL,iBAAO,GAAG,KAAK,EAAE,MAAM,eAAe,MAAM,IAAI,CAAC;AACjD,iBAAO,CAAC;AAAA,QACV;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,eAAQ;","names":["require"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Angular Compiler Plugin for Vite
|
|
5
|
+
*
|
|
6
|
+
* This plugin compiles Angular TypeScript files using the Rust-based Angular compiler.
|
|
7
|
+
* Use with the linker plugin for a complete Angular build solution.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* import { angularCompilerVitePlugin } from 'angular-rust-plugins/compiler/vite';
|
|
12
|
+
* import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';
|
|
13
|
+
* import { defineConfig } from 'vite';
|
|
14
|
+
*
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* plugins: [
|
|
17
|
+
* angularLinkerVitePlugin(),
|
|
18
|
+
* angularCompilerVitePlugin(),
|
|
19
|
+
* ],
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface CompilerOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Enable debug logging
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Custom path to the Angular Rust binding package
|
|
32
|
+
*/
|
|
33
|
+
bindingPath?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Vite plugin for Angular Rust compiler
|
|
37
|
+
* Compiles .ts files (except .d.ts) using the Rust compiler
|
|
38
|
+
*/
|
|
39
|
+
declare function angularCompilerVitePlugin(options?: CompilerOptions): Plugin;
|
|
40
|
+
|
|
41
|
+
export { type CompilerOptions, angularCompilerVitePlugin, angularCompilerVitePlugin as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Angular Compiler Plugin for Vite
|
|
5
|
+
*
|
|
6
|
+
* This plugin compiles Angular TypeScript files using the Rust-based Angular compiler.
|
|
7
|
+
* Use with the linker plugin for a complete Angular build solution.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```js
|
|
11
|
+
* import { angularCompilerVitePlugin } from 'angular-rust-plugins/compiler/vite';
|
|
12
|
+
* import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';
|
|
13
|
+
* import { defineConfig } from 'vite';
|
|
14
|
+
*
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* plugins: [
|
|
17
|
+
* angularLinkerVitePlugin(),
|
|
18
|
+
* angularCompilerVitePlugin(),
|
|
19
|
+
* ],
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
interface CompilerOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Enable debug logging
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Custom path to the Angular Rust binding package
|
|
32
|
+
*/
|
|
33
|
+
bindingPath?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Vite plugin for Angular Rust compiler
|
|
37
|
+
* Compiles .ts files (except .d.ts) using the Rust compiler
|
|
38
|
+
*/
|
|
39
|
+
declare function angularCompilerVitePlugin(options?: CompilerOptions): Plugin;
|
|
40
|
+
|
|
41
|
+
export { type CompilerOptions, angularCompilerVitePlugin, angularCompilerVitePlugin as default };
|
package/compiler/vite.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/compiler/vite.ts
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
import { dirname, join } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
var compilerInstance = null;
|
|
6
|
+
function getCompiler(options) {
|
|
7
|
+
if (compilerInstance) {
|
|
8
|
+
return compilerInstance;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
let binding;
|
|
12
|
+
if (options?.bindingPath) {
|
|
13
|
+
const require2 = createRequire(import.meta.url);
|
|
14
|
+
binding = require2(options.bindingPath);
|
|
15
|
+
} else {
|
|
16
|
+
const currentFileUrl = import.meta.url;
|
|
17
|
+
const currentFilePath = fileURLToPath(currentFileUrl);
|
|
18
|
+
const currentDir = dirname(currentFilePath);
|
|
19
|
+
const require2 = createRequire(currentFileUrl);
|
|
20
|
+
const possiblePaths = [
|
|
21
|
+
join(currentDir, "..", "binding"),
|
|
22
|
+
// dist/compiler/../binding
|
|
23
|
+
join(currentDir, "..", "..", "binding"),
|
|
24
|
+
// in case of deeper nesting
|
|
25
|
+
join(currentDir, "binding")
|
|
26
|
+
// same directory
|
|
27
|
+
];
|
|
28
|
+
let loadedBinding = null;
|
|
29
|
+
let lastError = null;
|
|
30
|
+
for (const bindingPath of possiblePaths) {
|
|
31
|
+
try {
|
|
32
|
+
loadedBinding = require2(bindingPath);
|
|
33
|
+
break;
|
|
34
|
+
} catch (e) {
|
|
35
|
+
lastError = e;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!loadedBinding) {
|
|
39
|
+
throw lastError || new Error("Could not find binding in any expected location");
|
|
40
|
+
}
|
|
41
|
+
binding = loadedBinding;
|
|
42
|
+
}
|
|
43
|
+
compilerInstance = new binding.Compiler();
|
|
44
|
+
return compilerInstance;
|
|
45
|
+
} catch (e) {
|
|
46
|
+
throw new Error(`Failed to load Angular Rust binding. Error: ${e}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function angularCompilerVitePlugin(options) {
|
|
50
|
+
const debug = options?.debug ?? false;
|
|
51
|
+
let compiler;
|
|
52
|
+
return {
|
|
53
|
+
name: "angular-rust-compiler",
|
|
54
|
+
enforce: "pre",
|
|
55
|
+
transform(code, id) {
|
|
56
|
+
if (!compiler) {
|
|
57
|
+
compiler = getCompiler(options);
|
|
58
|
+
}
|
|
59
|
+
if (id.includes("node_modules")) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (!id.endsWith(".ts") || id.endsWith(".d.ts")) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (debug) {
|
|
66
|
+
console.log(`[Angular Compiler] Compiling: ${id}`);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const result = compiler.compile(id, code);
|
|
70
|
+
if (result.startsWith("/* Error")) {
|
|
71
|
+
console.error(`[Angular Compiler Error] ${id}:
|
|
72
|
+
${result}`);
|
|
73
|
+
throw new Error(`Rust Compilation Failed for ${id}`);
|
|
74
|
+
}
|
|
75
|
+
if (debug) {
|
|
76
|
+
console.log(`[Angular Compiler] Successfully compiled: ${id}`);
|
|
77
|
+
}
|
|
78
|
+
return { code: result, map: null };
|
|
79
|
+
} catch (e) {
|
|
80
|
+
console.error(`[Angular Compiler Failed] ${id}:`, e);
|
|
81
|
+
throw e;
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
handleHotUpdate({ file, server }) {
|
|
85
|
+
if (file.endsWith(".html")) {
|
|
86
|
+
const tsFile = file.replace(/\.html$/, ".ts");
|
|
87
|
+
if (debug) {
|
|
88
|
+
console.log(`[HMR] HTML changed: ${file}`);
|
|
89
|
+
console.log(`[HMR] Invalidating TS: ${tsFile}`);
|
|
90
|
+
}
|
|
91
|
+
const mod = server.moduleGraph.getModuleById(tsFile);
|
|
92
|
+
if (mod) {
|
|
93
|
+
server.moduleGraph.invalidateModule(mod);
|
|
94
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
95
|
+
return [];
|
|
96
|
+
} else {
|
|
97
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
var vite_default = angularCompilerVitePlugin;
|
|
105
|
+
export {
|
|
106
|
+
angularCompilerVitePlugin,
|
|
107
|
+
vite_default as default
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=vite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/compiler/vite.ts"],"sourcesContent":["/**\n * Angular Compiler Plugin for Vite\n *\n * This plugin compiles Angular TypeScript files using the Rust-based Angular compiler.\n * Use with the linker plugin for a complete Angular build solution.\n *\n * @example\n * ```js\n * import { angularCompilerVitePlugin } from 'angular-rust-plugins/compiler/vite';\n * import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [\n * angularLinkerVitePlugin(),\n * angularCompilerVitePlugin(),\n * ],\n * });\n * ```\n */\n\nimport type { Plugin, HmrContext } from \"vite\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nexport interface CompilerOptions {\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom path to the Angular Rust binding package\n */\n bindingPath?: string;\n}\n\nfunction getCompiler(options?: CompilerOptions): CompilerBinding {\n if (compilerInstance) {\n return compilerInstance;\n }\n\n try {\n let binding: { Compiler: new () => CompilerBinding };\n\n if (options?.bindingPath) {\n const require = createRequire(import.meta.url);\n binding = require(options.bindingPath);\n } else {\n // Load from bundled binding directory\n // Use import.meta.url to get the actual location of this file\n const currentFileUrl = import.meta.url;\n const currentFilePath = fileURLToPath(currentFileUrl);\n const currentDir = dirname(currentFilePath);\n const require = createRequire(currentFileUrl);\n\n // Try multiple possible binding locations\n const possiblePaths = [\n join(currentDir, \"..\", \"binding\"), // dist/compiler/../binding\n join(currentDir, \"..\", \"..\", \"binding\"), // in case of deeper nesting\n join(currentDir, \"binding\"), // same directory\n ];\n\n let loadedBinding: { Compiler: new () => CompilerBinding } | null = null;\n let lastError: unknown = null;\n\n for (const bindingPath of possiblePaths) {\n try {\n loadedBinding = require(bindingPath);\n break;\n } catch (e) {\n lastError = e;\n }\n }\n\n if (!loadedBinding) {\n throw (\n lastError ||\n new Error(\"Could not find binding in any expected location\")\n );\n }\n\n binding = loadedBinding;\n }\n\n compilerInstance = new binding.Compiler();\n return compilerInstance;\n } catch (e) {\n throw new Error(`Failed to load Angular Rust binding. Error: ${e}`);\n }\n}\n\n/**\n * Creates a Vite plugin for Angular Rust compiler\n * Compiles .ts files (except .d.ts) using the Rust compiler\n */\nexport function angularCompilerVitePlugin(options?: CompilerOptions): Plugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-rust-compiler\",\n enforce: \"pre\",\n\n transform(code: string, id: string) {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Skip node_modules - those are handled by linker, not compiler\n if (id.includes(\"node_modules\")) {\n return null;\n }\n\n // Only process TypeScript files, skip declaration files\n if (!id.endsWith(\".ts\") || id.endsWith(\".d.ts\")) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Compiling: ${id}`);\n }\n\n try {\n const result = compiler.compile(id, code);\n\n if (result.startsWith(\"/* Error\")) {\n console.error(`[Angular Compiler Error] ${id}:\\n${result}`);\n throw new Error(`Rust Compilation Failed for ${id}`);\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Successfully compiled: ${id}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Compiler Failed] ${id}:`, e);\n throw e;\n }\n },\n\n handleHotUpdate({ file, server }: HmrContext) {\n // When HTML template changes, invalidate the corresponding TS file\n if (file.endsWith(\".html\")) {\n const tsFile = file.replace(/\\.html$/, \".ts\");\n\n if (debug) {\n console.log(`[HMR] HTML changed: ${file}`);\n console.log(`[HMR] Invalidating TS: ${tsFile}`);\n }\n\n const mod = server.moduleGraph.getModuleById(tsFile);\n if (mod) {\n server.moduleGraph.invalidateModule(mod);\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n return [];\n } else {\n server.ws.send({ type: \"full-reload\", path: \"*\" });\n return [];\n }\n }\n },\n };\n}\n\nexport default angularCompilerVitePlugin;\n"],"mappings":";AAsBA,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAG9B,IAAI,mBAA2C;AAe/C,SAAS,YAAY,SAA4C;AAC/D,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,QAAI;AAEJ,QAAI,SAAS,aAAa;AACxB,YAAMA,WAAU,cAAc,YAAY,GAAG;AAC7C,gBAAUA,SAAQ,QAAQ,WAAW;AAAA,IACvC,OAAO;AAGL,YAAM,iBAAiB,YAAY;AACnC,YAAM,kBAAkB,cAAc,cAAc;AACpD,YAAM,aAAa,QAAQ,eAAe;AAC1C,YAAMA,WAAU,cAAc,cAAc;AAG5C,YAAM,gBAAgB;AAAA,QACpB,KAAK,YAAY,MAAM,SAAS;AAAA;AAAA,QAChC,KAAK,YAAY,MAAM,MAAM,SAAS;AAAA;AAAA,QACtC,KAAK,YAAY,SAAS;AAAA;AAAA,MAC5B;AAEA,UAAI,gBAAgE;AACpE,UAAI,YAAqB;AAEzB,iBAAW,eAAe,eAAe;AACvC,YAAI;AACF,0BAAgBA,SAAQ,WAAW;AACnC;AAAA,QACF,SAAS,GAAG;AACV,sBAAY;AAAA,QACd;AAAA,MACF;AAEA,UAAI,CAAC,eAAe;AAClB,cACE,aACA,IAAI,MAAM,iDAAiD;AAAA,MAE/D;AAEA,gBAAU;AAAA,IACZ;AAEA,uBAAmB,IAAI,QAAQ,SAAS;AACxC,WAAO;AAAA,EACT,SAAS,G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