angular-rust-plugins 0.4.0 → 0.6.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/binding/angular-binding.darwin-arm64.node +0 -0
- package/binding/index.d.ts +12 -3
- package/binding/index.js +132 -110
- package/compiler/index.cjs +70 -4
- package/compiler/index.cjs.map +1 -1
- package/compiler/index.d.cts +0 -10
- package/compiler/index.d.ts +0 -10
- package/compiler/index.js +70 -4
- package/compiler/index.js.map +1 -1
- package/compiler/vite.cjs +70 -4
- package/compiler/vite.cjs.map +1 -1
- package/compiler/vite.js +70 -4
- package/compiler/vite.js.map +1 -1
- package/index.cjs +83 -18
- package/index.cjs.map +1 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +83 -18
- package/index.js.map +1 -1
- package/linker/index.cjs +13 -14
- package/linker/index.cjs.map +1 -1
- package/linker/index.js +13 -14
- package/linker/index.js.map +1 -1
- package/linker/rolldown.cjs +7 -15
- package/linker/rolldown.cjs.map +1 -1
- package/linker/rolldown.d.cts +1 -1
- package/linker/rolldown.d.ts +1 -1
- package/linker/rolldown.js +7 -15
- package/linker/rolldown.js.map +1 -1
- package/linker/vite.cjs +6 -19
- package/linker/vite.cjs.map +1 -1
- package/linker/vite.d.cts +1 -1
- package/linker/vite.d.ts +1 -1
- package/linker/vite.js +6 -19
- package/linker/vite.js.map +1 -1
- package/package.json +1 -1
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/linker/esbuild.ts","../src/linker/types.ts","../src/linker/rolldown.ts","../src/linker/vite.ts","../src/compiler/vite.ts"],"sourcesContent":["/**\n * Angular Rust Plugins\n *\n * High-performance Angular linker and compiler plugins powered by Rust.\n * Supports Vite, esbuild, Rolldown, and more bundlers.\n *\n * @packageDocumentation\n *\n * @example\n * ```js\n * // Use linker + compiler together\n * import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';\n * import { angularCompilerVitePlugin } from 'angular-rust-plugins/compiler/vite';\n *\n * export default defineConfig({\n * plugins: [\n * angularLinkerVitePlugin(),\n * angularCompilerVitePlugin(),\n * ],\n * });\n * ```\n */\n\n// Re-export linker plugins\nexport {\n angularLinkerEsbuildPlugin,\n angularLinkerRolldownPlugin,\n angularLinkerVitePlugin,\n getAngularViteConfig,\n ANGULAR_PACKAGES,\n NON_ANGULAR_PACKAGES,\n needsLinking,\n isAngularPackage,\n isJsFile,\n cleanModuleId,\n} from \"./linker\";\n\nexport type {\n LinkerOptions,\n LinkerResult,\n ViteLinkerPluginOptions,\n} from \"./linker\";\n\n// Re-export compiler plugins\nexport { angularCompilerVitePlugin } from \"./compiler\";\n\nexport type { CompilerOptions, CompilerBinding } from \"./compiler\";\n","/**\n * Angular Linker Plugin for esbuild\n *\n * Use this plugin with Vite's optimizeDeps.esbuildOptions or standalone esbuild.\n *\n * @example\n * ```js\n * import { angularLinkerEsbuildPlugin } from 'vite-plugin-angular-rust/esbuild';\n *\n * // With esbuild\n * import esbuild from 'esbuild';\n *\n * esbuild.build({\n * plugins: [angularLinkerEsbuildPlugin()],\n * // ...\n * });\n *\n * // With Vite\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * optimizeDeps: {\n * esbuildOptions: {\n * plugins: [angularLinkerEsbuildPlugin()],\n * },\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"esbuild\";\nimport { promises as fs } from \"fs\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport { needsLinking } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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 an esbuild plugin for Angular linker\n */\nexport function angularLinkerEsbuildPlugin(options?: LinkerOptions): Plugin {\n return {\n name: \"angular-linker-esbuild\",\n setup(build) {\n const compiler = getCompiler(options);\n const debug = options?.debug ?? false;\n\n // Handle all .mjs and .js files in @angular packages\n build.onLoad({ filter: /@angular\\/.*\\.(mjs|js)$/ }, async (args) => {\n if (debug) {\n console.log(`[Angular Linker] Processing: ${args.path}`);\n }\n\n const code = await fs.readFile(args.path, \"utf8\");\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return { contents: code, loader: \"js\" };\n }\n\n try {\n const result = compiler.linkFile(args.path, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n if (debug) {\n console.error(`[Angular Linker Error] ${args.path}:\\n${result}`);\n }\n return { contents: code, loader: \"js\" };\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${args.path}`);\n }\n\n return { contents: result, loader: \"js\" };\n } catch (e) {\n if (debug) {\n console.error(`[Angular Linker Failed] ${args.path}:`, e);\n }\n return { contents: code, loader: \"js\" };\n }\n });\n },\n };\n}\n\nexport default angularLinkerEsbuildPlugin;\n","/**\n * Angular Linker Plugin Types\n */\n\nexport interface LinkerOptions {\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom path to the Angular Rust binding package\n * If not specified, will try to resolve @anthropic/angular-rust-binding\n */\n bindingPath?: string;\n}\n\nexport interface LinkerResult {\n code: string;\n map: null | undefined;\n}\n\nexport interface CompilerBinding {\n linkFile(filePath: string, code: string): string;\n compile?(filePath: string, code: string): string;\n}\n\n/**\n * Check if file contains Angular partial declarations that need linking\n */\nexport function needsLinking(code: string): boolean {\n return code.includes(\"ɵɵngDeclare\");\n}\n\n/**\n * Check if file is an Angular package file\n */\nexport function isAngularPackage(id: string): boolean {\n return id.includes(\"@angular\") || id.includes(\"/@angular/\");\n}\n\n/**\n * Check if file is a JavaScript/MJS file\n */\nexport function isJsFile(id: string): boolean {\n const cleanId = id.split(\"?\")[0];\n return cleanId.endsWith(\".mjs\") || cleanId.endsWith(\".js\");\n}\n\n/**\n * Clean module ID by removing query strings\n */\nexport function cleanModuleId(id: string): string {\n return id.split(\"?\")[0];\n}\n\n/**\n * Default Angular packages to exclude from pre-bundling\n */\nexport const ANGULAR_PACKAGES = [\n \"@angular/core\",\n \"@angular/common\",\n \"@angular/platform-browser\",\n \"@angular/platform-browser-dynamic\",\n \"@angular/router\",\n \"@angular/forms\",\n \"@angular/animations\",\n \"@angular/cdk\",\n \"@angular/material\",\n];\n\n/**\n * Packages that don't need linking and should be included in pre-bundling\n */\nexport const NON_ANGULAR_PACKAGES = [\"zone.js\", \"rxjs\", \"rxjs/operators\"];\n","/**\n * Angular Linker Plugin for Rolldown\n *\n * Use this plugin with rolldown-vite or standalone Rolldown.\n *\n * @example\n * ```js\n * import { angularLinkerRolldownPlugin } from 'vite-plugin-angular-rust/rolldown';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerRolldownPlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * ],\n * },\n * });\n * ```\n */\n\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions, LinkerResult } from \"./types\";\nimport {\n needsLinking,\n isAngularPackage,\n isJsFile,\n cleanModuleId,\n} from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface RolldownPlugin {\n name: string;\n transform(\n code: string,\n id: string\n ): Promise<LinkerResult | null> | LinkerResult | null;\n}\n\n/**\n * Creates a Rolldown-compatible plugin for Angular linker\n */\nexport function angularLinkerRolldownPlugin(\n options?: LinkerOptions\n): RolldownPlugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-rolldown\",\n async transform(code: string, id: string): Promise<LinkerResult | null> {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Only process @angular packages with .mjs or .js extensions\n const isInNodeModules = id.includes(\"node_modules\");\n const cleanId = cleanModuleId(id);\n\n if (!isAngularPackage(id) || !isInNodeModules || !isJsFile(id)) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Angular Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\nexport default angularLinkerRolldownPlugin;\n","/**\n * Angular Linker Plugin for Vite\n *\n * This plugin handles Angular linking for both Vite's dev server (with rolldown/esbuild)\n * and production builds.\n *\n * @example\n * ```js\n * import { angularLinkerVitePlugin } from 'vite-plugin-angular-rust/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerVitePlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * '@angular/forms',\n * ],\n * include: ['zone.js', 'rxjs', 'rxjs/operators'],\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"vite\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport {\n needsLinking,\n isAngularPackage,\n isJsFile,\n cleanModuleId,\n ANGULAR_PACKAGES,\n NON_ANGULAR_PACKAGES,\n} from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface ViteLinkerPluginOptions extends LinkerOptions {\n /**\n * Additional packages to exclude from pre-bundling\n */\n excludePackages?: string[];\n\n /**\n * Additional packages to include in pre-bundling (non-Angular packages)\n */\n includePackages?: string[];\n}\n\n/**\n * Creates a Vite plugin for Angular linker\n * Works with both rolldown-vite and standard Vite (esbuild)\n */\nexport function angularLinkerVitePlugin(\n options?: ViteLinkerPluginOptions\n): Plugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-vite\",\n enforce: \"pre\",\n\n config(config) {\n // Merge optimizeDeps configuration\n const excludePackages = [\n ...ANGULAR_PACKAGES,\n ...(options?.excludePackages ?? []),\n ];\n const includePackages = [\n ...NON_ANGULAR_PACKAGES,\n ...(options?.includePackages ?? []),\n ];\n\n return {\n optimizeDeps: {\n exclude: excludePackages,\n include: includePackages,\n },\n };\n },\n\n transform(code: string, id: string) {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Only process node_modules\n if (!id.includes(\"node_modules\")) {\n return null;\n }\n\n // Only process Angular packages\n if (!isAngularPackage(id)) {\n return null;\n }\n\n // Only process JS files\n if (!isJsFile(id)) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return null;\n }\n\n const cleanId = cleanModuleId(id);\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Angular Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\n/**\n * Get recommended Vite config for Angular with Rust linker\n */\nexport function getAngularViteConfig() {\n return {\n plugins: [angularLinkerVitePlugin()],\n optimizeDeps: {\n exclude: ANGULAR_PACKAGES,\n include: NON_ANGULAR_PACKAGES,\n },\n };\n}\n\nexport { ANGULAR_PACKAGES, NON_ANGULAR_PACKAGES };\nexport default angularLinkerVitePlugin;\n","/**\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+BA,gBAA+B;AAC/B,oBAA8B;AAC9B,kBAA8B;AAC9B,iBAA8B;;;ACHvB,SAAS,aAAa,MAAuB;AAClD,SAAO,KAAK,SAAS,uBAAa;AACpC;AAKO,SAAS,iBAAiB,IAAqB;AACpD,SAAO,GAAG,SAAS,UAAU,KAAK,GAAG,SAAS,YAAY;AAC5D;AAKO,SAAS,SAAS,IAAqB;AAC5C,QAAM,UAAU,GAAG,MAAM,GAAG,EAAE,CAAC;AAC/B,SAAO,QAAQ,SAAS,MA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AuB,IAAI,EAAE;AACzC,kBAAQ,IAAI,0BAA0B,MAAM,EAAE;AAAA,QAChD;AAEA,cAAM,MAAM,OAAO,YAAY,cAAc,MAAM;AACnD,YAAI,KAAK;AACP,iBAAO,YAAY,iBAAiB,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;","names":["require","fs","import_module","import_path","import_url","import_meta","compilerInstance","getCompiler","require","import_module","import_path","import_url","import_meta","compilerInstance","getCompiler","require","import_module","import_path","import_url","import_meta","compilerInstance","getCompiler","require"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/linker/esbuild.ts","../src/linker/types.ts","../src/linker/rolldown.ts","../src/linker/vite.ts","../src/compiler/vite.ts"],"sourcesContent":["/**\n * Angular Rust Plugins\n *\n * High-performance Angular linker and compiler plugins powered by Rust.\n * Supports Vite, esbuild, Rolldown, and more bundlers.\n *\n * @packageDocumentation\n *\n * @example\n * ```js\n * // Use linker + compiler together\n * import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';\n * import { angularCompilerVitePlugin } from 'angular-rust-plugins/compiler/vite';\n *\n * export default defineConfig({\n * plugins: [\n * angularLinkerVitePlugin(),\n * angularCompilerVitePlugin(),\n * ],\n * });\n * ```\n */\n\n// Re-export linker plugins\nexport {\n angularLinkerEsbuildPlugin,\n angularLinkerRolldownPlugin,\n angularLinkerVitePlugin,\n getAngularViteConfig,\n ANGULAR_PACKAGES,\n NON_ANGULAR_PACKAGES,\n needsLinking,\n isAngularPackage,\n isJsFile,\n cleanModuleId,\n} from \"./linker\";\n\nexport type {\n LinkerOptions,\n LinkerResult,\n ViteLinkerPluginOptions,\n} from \"./linker\";\n\n// Re-export compiler plugins\nexport { angularCompilerVitePlugin } from \"./compiler\";\n\nexport type { CompilerOptions } from \"./compiler\";\n","/**\n * Angular Linker Plugin for esbuild\n *\n * Use this plugin with Vite's optimizeDeps.esbuildOptions or standalone esbuild.\n *\n * @example\n * ```js\n * import { angularLinkerEsbuildPlugin } from 'vite-plugin-angular-rust/esbuild';\n *\n * // With esbuild\n * import esbuild from 'esbuild';\n *\n * esbuild.build({\n * plugins: [angularLinkerEsbuildPlugin()],\n * // ...\n * });\n *\n * // With Vite\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * optimizeDeps: {\n * esbuildOptions: {\n * plugins: [angularLinkerEsbuildPlugin()],\n * },\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"esbuild\";\nimport { promises as fs } from \"fs\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport { needsLinking } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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 an esbuild plugin for Angular linker\n */\nexport function angularLinkerEsbuildPlugin(options?: LinkerOptions): Plugin {\n return {\n name: \"angular-linker-esbuild\",\n setup(build) {\n const compiler = getCompiler(options);\n const debug = options?.debug ?? false;\n\n // Handle all .mjs and .js files in @angular packages\n build.onLoad({ filter: /@angular\\/.*\\.(mjs|js)$/ }, async (args) => {\n if (debug) {\n console.log(`[Angular Linker] Processing: ${args.path}`);\n }\n\n const code = await fs.readFile(args.path, \"utf8\");\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return { contents: code, loader: \"js\" };\n }\n\n try {\n const result = compiler.linkFile(args.path, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n if (debug) {\n console.error(`[Angular Linker Error] ${args.path}:\\n${result}`);\n }\n return { contents: code, loader: \"js\" };\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${args.path}`);\n }\n\n return { contents: result, loader: \"js\" };\n } catch (e) {\n if (debug) {\n console.error(`[Angular Linker Failed] ${args.path}:`, e);\n }\n return { contents: code, loader: \"js\" };\n }\n });\n },\n };\n}\n\nexport default angularLinkerEsbuildPlugin;\n","/**\n * Angular Linker Plugin Types\n */\n\nexport interface LinkerOptions {\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom path to the Angular Rust binding package\n * If not specified, will try to resolve @anthropic/angular-rust-binding\n */\n bindingPath?: string;\n}\n\nexport interface LinkerResult {\n code: string;\n map: null | undefined;\n}\n\nexport interface CompilerBinding {\n linkFile(filePath: string, code: string): string;\n compile?(filePath: string, code: string): string;\n}\n\n/**\n * Check if file contains Angular partial declarations that need linking\n */\nexport function needsLinking(code: string): boolean {\n return code.includes(\"ɵɵngDeclare\");\n}\n\n/**\n * Check if file is an Angular package file\n */\nexport function isAngularPackage(id: string): boolean {\n return id.includes(\"@angular\") || id.includes(\"/@angular/\");\n}\n\n/**\n * Check if file is a JavaScript/MJS file\n */\nexport function isJsFile(id: string): boolean {\n const cleanId = id.split(\"?\")[0];\n return cleanId.endsWith(\".mjs\") || cleanId.endsWith(\".js\");\n}\n\n/**\n * Clean module ID by removing query strings\n */\nexport function cleanModuleId(id: string): string {\n return id.split(\"?\")[0];\n}\n\n/**\n * Default Angular packages to exclude from pre-bundling\n */\nexport const ANGULAR_PACKAGES = [\n \"@angular/core\",\n \"@angular/common\",\n \"@angular/platform-browser\",\n \"@angular/platform-browser-dynamic\",\n \"@angular/router\",\n \"@angular/forms\",\n \"@angular/animations\",\n \"@angular/cdk\",\n \"@angular/material\",\n];\n\n/**\n * Packages that don't need linking and should be included in pre-bundling\n */\nexport const NON_ANGULAR_PACKAGES = [\"zone.js\", \"rxjs\", \"rxjs/operators\"];\n","/**\n * Angular Linker Plugin for Rolldown\n *\n * Use this plugin with rolldown-vite or standalone Rolldown.\n *\n * @example\n * ```js\n * import { angularLinkerRolldownPlugin } from 'angular-rust-plugins/linker/rolldown';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerRolldownPlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * ],\n * },\n * });\n * ```\n */\n\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions, LinkerResult } from \"./types\";\nimport { cleanModuleId } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface RolldownPlugin {\n name: string;\n transform(\n code: string,\n id: string\n ): Promise<LinkerResult | null> | LinkerResult | null;\n}\n\n/**\n * Creates a Rolldown-compatible plugin for Angular linker\n */\nexport function angularLinkerRolldownPlugin(\n options?: LinkerOptions\n): RolldownPlugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-rolldown\",\n async transform(code: string, id: string): Promise<LinkerResult | null> {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Logic from vite.config.mjs\n const isAngularPackage = id.includes('@angular') || id.includes('/@angular/');\n const isNodeModules = id.includes('node_modules');\n const cleanId = cleanModuleId(id);\n const isJsFile = cleanId.endsWith('.mjs') || cleanId.endsWith('.js');\n\n if (!isAngularPackage || !isNodeModules || !isJsFile) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!code.includes('ɵɵngDeclare')) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Rolldown Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Rolldown Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\nexport default angularLinkerRolldownPlugin;\n","/**\n * Angular Linker Plugin for Vite\n *\n * This plugin handles Angular linking for both Vite's dev server (with rolldown/esbuild)\n * and production builds.\n *\n * @example\n * ```js\n * import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerVitePlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * '@angular/forms',\n * ],\n * include: ['zone.js', 'rxjs', 'rxjs/operators'],\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"vite\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport {\n cleanModuleId,\n ANGULAR_PACKAGES,\n NON_ANGULAR_PACKAGES,\n} from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface ViteLinkerPluginOptions extends LinkerOptions {\n /**\n * Additional packages to exclude from pre-bundling\n */\n excludePackages?: string[];\n\n /**\n * Additional packages to include in pre-bundling (non-Angular packages)\n */\n includePackages?: string[];\n}\n\n/**\n * Creates a Vite plugin for Angular linker\n * Works with both rolldown-vite and standard Vite (esbuild)\n */\nexport function angularLinkerVitePlugin(\n options?: ViteLinkerPluginOptions\n): Plugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-vite\",\n enforce: \"pre\",\n\n config(config) {\n // Merge optimizeDeps configuration\n const excludePackages = [\n ...ANGULAR_PACKAGES,\n ...(options?.excludePackages ?? []),\n ];\n const includePackages = [\n ...NON_ANGULAR_PACKAGES,\n ...(options?.includePackages ?? []),\n ];\n\n return {\n optimizeDeps: {\n exclude: excludePackages,\n include: includePackages,\n },\n };\n },\n\n transform(code: string, id: string) {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Logic from vite.config.mjs\n const isAngularPackage = id.includes('@angular') || id.includes('/@angular/');\n const isNodeModules = id.includes('node_modules');\n const cleanId = cleanModuleId(id);\n const isJsFile = cleanId.endsWith('.mjs') || cleanId.endsWith('.js');\n\n if (!isAngularPackage || !isNodeModules || !isJsFile) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!code.includes('ɵɵngDeclare')) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Angular Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\n/**\n * Get recommended Vite config for Angular with Rust linker\n */\nexport function getAngularViteConfig() {\n return {\n plugins: [angularLinkerVitePlugin()],\n optimizeDeps: {\n exclude: ANGULAR_PACKAGES,\n include: NON_ANGULAR_PACKAGES,\n },\n };\n}\n\nexport { ANGULAR_PACKAGES, NON_ANGULAR_PACKAGES };\nexport default angularLinkerVitePlugin;\n","/**\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 { Compiler } from \"../binding\";\n\nlet compilerInstance: Compiler | 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\n// ============ Diagnostic Formatting ============\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst CYAN = '\\x1b[36m';\nconst BOLD = '\\x1b[1m';\nconst RESET = '\\x1b[0m';\n\nfunction formatDiagnostic(diag: any, sourceCode: string): string {\n const level = 'WARNING';\n const codeStr = `NG${diag.code}`;\n const file = diag.file || 'unknown';\n\n let line = 1;\n let col = 0;\n let lineStartPos = 0;\n\n if (diag.start !== undefined && diag.start !== null) {\n for (let i = 0; i < diag.start && i < sourceCode.length; i++) {\n if (sourceCode[i] === '\\n') {\n line++;\n col = 0;\n lineStartPos = i + 1;\n } else {\n col++;\n }\n }\n }\n\n let output = `\\n${BOLD}${YELLOW}▲ [${level}] ${RED}${codeStr}${RESET}${BOLD}: ${diag.message}${RESET} ${YELLOW}[plugin rust-ngc-plugin]${RESET}\\n`;\n\n const lineStr = line.toString();\n const colStr = (col + 1).toString();\n output += `\\n ${CYAN}${file}:${lineStr}:${colStr}:${RESET}\\n`;\n\n let lineEndPos = sourceCode.indexOf('\\n', lineStartPos);\n if (lineEndPos === -1) lineEndPos = sourceCode.length;\n const lineContent = sourceCode.substring(lineStartPos, lineEndPos);\n\n output += ` ${BOLD}${lineStr} │ ${RESET}${lineContent}\\n`;\n\n const gutterWidth = lineStr.length + 3;\n const gutterEmpty = ' '.repeat(gutterWidth);\n const length = diag.length || 1;\n const underline = '~'.repeat(length);\n\n output += ` ${gutterEmpty}${' '.repeat(col)}${RED}${underline}${RESET}`;\n\n return output;\n}\n\nfunction getCompiler(options?: CompilerOptions): Compiler {\n if (compilerInstance) {\n return compilerInstance;\n }\n\n try {\n let binding: { Compiler: new () => Compiler };\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 () => Compiler } | 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: Compiler;\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 but check for Angular packages that need linking\n if (id.includes('node_modules')) {\n if (id.includes('@angular') && code.includes('ɵɵngDeclare')) {\n const cleanId = id.split('?')[0];\n if (cleanId.endsWith('.mjs') || cleanId.endsWith('.js')) {\n try {\n const result = compiler.linkFile(id, code);\n if (result.startsWith('/* Linker Error')) {\n if (debug) console.error(`[Linker Error] ${id}: ${result}`);\n return null;\n }\n return { code: result, map: null };\n } catch (e) {\n if (debug) console.error(`Linker failed for ${id}:`, e);\n return null;\n }\n }\n }\n return null;\n }\n\n // Only process TypeScript files, skip declaration files\n const cleanId = id.split('?')[0];\n if (!cleanId.endsWith('.ts') || cleanId.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 // Handle structured result\n const { code: compiledCode, diagnostics } = result;\n\n if (compiledCode.startsWith('/* Error')) {\n console.error(`[Angular Compiler Error] ${id}:\\n${compiledCode}`);\n throw new Error(`Rust Compilation Failed for ${id}`);\n }\n\n if (diagnostics && diagnostics.length > 0) {\n diagnostics.forEach((diag: any) => {\n console.warn(formatDiagnostic(diag, code));\n });\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Successfully compiled: ${id}`);\n }\n\n return { code: compiledCode, 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC+BA,gBAA+B;AAC/B,oBAA8B;AAC9B,kBAA8B;AAC9B,iBAA8B;;;ACHvB,SAAS,aAAa,MAAuB;AAClD,SAAO,KAAK,SAAS,uBAAa;AACpC;AAKO,SAAS,iBAAiB,IAAqB;AACpD,SAAO,GAAG,SAAS,UAAU,KAAK,GAAG,SAAS,YAAY;AAC5D;AAKO,SAAS,SAAS,IAAqB;AAC5C,QAAM,UAAU,GAAG,MAAM,GAAG,EAAE,CAAC;AAC/B,SAAO,QAAQ,SAAS,MAAM,KAAK,QAAQ,SAAS,KAAK;AAC3D;AAKO,SAAS,cAAc,IAAoB;AAChD,SAAO,GAAG,MAAM,GAAG,EAAE,CAAC;AACxB;AAKO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,uBAA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AI;AAGxC,cAAM,EAAE,MAAM,cAAc,YAAY,IAAI;AAE5C,YAAI,aAAa,WAAW,UAAU,GAAG;AACvC,kBAAQ,MAAM,4BAA4B,EAAE;AAAA,EAAM,YAAY,EAAE;AAChE,gBAAM,IAAI,MAAM,+BAA+B,EAAE,EAAE;AAAA,QACrD;AAEA,YAAI,eAAe,YAAY,SAAS,GAAG;AACzC,sBAAY,QAAQ,CAAC,SAAc;AACjC,oBAAQ,KAAK,iBAAiB,MAAM,IAAI,CAAC;AAAA,UAC3C,CAAC;AAAA,QACH;AAEA,YAAI,OAAO;AACT,kBAAQ,IAAI,6CAA6C,EAAE,EAAE;AAAA,QAC/D;AAEA,eAAO,EAAE,MAAM,cAAc,KAAK,KAAK;AAAA,MACzC,SAAS,GAAG;AACV,gBAAQ,MAAM,6BAA6B,EAAE,KAAK,CAAC;AACnD,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,gBAAgB,EAAE,MAAM,OAAO,GAAe;AAE5C,UAAI,KAAK,SAAS,OAAO,GAAG;AAC1B,cAAM,SAAS,KAAK,QAAQ,WAAW,KAAK;AAE5C,YAAI,OAAO;AACT,kBAAQ,IAAI,uBAAuB,IAAI,EAAE;AACzC,kBAAQ,IAAI,0BAA0B,MAAM,EAAE;AAAA,QAChD;AAEA,cAAM,MAAM,OAAO,YAAY,cAAc,MAAM;AACnD,YAAI,KAAK;AACP,iBAAO,YAAY,iBAAiB,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;","names":["require","fs","import_module","import_path","import_url","import_meta","compilerInstance","getCompiler","require","isAngularPackage","isJsFile","import_module","import_path","import_url","import_meta","compilerInstance","getCompiler","require","isAngularPackage","isJsFile","import_module","import_path","import_url","import_meta","compilerInstance","getCompiler","require","cleanId"]}
|
package/index.d.cts
CHANGED
|
@@ -3,6 +3,5 @@ export { default as angularLinkerRolldownPlugin } from './linker/rolldown.cjs';
|
|
|
3
3
|
export { ViteLinkerPluginOptions, default as angularLinkerVitePlugin, getAngularViteConfig } from './linker/vite.cjs';
|
|
4
4
|
export { A as ANGULAR_PACKAGES, L as LinkerOptions, b as LinkerResult, N as NON_ANGULAR_PACKAGES, c as cleanModuleId, i as isAngularPackage, a as isJsFile, n as needsLinking } from './types-BTaYbdhr.cjs';
|
|
5
5
|
export { CompilerOptions, default as angularCompilerVitePlugin } from './compiler/vite.cjs';
|
|
6
|
-
export { CompilerBinding } from './compiler/index.cjs';
|
|
7
6
|
import 'esbuild';
|
|
8
7
|
import 'vite';
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,5 @@ export { default as angularLinkerRolldownPlugin } from './linker/rolldown.js';
|
|
|
3
3
|
export { ViteLinkerPluginOptions, default as angularLinkerVitePlugin, getAngularViteConfig } from './linker/vite.js';
|
|
4
4
|
export { A as ANGULAR_PACKAGES, L as LinkerOptions, b as LinkerResult, N as NON_ANGULAR_PACKAGES, c as cleanModuleId, i as isAngularPackage, a as isJsFile, n as needsLinking } from './types-BTaYbdhr.js';
|
|
5
5
|
export { CompilerOptions, default as angularCompilerVitePlugin } from './compiler/vite.js';
|
|
6
|
-
export { CompilerBinding } from './compiler/index.js';
|
|
7
6
|
import 'esbuild';
|
|
8
7
|
import 'vite';
|
package/index.js
CHANGED
|
@@ -171,12 +171,14 @@ function angularLinkerRolldownPlugin(options) {
|
|
|
171
171
|
if (!compiler) {
|
|
172
172
|
compiler = getCompiler2(options);
|
|
173
173
|
}
|
|
174
|
-
const
|
|
174
|
+
const isAngularPackage2 = id.includes("@angular") || id.includes("/@angular/");
|
|
175
|
+
const isNodeModules = id.includes("node_modules");
|
|
175
176
|
const cleanId = cleanModuleId(id);
|
|
176
|
-
|
|
177
|
+
const isJsFile2 = cleanId.endsWith(".mjs") || cleanId.endsWith(".js");
|
|
178
|
+
if (!isAngularPackage2 || !isNodeModules || !isJsFile2) {
|
|
177
179
|
return null;
|
|
178
180
|
}
|
|
179
|
-
if (!
|
|
181
|
+
if (!code.includes("\u0275\u0275ngDeclare")) {
|
|
180
182
|
return null;
|
|
181
183
|
}
|
|
182
184
|
if (debug) {
|
|
@@ -185,7 +187,7 @@ function angularLinkerRolldownPlugin(options) {
|
|
|
185
187
|
try {
|
|
186
188
|
const result = compiler.linkFile(cleanId, code);
|
|
187
189
|
if (result.startsWith("/* Linker Error")) {
|
|
188
|
-
console.error(`[
|
|
190
|
+
console.error(`[Rolldown Linker Error] ${id}:
|
|
189
191
|
${result}`);
|
|
190
192
|
return null;
|
|
191
193
|
}
|
|
@@ -194,7 +196,7 @@ ${result}`);
|
|
|
194
196
|
}
|
|
195
197
|
return { code: result, map: null };
|
|
196
198
|
} catch (e) {
|
|
197
|
-
console.error(`[
|
|
199
|
+
console.error(`[Rolldown Linker Failed] ${id}:`, e);
|
|
198
200
|
return null;
|
|
199
201
|
}
|
|
200
202
|
}
|
|
@@ -275,19 +277,16 @@ function angularLinkerVitePlugin(options) {
|
|
|
275
277
|
if (!compiler) {
|
|
276
278
|
compiler = getCompiler3(options);
|
|
277
279
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
if (!isJsFile(id)) {
|
|
280
|
+
const isAngularPackage2 = id.includes("@angular") || id.includes("/@angular/");
|
|
281
|
+
const isNodeModules = id.includes("node_modules");
|
|
282
|
+
const cleanId = cleanModuleId(id);
|
|
283
|
+
const isJsFile2 = cleanId.endsWith(".mjs") || cleanId.endsWith(".js");
|
|
284
|
+
if (!isAngularPackage2 || !isNodeModules || !isJsFile2) {
|
|
285
285
|
return null;
|
|
286
286
|
}
|
|
287
|
-
if (!
|
|
287
|
+
if (!code.includes("\u0275\u0275ngDeclare")) {
|
|
288
288
|
return null;
|
|
289
289
|
}
|
|
290
|
-
const cleanId = cleanModuleId(id);
|
|
291
290
|
if (debug) {
|
|
292
291
|
console.log(`[Angular Linker] Linking: ${cleanId}`);
|
|
293
292
|
}
|
|
@@ -324,6 +323,49 @@ import { createRequire as createRequire4 } from "module";
|
|
|
324
323
|
import { dirname as dirname4, join as join4 } from "path";
|
|
325
324
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
326
325
|
var compilerInstance4 = null;
|
|
326
|
+
var RED = "\x1B[31m";
|
|
327
|
+
var YELLOW = "\x1B[33m";
|
|
328
|
+
var CYAN = "\x1B[36m";
|
|
329
|
+
var BOLD = "\x1B[1m";
|
|
330
|
+
var RESET = "\x1B[0m";
|
|
331
|
+
function formatDiagnostic(diag, sourceCode) {
|
|
332
|
+
const level = "WARNING";
|
|
333
|
+
const codeStr = `NG${diag.code}`;
|
|
334
|
+
const file = diag.file || "unknown";
|
|
335
|
+
let line = 1;
|
|
336
|
+
let col = 0;
|
|
337
|
+
let lineStartPos = 0;
|
|
338
|
+
if (diag.start !== void 0 && diag.start !== null) {
|
|
339
|
+
for (let i = 0; i < diag.start && i < sourceCode.length; i++) {
|
|
340
|
+
if (sourceCode[i] === "\n") {
|
|
341
|
+
line++;
|
|
342
|
+
col = 0;
|
|
343
|
+
lineStartPos = i + 1;
|
|
344
|
+
} else {
|
|
345
|
+
col++;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
let output = `
|
|
350
|
+
${BOLD}${YELLOW}\u25B2 [${level}] ${RED}${codeStr}${RESET}${BOLD}: ${diag.message}${RESET} ${YELLOW}[plugin rust-ngc-plugin]${RESET}
|
|
351
|
+
`;
|
|
352
|
+
const lineStr = line.toString();
|
|
353
|
+
const colStr = (col + 1).toString();
|
|
354
|
+
output += `
|
|
355
|
+
${CYAN}${file}:${lineStr}:${colStr}:${RESET}
|
|
356
|
+
`;
|
|
357
|
+
let lineEndPos = sourceCode.indexOf("\n", lineStartPos);
|
|
358
|
+
if (lineEndPos === -1) lineEndPos = sourceCode.length;
|
|
359
|
+
const lineContent = sourceCode.substring(lineStartPos, lineEndPos);
|
|
360
|
+
output += ` ${BOLD}${lineStr} \u2502 ${RESET}${lineContent}
|
|
361
|
+
`;
|
|
362
|
+
const gutterWidth = lineStr.length + 3;
|
|
363
|
+
const gutterEmpty = " ".repeat(gutterWidth);
|
|
364
|
+
const length = diag.length || 1;
|
|
365
|
+
const underline = "~".repeat(length);
|
|
366
|
+
output += ` ${gutterEmpty}${" ".repeat(col)}${RED}${underline}${RESET}`;
|
|
367
|
+
return output;
|
|
368
|
+
}
|
|
327
369
|
function getCompiler4(options) {
|
|
328
370
|
if (compilerInstance4) {
|
|
329
371
|
return compilerInstance4;
|
|
@@ -378,9 +420,26 @@ function angularCompilerVitePlugin(options) {
|
|
|
378
420
|
compiler = getCompiler4(options);
|
|
379
421
|
}
|
|
380
422
|
if (id.includes("node_modules")) {
|
|
423
|
+
if (id.includes("@angular") && code.includes("\u0275\u0275ngDeclare")) {
|
|
424
|
+
const cleanId2 = id.split("?")[0];
|
|
425
|
+
if (cleanId2.endsWith(".mjs") || cleanId2.endsWith(".js")) {
|
|
426
|
+
try {
|
|
427
|
+
const result = compiler.linkFile(id, code);
|
|
428
|
+
if (result.startsWith("/* Linker Error")) {
|
|
429
|
+
if (debug) console.error(`[Linker Error] ${id}: ${result}`);
|
|
430
|
+
return null;
|
|
431
|
+
}
|
|
432
|
+
return { code: result, map: null };
|
|
433
|
+
} catch (e) {
|
|
434
|
+
if (debug) console.error(`Linker failed for ${id}:`, e);
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
381
439
|
return null;
|
|
382
440
|
}
|
|
383
|
-
|
|
441
|
+
const cleanId = id.split("?")[0];
|
|
442
|
+
if (!cleanId.endsWith(".ts") || cleanId.endsWith(".d.ts")) {
|
|
384
443
|
return null;
|
|
385
444
|
}
|
|
386
445
|
if (debug) {
|
|
@@ -388,15 +447,21 @@ function angularCompilerVitePlugin(options) {
|
|
|
388
447
|
}
|
|
389
448
|
try {
|
|
390
449
|
const result = compiler.compile(id, code);
|
|
391
|
-
|
|
450
|
+
const { code: compiledCode, diagnostics } = result;
|
|
451
|
+
if (compiledCode.startsWith("/* Error")) {
|
|
392
452
|
console.error(`[Angular Compiler Error] ${id}:
|
|
393
|
-
${
|
|
453
|
+
${compiledCode}`);
|
|
394
454
|
throw new Error(`Rust Compilation Failed for ${id}`);
|
|
395
455
|
}
|
|
456
|
+
if (diagnostics && diagnostics.length > 0) {
|
|
457
|
+
diagnostics.forEach((diag) => {
|
|
458
|
+
console.warn(formatDiagnostic(diag, code));
|
|
459
|
+
});
|
|
460
|
+
}
|
|
396
461
|
if (debug) {
|
|
397
462
|
console.log(`[Angular Compiler] Successfully compiled: ${id}`);
|
|
398
463
|
}
|
|
399
|
-
return { code:
|
|
464
|
+
return { code: compiledCode, map: null };
|
|
400
465
|
} catch (e) {
|
|
401
466
|
console.error(`[Angular Compiler Failed] ${id}:`, e);
|
|
402
467
|
throw e;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/linker/esbuild.ts","../src/linker/types.ts","../src/linker/rolldown.ts","../src/linker/vite.ts","../src/compiler/vite.ts"],"sourcesContent":["/**\n * Angular Linker Plugin for esbuild\n *\n * Use this plugin with Vite's optimizeDeps.esbuildOptions or standalone esbuild.\n *\n * @example\n * ```js\n * import { angularLinkerEsbuildPlugin } from 'vite-plugin-angular-rust/esbuild';\n *\n * // With esbuild\n * import esbuild from 'esbuild';\n *\n * esbuild.build({\n * plugins: [angularLinkerEsbuildPlugin()],\n * // ...\n * });\n *\n * // With Vite\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * optimizeDeps: {\n * esbuildOptions: {\n * plugins: [angularLinkerEsbuildPlugin()],\n * },\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"esbuild\";\nimport { promises as fs } from \"fs\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport { needsLinking } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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 an esbuild plugin for Angular linker\n */\nexport function angularLinkerEsbuildPlugin(options?: LinkerOptions): Plugin {\n return {\n name: \"angular-linker-esbuild\",\n setup(build) {\n const compiler = getCompiler(options);\n const debug = options?.debug ?? false;\n\n // Handle all .mjs and .js files in @angular packages\n build.onLoad({ filter: /@angular\\/.*\\.(mjs|js)$/ }, async (args) => {\n if (debug) {\n console.log(`[Angular Linker] Processing: ${args.path}`);\n }\n\n const code = await fs.readFile(args.path, \"utf8\");\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return { contents: code, loader: \"js\" };\n }\n\n try {\n const result = compiler.linkFile(args.path, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n if (debug) {\n console.error(`[Angular Linker Error] ${args.path}:\\n${result}`);\n }\n return { contents: code, loader: \"js\" };\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${args.path}`);\n }\n\n return { contents: result, loader: \"js\" };\n } catch (e) {\n if (debug) {\n console.error(`[Angular Linker Failed] ${args.path}:`, e);\n }\n return { contents: code, loader: \"js\" };\n }\n });\n },\n };\n}\n\nexport default angularLinkerEsbuildPlugin;\n","/**\n * Angular Linker Plugin Types\n */\n\nexport interface LinkerOptions {\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom path to the Angular Rust binding package\n * If not specified, will try to resolve @anthropic/angular-rust-binding\n */\n bindingPath?: string;\n}\n\nexport interface LinkerResult {\n code: string;\n map: null | undefined;\n}\n\nexport interface CompilerBinding {\n linkFile(filePath: string, code: string): string;\n compile?(filePath: string, code: string): string;\n}\n\n/**\n * Check if file contains Angular partial declarations that need linking\n */\nexport function needsLinking(code: string): boolean {\n return code.includes(\"ɵɵngDeclare\");\n}\n\n/**\n * Check if file is an Angular package file\n */\nexport function isAngularPackage(id: string): boolean {\n return id.includes(\"@angular\") || id.includes(\"/@angular/\");\n}\n\n/**\n * Check if file is a JavaScript/MJS file\n */\nexport function isJsFile(id: string): boolean {\n const cleanId = id.split(\"?\")[0];\n return cleanId.endsWith(\".mjs\") || cleanId.endsWith(\".js\");\n}\n\n/**\n * Clean module ID by removing query strings\n */\nexport function cleanModuleId(id: string): string {\n return id.split(\"?\")[0];\n}\n\n/**\n * Default Angular packages to exclude from pre-bundling\n */\nexport const ANGULAR_PACKAGES = [\n \"@angular/core\",\n \"@angular/common\",\n \"@angular/platform-browser\",\n \"@angular/platform-browser-dynamic\",\n \"@angular/router\",\n \"@angular/forms\",\n \"@angular/animations\",\n \"@angular/cdk\",\n \"@angular/material\",\n];\n\n/**\n * Packages that don't need linking and should be included in pre-bundling\n */\nexport const NON_ANGULAR_PACKAGES = [\"zone.js\", \"rxjs\", \"rxjs/operators\"];\n","/**\n * Angular Linker Plugin for Rolldown\n *\n * Use this plugin with rolldown-vite or standalone Rolldown.\n *\n * @example\n * ```js\n * import { angularLinkerRolldownPlugin } from 'vite-plugin-angular-rust/rolldown';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerRolldownPlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * ],\n * },\n * });\n * ```\n */\n\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions, LinkerResult } from \"./types\";\nimport {\n needsLinking,\n isAngularPackage,\n isJsFile,\n cleanModuleId,\n} from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface RolldownPlugin {\n name: string;\n transform(\n code: string,\n id: string\n ): Promise<LinkerResult | null> | LinkerResult | null;\n}\n\n/**\n * Creates a Rolldown-compatible plugin for Angular linker\n */\nexport function angularLinkerRolldownPlugin(\n options?: LinkerOptions\n): RolldownPlugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-rolldown\",\n async transform(code: string, id: string): Promise<LinkerResult | null> {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Only process @angular packages with .mjs or .js extensions\n const isInNodeModules = id.includes(\"node_modules\");\n const cleanId = cleanModuleId(id);\n\n if (!isAngularPackage(id) || !isInNodeModules || !isJsFile(id)) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Angular Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\nexport default angularLinkerRolldownPlugin;\n","/**\n * Angular Linker Plugin for Vite\n *\n * This plugin handles Angular linking for both Vite's dev server (with rolldown/esbuild)\n * and production builds.\n *\n * @example\n * ```js\n * import { angularLinkerVitePlugin } from 'vite-plugin-angular-rust/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerVitePlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * '@angular/forms',\n * ],\n * include: ['zone.js', 'rxjs', 'rxjs/operators'],\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"vite\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport {\n needsLinking,\n isAngularPackage,\n isJsFile,\n cleanModuleId,\n ANGULAR_PACKAGES,\n NON_ANGULAR_PACKAGES,\n} from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface ViteLinkerPluginOptions extends LinkerOptions {\n /**\n * Additional packages to exclude from pre-bundling\n */\n excludePackages?: string[];\n\n /**\n * Additional packages to include in pre-bundling (non-Angular packages)\n */\n includePackages?: string[];\n}\n\n/**\n * Creates a Vite plugin for Angular linker\n * Works with both rolldown-vite and standard Vite (esbuild)\n */\nexport function angularLinkerVitePlugin(\n options?: ViteLinkerPluginOptions\n): Plugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-vite\",\n enforce: \"pre\",\n\n config(config) {\n // Merge optimizeDeps configuration\n const excludePackages = [\n ...ANGULAR_PACKAGES,\n ...(options?.excludePackages ?? []),\n ];\n const includePackages = [\n ...NON_ANGULAR_PACKAGES,\n ...(options?.includePackages ?? []),\n ];\n\n return {\n optimizeDeps: {\n exclude: excludePackages,\n include: includePackages,\n },\n };\n },\n\n transform(code: string, id: string) {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Only process node_modules\n if (!id.includes(\"node_modules\")) {\n return null;\n }\n\n // Only process Angular packages\n if (!isAngularPackage(id)) {\n return null;\n }\n\n // Only process JS files\n if (!isJsFile(id)) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return null;\n }\n\n const cleanId = cleanModuleId(id);\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Angular Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\n/**\n * Get recommended Vite config for Angular with Rust linker\n */\nexport function getAngularViteConfig() {\n return {\n plugins: [angularLinkerVitePlugin()],\n optimizeDeps: {\n exclude: ANGULAR_PACKAGES,\n include: NON_ANGULAR_PACKAGES,\n },\n };\n}\n\nexport { ANGULAR_PACKAGES, NON_ANGULAR_PACKAGES };\nexport default angularLinkerVitePlugin;\n","/**\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":";AA+BA,SAAS,YAAY,UAAU;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAq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ACnC,SAAS,GAAG;AACV,gBAAQ,MAAM,6BAA6B,EAAE,KAAK,CAAC;AACnD,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,gBAAgB,EAAE,MAAM,OAAO,GAAe;AAE5C,UAAI,KAAK,SAAS,OAAO,GAAG;AAC1B,cAAM,SAAS,KAAK,QAAQ,WAAW,KAAK;AAE5C,YAAI,OAAO;AACT,kBAAQ,IAAI,uBAAuB,IAAI,EAAE;AACzC,kBAAQ,IAAI,0BAA0B,MAAM,EAAE;AAAA,QAChD;AAEA,cAAM,MAAM,OAAO,YAAY,cAAc,MAAM;AACnD,YAAI,KAAK;AACP,iBAAO,YAAY,iBAAiB,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;","names":["require","createRequire","dirname","join","fileURLToPath","compilerInstance","getCompiler","require","createRequire","fileURLToPath","dirname","join","createRequire","dirname","join","fileURLToPath","compilerInstance","getCompiler","require","createRequire","fileURLToPath","dirname","join","createRequire","dirname","join","fileURLToPath","compilerInstance","getCompiler","require"]}
|
|
1
|
+
{"version":3,"sources":["../src/linker/esbuild.ts","../src/linker/types.ts","../src/linker/rolldown.ts","../src/linker/vite.ts","../src/compiler/vite.ts"],"sourcesContent":["/**\n * Angular Linker Plugin for esbuild\n *\n * Use this plugin with Vite's optimizeDeps.esbuildOptions or standalone esbuild.\n *\n * @example\n * ```js\n * import { angularLinkerEsbuildPlugin } from 'vite-plugin-angular-rust/esbuild';\n *\n * // With esbuild\n * import esbuild from 'esbuild';\n *\n * esbuild.build({\n * plugins: [angularLinkerEsbuildPlugin()],\n * // ...\n * });\n *\n * // With Vite\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * optimizeDeps: {\n * esbuildOptions: {\n * plugins: [angularLinkerEsbuildPlugin()],\n * },\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"esbuild\";\nimport { promises as fs } from \"fs\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport { needsLinking } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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 an esbuild plugin for Angular linker\n */\nexport function angularLinkerEsbuildPlugin(options?: LinkerOptions): Plugin {\n return {\n name: \"angular-linker-esbuild\",\n setup(build) {\n const compiler = getCompiler(options);\n const debug = options?.debug ?? false;\n\n // Handle all .mjs and .js files in @angular packages\n build.onLoad({ filter: /@angular\\/.*\\.(mjs|js)$/ }, async (args) => {\n if (debug) {\n console.log(`[Angular Linker] Processing: ${args.path}`);\n }\n\n const code = await fs.readFile(args.path, \"utf8\");\n\n // Check if file contains partial declarations\n if (!needsLinking(code)) {\n return { contents: code, loader: \"js\" };\n }\n\n try {\n const result = compiler.linkFile(args.path, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n if (debug) {\n console.error(`[Angular Linker Error] ${args.path}:\\n${result}`);\n }\n return { contents: code, loader: \"js\" };\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${args.path}`);\n }\n\n return { contents: result, loader: \"js\" };\n } catch (e) {\n if (debug) {\n console.error(`[Angular Linker Failed] ${args.path}:`, e);\n }\n return { contents: code, loader: \"js\" };\n }\n });\n },\n };\n}\n\nexport default angularLinkerEsbuildPlugin;\n","/**\n * Angular Linker Plugin Types\n */\n\nexport interface LinkerOptions {\n /**\n * Enable debug logging\n * @default false\n */\n debug?: boolean;\n\n /**\n * Custom path to the Angular Rust binding package\n * If not specified, will try to resolve @anthropic/angular-rust-binding\n */\n bindingPath?: string;\n}\n\nexport interface LinkerResult {\n code: string;\n map: null | undefined;\n}\n\nexport interface CompilerBinding {\n linkFile(filePath: string, code: string): string;\n compile?(filePath: string, code: string): string;\n}\n\n/**\n * Check if file contains Angular partial declarations that need linking\n */\nexport function needsLinking(code: string): boolean {\n return code.includes(\"ɵɵngDeclare\");\n}\n\n/**\n * Check if file is an Angular package file\n */\nexport function isAngularPackage(id: string): boolean {\n return id.includes(\"@angular\") || id.includes(\"/@angular/\");\n}\n\n/**\n * Check if file is a JavaScript/MJS file\n */\nexport function isJsFile(id: string): boolean {\n const cleanId = id.split(\"?\")[0];\n return cleanId.endsWith(\".mjs\") || cleanId.endsWith(\".js\");\n}\n\n/**\n * Clean module ID by removing query strings\n */\nexport function cleanModuleId(id: string): string {\n return id.split(\"?\")[0];\n}\n\n/**\n * Default Angular packages to exclude from pre-bundling\n */\nexport const ANGULAR_PACKAGES = [\n \"@angular/core\",\n \"@angular/common\",\n \"@angular/platform-browser\",\n \"@angular/platform-browser-dynamic\",\n \"@angular/router\",\n \"@angular/forms\",\n \"@angular/animations\",\n \"@angular/cdk\",\n \"@angular/material\",\n];\n\n/**\n * Packages that don't need linking and should be included in pre-bundling\n */\nexport const NON_ANGULAR_PACKAGES = [\"zone.js\", \"rxjs\", \"rxjs/operators\"];\n","/**\n * Angular Linker Plugin for Rolldown\n *\n * Use this plugin with rolldown-vite or standalone Rolldown.\n *\n * @example\n * ```js\n * import { angularLinkerRolldownPlugin } from 'angular-rust-plugins/linker/rolldown';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerRolldownPlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * ],\n * },\n * });\n * ```\n */\n\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions, LinkerResult } from \"./types\";\nimport { cleanModuleId } from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface RolldownPlugin {\n name: string;\n transform(\n code: string,\n id: string\n ): Promise<LinkerResult | null> | LinkerResult | null;\n}\n\n/**\n * Creates a Rolldown-compatible plugin for Angular linker\n */\nexport function angularLinkerRolldownPlugin(\n options?: LinkerOptions\n): RolldownPlugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-rolldown\",\n async transform(code: string, id: string): Promise<LinkerResult | null> {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Logic from vite.config.mjs\n const isAngularPackage = id.includes('@angular') || id.includes('/@angular/');\n const isNodeModules = id.includes('node_modules');\n const cleanId = cleanModuleId(id);\n const isJsFile = cleanId.endsWith('.mjs') || cleanId.endsWith('.js');\n\n if (!isAngularPackage || !isNodeModules || !isJsFile) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!code.includes('ɵɵngDeclare')) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Rolldown Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Rolldown Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\nexport default angularLinkerRolldownPlugin;\n","/**\n * Angular Linker Plugin for Vite\n *\n * This plugin handles Angular linking for both Vite's dev server (with rolldown/esbuild)\n * and production builds.\n *\n * @example\n * ```js\n * import { angularLinkerVitePlugin } from 'angular-rust-plugins/linker/vite';\n * import { defineConfig } from 'vite';\n *\n * export default defineConfig({\n * plugins: [angularLinkerVitePlugin()],\n * optimizeDeps: {\n * exclude: [\n * '@angular/core',\n * '@angular/common',\n * '@angular/platform-browser',\n * '@angular/router',\n * '@angular/forms',\n * ],\n * include: ['zone.js', 'rxjs', 'rxjs/operators'],\n * },\n * });\n * ```\n */\n\nimport type { Plugin } from \"vite\";\nimport { createRequire } from \"module\";\nimport { dirname, join } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport type { CompilerBinding, LinkerOptions } from \"./types\";\nimport {\n cleanModuleId,\n ANGULAR_PACKAGES,\n NON_ANGULAR_PACKAGES,\n} from \"./types\";\n\nlet compilerInstance: CompilerBinding | null = null;\n\nfunction getCompiler(options?: LinkerOptions): 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 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/linker/../binding\n join(currentDir, \"binding\"), // same directory\n join(currentDir, \"..\", \"..\", \"binding\"), // deeper nesting\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\nexport interface ViteLinkerPluginOptions extends LinkerOptions {\n /**\n * Additional packages to exclude from pre-bundling\n */\n excludePackages?: string[];\n\n /**\n * Additional packages to include in pre-bundling (non-Angular packages)\n */\n includePackages?: string[];\n}\n\n/**\n * Creates a Vite plugin for Angular linker\n * Works with both rolldown-vite and standard Vite (esbuild)\n */\nexport function angularLinkerVitePlugin(\n options?: ViteLinkerPluginOptions\n): Plugin {\n const debug = options?.debug ?? false;\n let compiler: CompilerBinding;\n\n return {\n name: \"angular-linker-vite\",\n enforce: \"pre\",\n\n config(config) {\n // Merge optimizeDeps configuration\n const excludePackages = [\n ...ANGULAR_PACKAGES,\n ...(options?.excludePackages ?? []),\n ];\n const includePackages = [\n ...NON_ANGULAR_PACKAGES,\n ...(options?.includePackages ?? []),\n ];\n\n return {\n optimizeDeps: {\n exclude: excludePackages,\n include: includePackages,\n },\n };\n },\n\n transform(code: string, id: string) {\n // Lazy initialize compiler\n if (!compiler) {\n compiler = getCompiler(options);\n }\n\n // Logic from vite.config.mjs\n const isAngularPackage = id.includes('@angular') || id.includes('/@angular/');\n const isNodeModules = id.includes('node_modules');\n const cleanId = cleanModuleId(id);\n const isJsFile = cleanId.endsWith('.mjs') || cleanId.endsWith('.js');\n\n if (!isAngularPackage || !isNodeModules || !isJsFile) {\n return null;\n }\n\n // Check if file contains partial declarations\n if (!code.includes('ɵɵngDeclare')) {\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Linking: ${cleanId}`);\n }\n\n try {\n const result = compiler.linkFile(cleanId, code);\n\n if (result.startsWith(\"/* Linker Error\")) {\n console.error(`[Angular Linker Error] ${id}:\\n${result}`);\n return null;\n }\n\n if (debug) {\n console.log(`[Angular Linker] Successfully linked: ${cleanId}`);\n }\n\n return { code: result, map: null };\n } catch (e) {\n console.error(`[Angular Linker Failed] ${id}:`, e);\n return null;\n }\n },\n };\n}\n\n/**\n * Get recommended Vite config for Angular with Rust linker\n */\nexport function getAngularViteConfig() {\n return {\n plugins: [angularLinkerVitePlugin()],\n optimizeDeps: {\n exclude: ANGULAR_PACKAGES,\n include: NON_ANGULAR_PACKAGES,\n },\n };\n}\n\nexport { ANGULAR_PACKAGES, NON_ANGULAR_PACKAGES };\nexport default angularLinkerVitePlugin;\n","/**\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 { Compiler } from \"../binding\";\n\nlet compilerInstance: Compiler | 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\n// ============ Diagnostic Formatting ============\nconst RED = '\\x1b[31m';\nconst YELLOW = '\\x1b[33m';\nconst CYAN = '\\x1b[36m';\nconst BOLD = '\\x1b[1m';\nconst RESET = '\\x1b[0m';\n\nfunction formatDiagnostic(diag: any, sourceCode: string): string {\n const level = 'WARNING';\n const codeStr = `NG${diag.code}`;\n const file = diag.file || 'unknown';\n\n let line = 1;\n let col = 0;\n let lineStartPos = 0;\n\n if (diag.start !== undefined && diag.start !== null) {\n for (let i = 0; i < diag.start && i < sourceCode.length; i++) {\n if (sourceCode[i] === '\\n') {\n line++;\n col = 0;\n lineStartPos = i + 1;\n } else {\n col++;\n }\n }\n }\n\n let output = `\\n${BOLD}${YELLOW}▲ [${level}] ${RED}${codeStr}${RESET}${BOLD}: ${diag.message}${RESET} ${YELLOW}[plugin rust-ngc-plugin]${RESET}\\n`;\n\n const lineStr = line.toString();\n const colStr = (col + 1).toString();\n output += `\\n ${CYAN}${file}:${lineStr}:${colStr}:${RESET}\\n`;\n\n let lineEndPos = sourceCode.indexOf('\\n', lineStartPos);\n if (lineEndPos === -1) lineEndPos = sourceCode.length;\n const lineContent = sourceCode.substring(lineStartPos, lineEndPos);\n\n output += ` ${BOLD}${lineStr} │ ${RESET}${lineContent}\\n`;\n\n const gutterWidth = lineStr.length + 3;\n const gutterEmpty = ' '.repeat(gutterWidth);\n const length = diag.length || 1;\n const underline = '~'.repeat(length);\n\n output += ` ${gutterEmpty}${' '.repeat(col)}${RED}${underline}${RESET}`;\n\n return output;\n}\n\nfunction getCompiler(options?: CompilerOptions): Compiler {\n if (compilerInstance) {\n return compilerInstance;\n }\n\n try {\n let binding: { Compiler: new () => Compiler };\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 () => Compiler } | 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: Compiler;\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 but check for Angular packages that need linking\n if (id.includes('node_modules')) {\n if (id.includes('@angular') && code.includes('ɵɵngDeclare')) {\n const cleanId = id.split('?')[0];\n if (cleanId.endsWith('.mjs') || cleanId.endsWith('.js')) {\n try {\n const result = compiler.linkFile(id, code);\n if (result.startsWith('/* Linker Error')) {\n if (debug) console.error(`[Linker Error] ${id}: ${result}`);\n return null;\n }\n return { code: result, map: null };\n } catch (e) {\n if (debug) console.error(`Linker failed for ${id}:`, e);\n return null;\n }\n }\n }\n return null;\n }\n\n // Only process TypeScript files, skip declaration files\n const cleanId = id.split('?')[0];\n if (!cleanId.endsWith('.ts') || cleanId.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 // Handle structured result\n const { code: compiledCode, diagnostics } = result;\n\n if (compiledCode.startsWith('/* Error')) {\n console.error(`[Angular Compiler Error] ${id}:\\n${compiledCode}`);\n throw new Error(`Rust Compilation Failed for ${id}`);\n }\n\n if (diagnostics && diagnostics.length > 0) {\n diagnostics.forEach((diag: any) => {\n console.warn(formatDiagnostic(diag, code));\n });\n }\n\n if (debug) {\n console.log(`[Angular Compiler] Successfully compiled: ${id}`);\n }\n\n return { code: compiledCode, 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":";AA+BA,SAAS,YAAY,UAAU;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;;;ACHvB,SAAS,aAAa,MAAuB;AAClD,SAAO,KAAK,SAAS,uBAAa;AACpC;AAKO,SAAS,iBAAiB,IAAqB;AACpD,SAAO,GAAG,SAAS,UAAU,KAAK,GAAG,SAAS,YAAY;AAC5D;AAKO,SAAS,SAAS,IAAqB;AAC5C,QAAM,UAAU,GAAG,MAAM,GAAG,EAAE,CAAC;AAC/B,SAAO,QAAQ,SAAS,MAAM,KAAK,QAAQ,SAAS,KAAK;AAC3D;AAKO,SAAS,cAAc,IAAoB;AAChD,SAAO,GAAG,MAAM,GAAG,EAAE,CAAC;AACxB;AAKO,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,uBAAuB,CAAC,WAAW,QAAQ,gBAAgB;;;ADrCxE,IAAI,mBAA2C;AAE/C,SAAS,YAAY,SAA0C;AAC7D,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;AAEL,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,MAA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AE,MAAM,cAAc,KAAK,KAAK;AAAA,MACzC,SAAS,GAAG;AACV,gBAAQ,MAAM,6BAA6B,EAAE,KAAK,CAAC;AACnD,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IAEA,gBAAgB,EAAE,MAAM,OAAO,GAAe;AAE5C,UAAI,KAAK,SAAS,OAAO,GAAG;AAC1B,cAAM,SAAS,KAAK,QAAQ,WAAW,KAAK;AAE5C,YAAI,OAAO;AACT,kBAAQ,IAAI,uBAAuB,IAAI,EAAE;AACzC,kBAAQ,IAAI,0BAA0B,MAAM,EAAE;AAAA,QAChD;AAEA,cAAM,MAAM,OAAO,YAAY,cAAc,MAAM;AACnD,YAAI,KAAK;AACP,iBAAO,YAAY,iBAAiB,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;","names":["require","createRequire","dirname","join","fileURLToPath","compilerInstance","getCompiler","require","createRequire","fileURLToPath","dirname","join","isAngularPackage","isJsFile","createRequire","dirname","join","fileURLToPath","compilerInstance","getCompiler","require","createRequire","fileURLToPath","dirname","join","isAngularPackage","isJsFile","createRequire","dirname","join","fileURLToPath","compilerInstance","getCompiler","require","cleanId"]}
|
package/linker/index.cjs
CHANGED
|
@@ -208,12 +208,14 @@ function angularLinkerRolldownPlugin(options) {
|
|
|
208
208
|
if (!compiler) {
|
|
209
209
|
compiler = getCompiler2(options);
|
|
210
210
|
}
|
|
211
|
-
const
|
|
211
|
+
const isAngularPackage2 = id.includes("@angular") || id.includes("/@angular/");
|
|
212
|
+
const isNodeModules = id.includes("node_modules");
|
|
212
213
|
const cleanId = cleanModuleId(id);
|
|
213
|
-
|
|
214
|
+
const isJsFile2 = cleanId.endsWith(".mjs") || cleanId.endsWith(".js");
|
|
215
|
+
if (!isAngularPackage2 || !isNodeModules || !isJsFile2) {
|
|
214
216
|
return null;
|
|
215
217
|
}
|
|
216
|
-
if (!
|
|
218
|
+
if (!code.includes("\u0275\u0275ngDeclare")) {
|
|
217
219
|
return null;
|
|
218
220
|
}
|
|
219
221
|
if (debug) {
|
|
@@ -222,7 +224,7 @@ function angularLinkerRolldownPlugin(options) {
|
|
|
222
224
|
try {
|
|
223
225
|
const result = compiler.linkFile(cleanId, code);
|
|
224
226
|
if (result.startsWith("/* Linker Error")) {
|
|
225
|
-
console.error(`[
|
|
227
|
+
console.error(`[Rolldown Linker Error] ${id}:
|
|
226
228
|
${result}`);
|
|
227
229
|
return null;
|
|
228
230
|
}
|
|
@@ -231,7 +233,7 @@ ${result}`);
|
|
|
231
233
|
}
|
|
232
234
|
return { code: result, map: null };
|
|
233
235
|
} catch (e) {
|
|
234
|
-
console.error(`[
|
|
236
|
+
console.error(`[Rolldown Linker Failed] ${id}:`, e);
|
|
235
237
|
return null;
|
|
236
238
|
}
|
|
237
239
|
}
|
|
@@ -313,19 +315,16 @@ function angularLinkerVitePlugin(options) {
|
|
|
313
315
|
if (!compiler) {
|
|
314
316
|
compiler = getCompiler3(options);
|
|
315
317
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
if (!isJsFile(id)) {
|
|
318
|
+
const isAngularPackage2 = id.includes("@angular") || id.includes("/@angular/");
|
|
319
|
+
const isNodeModules = id.includes("node_modules");
|
|
320
|
+
const cleanId = cleanModuleId(id);
|
|
321
|
+
const isJsFile2 = cleanId.endsWith(".mjs") || cleanId.endsWith(".js");
|
|
322
|
+
if (!isAngularPackage2 || !isNodeModules || !isJsFile2) {
|
|
323
323
|
return null;
|
|
324
324
|
}
|
|
325
|
-
if (!
|
|
325
|
+
if (!code.includes("\u0275\u0275ngDeclare")) {
|
|
326
326
|
return null;
|
|
327
327
|
}
|
|
328
|
-
const cleanId = cleanModuleId(id);
|
|
329
328
|
if (debug) {
|
|
330
329
|
console.log(`[Angular Linker] Linking: ${cleanId}`);
|
|
331
330
|
}
|