@analogjs/vite-plugin-angular 3.0.0-beta.47 → 3.0.0-beta.49

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/vite-plugin-angular",
3
- "version": "3.0.0-beta.47",
3
+ "version": "3.0.0-beta.49",
4
4
  "description": "Vite Plugin for Angular",
5
5
  "type": "module",
6
6
  "keywords": [
package/src/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { angular } from "./lib/angular-vite-plugin.js";
4
4
  export type { PluginOptions } from "./lib/angular-vite-plugin.js";
5
5
  export type { AnalogIntegrationPlugin, AnalogPluginContext, AnalogPluginHooks, ComponentRegistryEntries, StylesheetRegistryConfigurator, StylesheetRegistryContext, TransformFilter } from "./lib/analog-plugin-interop.js";
6
6
  export { findFastCompileApi, type FastCompileApi, type FastCompileOptions, type FastCompileResolve, type FastCompileSourceFormat, type SourceMapInput } from "./lib/fast-compile-api.js";
7
+ export { findNgpCompileApi, type NgpCompileApi, type NgpLowerContext, type NgpLoweredModule, type NgpSourceFormat } from "./lib/ngp-compile-api.js";
7
8
  export type { RegistryEntry as ComponentRegistryEntry, RegistryInput as ComponentRegistryInput } from "./lib/compiler/registry.js";
8
9
  export type { StylePreprocessor, StylesheetDependency, StylesheetDiagnostic, StylesheetRegistryReader, StylesheetTransformContext, StylesheetTransformResult } from "./lib/style-preprocessor.js";
9
10
  export default angular;
package/src/index.js CHANGED
@@ -2,9 +2,10 @@ import { angularCompilationPlugin } from "./lib/compilation-api/compilation-api-
2
2
  import "./lib/compilation-api/index.js";
3
3
  import { angular } from "./lib/angular-vite-plugin.js";
4
4
  import { findFastCompileApi } from "./lib/fast-compile-api.js";
5
+ import { findNgpCompileApi } from "./lib/ngp-compile-api.js";
5
6
  //#region packages/vite-plugin-angular/src/index.ts
6
7
  var src_default = angular;
7
8
  //#endregion
8
- export { angular, angularCompilationPlugin, src_default as default, findFastCompileApi };
9
+ export { angular, angularCompilationPlugin, src_default as default, findFastCompileApi, findNgpCompileApi };
9
10
 
10
11
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export {\n angularCompilationPlugin,\n type AngularCompilationPluginOptions,\n} from './lib/compilation-api/index.js';\nimport { angular } from './lib/angular-vite-plugin.js';\nexport { angular } from './lib/angular-vite-plugin.js';\nexport type { PluginOptions } from './lib/angular-vite-plugin.js';\nexport type {\n AnalogIntegrationPlugin,\n AnalogPluginContext,\n AnalogPluginHooks,\n ComponentRegistryEntries,\n StylesheetRegistryConfigurator,\n StylesheetRegistryContext,\n TransformFilter,\n} from './lib/analog-plugin-interop.js';\nexport {\n findFastCompileApi,\n type FastCompileApi,\n type FastCompileOptions,\n type FastCompileResolve,\n type FastCompileSourceFormat,\n type SourceMapInput,\n} from './lib/fast-compile-api.js';\nexport type {\n RegistryEntry as ComponentRegistryEntry,\n RegistryInput as ComponentRegistryInput,\n} from './lib/compiler/registry.js';\nexport type {\n StylePreprocessor,\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetRegistryReader,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './lib/style-preprocessor.js';\n\nexport default angular;\n"],"mappings":";;;;;AAqCA,IAAA,cAAe"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export {\n angularCompilationPlugin,\n type AngularCompilationPluginOptions,\n} from './lib/compilation-api/index.js';\nimport { angular } from './lib/angular-vite-plugin.js';\nexport { angular } from './lib/angular-vite-plugin.js';\nexport type { PluginOptions } from './lib/angular-vite-plugin.js';\nexport type {\n AnalogIntegrationPlugin,\n AnalogPluginContext,\n AnalogPluginHooks,\n ComponentRegistryEntries,\n StylesheetRegistryConfigurator,\n StylesheetRegistryContext,\n TransformFilter,\n} from './lib/analog-plugin-interop.js';\nexport {\n findFastCompileApi,\n type FastCompileApi,\n type FastCompileOptions,\n type FastCompileResolve,\n type FastCompileSourceFormat,\n type SourceMapInput,\n} from './lib/fast-compile-api.js';\nexport {\n findNgpCompileApi,\n type NgpCompileApi,\n type NgpLowerContext,\n type NgpLoweredModule,\n type NgpSourceFormat,\n} from './lib/ngp-compile-api.js';\nexport type {\n RegistryEntry as ComponentRegistryEntry,\n RegistryInput as ComponentRegistryInput,\n} from './lib/compiler/registry.js';\nexport type {\n StylePreprocessor,\n StylesheetDependency,\n StylesheetDiagnostic,\n StylesheetRegistryReader,\n StylesheetTransformContext,\n StylesheetTransformResult,\n} from './lib/style-preprocessor.js';\n\nexport default angular;\n"],"mappings":";;;;;;AA4CA,IAAA,cAAe"}
@@ -74,14 +74,24 @@ function buildOptimizerPlugin(ctxOrOptions) {
74
74
  };
75
75
  }
76
76
  function extractInlineSourceMap(code, _id) {
77
- const sourceMapMatch = code.match(/\n?\/\/# sourceMappingURL=data:application\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\s*$/);
78
- if (!sourceMapMatch || sourceMapMatch.index === void 0) return {
77
+ const prefix = "//# sourceMappingURL=data:application/json";
78
+ const separator = ";base64,";
79
+ const commentStart = code.lastIndexOf(prefix);
80
+ if (commentStart === -1) return {
79
81
  code,
80
82
  map: null
81
83
  };
84
+ const tail = code.slice(commentStart + 42).trimEnd();
85
+ const base64Start = tail.indexOf(separator);
86
+ const payload = tail.slice(base64Start + 8);
87
+ if (base64Start === -1 || !/^(?:;charset=[^;,]+)?$/.test(tail.slice(0, base64Start)) || payload === "" || /[^A-Za-z0-9+/=]/.test(payload)) return {
88
+ code,
89
+ map: null
90
+ };
91
+ const codeEnd = code[commentStart - 1] === "\n" ? commentStart - 1 : commentStart;
82
92
  return {
83
- code: code.slice(0, sourceMapMatch.index),
84
- map: Buffer.from(sourceMapMatch[1], "base64").toString()
93
+ code: code.slice(0, codeEnd),
94
+ map: Buffer.from(payload, "base64").toString()
85
95
  };
86
96
  }
87
97
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode, isServerEnvironment } from './utils/plugin-config.js';\n\nexport interface BuildOptimizerPluginOptions {\n jit?: boolean;\n}\n\nexport function buildOptimizerPlugin(\n ctxOrOptions?: AngularBuildContext | BuildOptimizerPluginOptions,\n): Plugin {\n const jit = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.jit\n : (ctxOrOptions?.jit ?? false);\n\n const transformers = new Map<\n string,\n InstanceType<typeof JavaScriptTransformer>\n >();\n let isProd = false;\n let isWatch = false;\n let preserveVendorMaps = false;\n\n function getTransformer(envName = 'default') {\n let transformer = transformers.get(envName);\n if (!transformer) {\n transformer = new JavaScriptTransformer(\n {\n sourcemap: preserveVendorMaps,\n thirdPartySourcemaps: preserveVendorMaps,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\n transformers.set(envName, transformer);\n }\n return transformer;\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n // Normally build-only. Astro's Cloudflare integration (`@astrojs/cloudflare`)\n // transforms SSR modules through a serve-style `workerd` runner *during*\n // `astro build`; an `apply: 'build'` plugin is excluded from that pipeline,\n // so the Angular linker never runs on the worker's partially-compiled\n // packages and they fall back to the JIT compiler. Also apply under a\n // production `NODE_ENV` (which `astro build` sets) so the linker runs in\n // that runner too. Regular Analog dev servers run with a development\n // `NODE_ENV`, so their behavior is unchanged.\n apply(_config, env) {\n return (\n env.command === 'build' || process.env['NODE_ENV'] === 'production'\n );\n },\n config(userConfig) {\n isProd = isProdMode(userConfig.mode);\n // Advanced optimizations paired with dev-mode defines would strip\n // dev-only code the debug API needs, so both key off `isProd`.\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n } as UserConfig;\n },\n // The top-level define keys `ngServerMode` off the legacy `build.ssr`\n // flag. Environment API builds run the server through a server\n // environment while `build.ssr` stays unset, so give that environment its\n // own value; otherwise the guard compiles to `false` and browser-only\n // hydration features run during SSR. Runs after other plugins' hooks, so\n // a consumer they set is taken into account.\n configEnvironment: {\n order: 'post',\n handler(name, config) {\n if (isProd && isServerEnvironment(name, config)) {\n return { define: { ngServerMode: 'true' } };\n }\n return undefined;\n },\n },\n configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\n isWatch = config.command === 'serve' || !!config.build?.watch;\n },\n transform: {\n filter: {\n // Allow an optional `?query` after the extension. Some environments\n // (e.g. Cloudflare's `workerd`, used by Astro's Cloudflare integration)\n // reference optimized deps with a `?v=<hash>` suffix, e.g.\n // `.../fesm2022/_platform_location-chunk.mjs?v=a786a9ff`. A `$`-anchored\n // extension match skips those, so the Angular linker never runs and the\n // partially-compiled package falls back to the JIT compiler at runtime.\n id: /\\.[cm]?js(?:\\?|$)/,\n },\n async handler(code, id) {\n // Strip the `?query` so the fesm check and the transformer see a real\n // filename rather than `foo.mjs?v=<hash>`.\n const cleanId = id.split('?')[0];\n const angularPackage = /fesm20/.test(cleanId);\n\n if (!angularPackage) {\n // `{ mappings: '' }` declares zero segments, dropping the module's own\n // map from the chain; `null` keeps it. Removing `sourceMappingURL` is\n // what makes that map unreachable, so it only runs when discarding.\n return {\n code:\n isProd && !preserveVendorMaps\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: preserveVendorMaps ? null : { mappings: '' },\n };\n }\n\n const sideEffects =\n jit && cleanId.includes('@angular/compiler') ? true : false;\n const envName = this.environment?.name ?? 'default';\n const transformer = getTransformer(envName);\n const result: Uint8Array = await transformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n const transformed = Buffer.from(result).toString();\n return preserveVendorMaps\n ? extractInlineSourceMap(transformed, cleanId)\n : { code: transformed, map: { mappings: '' } };\n },\n },\n async closeBundle() {\n if (isWatch) {\n return;\n }\n const envName = this.environment?.name ?? 'default';\n const transformer = transformers.get(envName);\n if (transformer) {\n transformers.delete(envName);\n await transformer.close();\n }\n },\n };\n}\n\nexport function extractInlineSourceMap(\n code: string,\n _id: string,\n): { code: string; map: string | null } {\n const sourceMapMatch = code.match(\n /\\n?\\/\\/# sourceMappingURL=data:application\\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\\s*$/,\n );\n if (!sourceMapMatch || sourceMapMatch.index === undefined) {\n return {\n code,\n map: null,\n };\n }\n return {\n code: code.slice(0, sourceMapMatch.index),\n map: Buffer.from(sourceMapMatch[1]!, 'base64').toString(),\n };\n}\n"],"mappings":";;;;AAYA,SAAgB,qBACd,cACQ;CACR,MAAM,MAAM,sBAAsB,YAAY,IAC1C,aAAa,QAAQ,MACpB,cAAc,OAAO;CAE1B,MAAM,+BAAe,IAAI,IAGvB;CACF,IAAI,SAAS;CACb,IAAI,UAAU;CACd,IAAI,qBAAqB;CAEzB,SAAS,eAAe,UAAU,WAAW;EAC3C,IAAI,cAAc,aAAa,IAAI,OAAO;EAC1C,IAAI,CAAC,aAAa;GAChB,cAAc,IAAI,sBAChB;IACE,WAAW;IACX,sBAAsB;IACtB,uBAAuB;IACvB,KAAK;GACP,GACA,CACF;GACA,aAAa,IAAI,SAAS,WAAW;EACvC;EACA,OAAO;CACT;CAEA,OAAO;EACL,MAAM;EASN,MAAM,SAAS,KAAK;GAClB,OACE,IAAI,YAAY,WAAA,QAAA,IAAA,aAAuC;EAE3D;EACA,OAAO,YAAY;GACjB,SAAS,WAAW,WAAW,IAAI;GAGnC,OAAO,EACL,QAAQ,SACJ;IACE,WAAW;IACX,mBAAmB;IACnB,WAAW;IACX,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;GACvC,IACA,CAA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ACL,MAAM,KAAK,MAAM,GAAG,eAAe,KAAK;EACxC,KAAK,OAAO,KAAK,eAAe,IAAK,QAAQ,CAAC,CAAC,SAAS;CAC1D;AACF"}
1
+ {"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport {\n isAngularBuildContext,\n type AngularBuildContext,\n} from './angular-build-context.js';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode, isServerEnvironment } from './utils/plugin-config.js';\n\nexport interface BuildOptimizerPluginOptions {\n jit?: boolean;\n}\n\nexport function buildOptimizerPlugin(\n ctxOrOptions?: AngularBuildContext | BuildOptimizerPluginOptions,\n): Plugin {\n const jit = isAngularBuildContext(ctxOrOptions)\n ? ctxOrOptions.options.jit\n : (ctxOrOptions?.jit ?? false);\n\n const transformers = new Map<\n string,\n InstanceType<typeof JavaScriptTransformer>\n >();\n let isProd = false;\n let isWatch = false;\n let preserveVendorMaps = false;\n\n function getTransformer(envName = 'default') {\n let transformer = transformers.get(envName);\n if (!transformer) {\n transformer = new JavaScriptTransformer(\n {\n sourcemap: preserveVendorMaps,\n thirdPartySourcemaps: preserveVendorMaps,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\n transformers.set(envName, transformer);\n }\n return transformer;\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n // Normally build-only. Astro's Cloudflare integration (`@astrojs/cloudflare`)\n // transforms SSR modules through a serve-style `workerd` runner *during*\n // `astro build`; an `apply: 'build'` plugin is excluded from that pipeline,\n // so the Angular linker never runs on the worker's partially-compiled\n // packages and they fall back to the JIT compiler. Also apply under a\n // production `NODE_ENV` (which `astro build` sets) so the linker runs in\n // that runner too. Regular Analog dev servers run with a development\n // `NODE_ENV`, so their behavior is unchanged.\n apply(_config, env) {\n return (\n env.command === 'build' || process.env['NODE_ENV'] === 'production'\n );\n },\n config(userConfig) {\n isProd = isProdMode(userConfig.mode);\n // Advanced optimizations paired with dev-mode defines would strip\n // dev-only code the debug API needs, so both key off `isProd`.\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n } as UserConfig;\n },\n // The top-level define keys `ngServerMode` off the legacy `build.ssr`\n // flag. Environment API builds run the server through a server\n // environment while `build.ssr` stays unset, so give that environment its\n // own value; otherwise the guard compiles to `false` and browser-only\n // hydration features run during SSR. Runs after other plugins' hooks, so\n // a consumer they set is taken into account.\n configEnvironment: {\n order: 'post',\n handler(name, config) {\n if (isProd && isServerEnvironment(name, config)) {\n return { define: { ngServerMode: 'true' } };\n }\n return undefined;\n },\n },\n configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\n isWatch = config.command === 'serve' || !!config.build?.watch;\n },\n transform: {\n filter: {\n // Allow an optional `?query` after the extension. Some environments\n // (e.g. Cloudflare's `workerd`, used by Astro's Cloudflare integration)\n // reference optimized deps with a `?v=<hash>` suffix, e.g.\n // `.../fesm2022/_platform_location-chunk.mjs?v=a786a9ff`. A `$`-anchored\n // extension match skips those, so the Angular linker never runs and the\n // partially-compiled package falls back to the JIT compiler at runtime.\n id: /\\.[cm]?js(?:\\?|$)/,\n },\n async handler(code, id) {\n // Strip the `?query` so the fesm check and the transformer see a real\n // filename rather than `foo.mjs?v=<hash>`.\n const cleanId = id.split('?')[0];\n const angularPackage = /fesm20/.test(cleanId);\n\n if (!angularPackage) {\n // `{ mappings: '' }` declares zero segments, dropping the module's own\n // map from the chain; `null` keeps it. Removing `sourceMappingURL` is\n // what makes that map unreachable, so it only runs when discarding.\n return {\n code:\n isProd && !preserveVendorMaps\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: preserveVendorMaps ? null : { mappings: '' },\n };\n }\n\n const sideEffects =\n jit && cleanId.includes('@angular/compiler') ? true : false;\n const envName = this.environment?.name ?? 'default';\n const transformer = getTransformer(envName);\n const result: Uint8Array = await transformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n const transformed = Buffer.from(result).toString();\n return preserveVendorMaps\n ? extractInlineSourceMap(transformed, cleanId)\n : { code: transformed, map: { mappings: '' } };\n },\n },\n async closeBundle() {\n if (isWatch) {\n return;\n }\n const envName = this.environment?.name ?? 'default';\n const transformer = transformers.get(envName);\n if (transformer) {\n transformers.delete(envName);\n await transformer.close();\n }\n },\n };\n}\n\nexport function extractInlineSourceMap(\n code: string,\n _id: string,\n): { code: string; map: string | null } {\n // Matching the whole comment with one regex can throw \"Maximum call stack\n // size exceeded\" on multi-megabyte payloads (#2669), so search by index.\n const prefix = '//# sourceMappingURL=data:application/json';\n const separator = ';base64,';\n const commentStart = code.lastIndexOf(prefix);\n if (commentStart === -1) {\n return { code, map: null };\n }\n\n const tail = code.slice(commentStart + prefix.length).trimEnd();\n const base64Start = tail.indexOf(separator);\n const payload = tail.slice(base64Start + separator.length);\n // Only a terminal comment counts: anything other than base64 characters\n // and trailing whitespace after `;base64,` leaves the code untouched.\n if (\n base64Start === -1 ||\n !/^(?:;charset=[^;,]+)?$/.test(tail.slice(0, base64Start)) ||\n payload === '' ||\n /[^A-Za-z0-9+/=]/.test(payload)\n ) {\n return { code, map: null };\n }\n\n const codeEnd =\n code[commentStart - 1] === '\\n' ? commentStart - 1 : commentStart;\n return {\n code: code.slice(0, codeEnd),\n map: Buffer.from(payload, 'base64').toString(),\n };\n}\n"],"mappings":";;;;AAYA,SAAgB,qBACd,cACQ;CACR,MAAM,MAAM,sBAAsB,YAAY,IAC1C,aAAa,QAAQ,MACpB,cAAc,OAAO;CAE1B,MAAM,+BAAe,IAAI,IAGvB;CACF,IAAI,SAAS;CACb,IAAI,UAAU;CACd,IAAI,qBAAqB;CAEzB,SAAS,eAAe,UAAU,WAAW;EAC3C,IAAI,cAAc,aAAa,IAAI,OAAO;EAC1C,IAAI,CAAC,aAAa;GAChB,cA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AAa,KAAK,EAAE,UAAU,GAAG;IAAE;GACjD;EACF;EACA,MAAM,cAAc;GAClB,IAAI,SACF;GAEF,MAAM,UAAU,KAAK,aAAa,QAAQ;GAC1C,MAAM,cAAc,aAAa,IAAI,OAAO;GAC5C,IAAI,aAAa;IACf,aAAa,OAAO,OAAO;IAC3B,MAAM,YAAY,MAAM;GAC1B;EACF;CACF;AACF;AAEA,SAAgB,uBACd,MACA,KACsC;CAGtC,MAAM,SAAS;CACf,MAAM,YAAY;CAClB,MAAM,eAAe,KAAK,YAAY,MAAM;CAC5C,IAAI,iBAAiB,IACnB,OAAO;EAAE;EAAM,KAAK;CAAK;CAG3B,MAAM,OAAO,KAAK,MAAM,eAAe,EAAa,CAAC,CAAC,QAAQ;CAC9D,MAAM,cAAc,KAAK,QAAQ,SAAS;CAC1C,MAAM,UAAU,KAAK,MAAM,cAAc,CAAgB;CAGzD,IACE,gBAAgB,MAChB,CAAC,yBAAyB,KAAK,KAAK,MAAM,GAAG,WAAW,CAAC,KACzD,YAAY,MACZ,kBAAkB,KAAK,OAAO,GAE9B,OAAO;EAAE;EAAM,KAAK;CAAK;CAG3B,MAAM,UACJ,KAAK,eAAe,OAAO,OAAO,eAAe,IAAI;CACvD,OAAO;EACL,MAAM,KAAK,MAAM,GAAG,OAAO;EAC3B,KAAK,OAAO,KAAK,SAAS,QAAQ,CAAC,CAAC,SAAS;CAC/C;AACF"}
@@ -0,0 +1,74 @@
1
+ import type { parseSync } from "oxc-parser";
2
+ import type { ComponentRegistryEntries } from "./analog-plugin-interop.js";
3
+ import { type ComponentRegistry, type RegistryEntry } from "./compiler/index.js";
4
+ import type { FastCompileResolve, FastCompileSourceFormat } from "./fast-compile-api.js";
5
+ type OxcProgram = ReturnType<typeof parseSync>["program"];
6
+ /** Resolves an import to a source file to scan, or `null` to skip it. */
7
+ export type ResolveImport = (spec: string, importer: string) => Promise<string | null>;
8
+ /**
9
+ * Angular classes scanned from source files and package `.d.ts` declarations,
10
+ * so source formats can look up the selectors of the components they import
11
+ * before any compiler sees their modules. Shared by the fast compile and NGP
12
+ * plugins.
13
+ */
14
+ export declare class ComponentScanner {
15
+ readonly registry: ComponentRegistry;
16
+ readonly scannedDtsPackages: Set<string>;
17
+ /** Files scanned on demand, mapped to the barrel chain each pulled in. */
18
+ readonly lazyScans: Map<string, Promise<Set<string>>>;
19
+ /** Modules compiled against each scanned file. */
20
+ readonly importersByFile: Map<string, Set<string>>;
21
+ private readonly sourceFormats;
22
+ private root;
23
+ /** Where package declarations are looked up from. */
24
+ get projectRoot(): string;
25
+ reset(projectRoot: string): void;
26
+ registerSourceFormat(format: FastCompileSourceFormat): void;
27
+ sourceFormatOf(file: string): FastCompileSourceFormat | undefined;
28
+ /** Whether `file` is TypeScript or a module of a registered source format. */
29
+ isCompiledSource(file: string): boolean;
30
+ /**
31
+ * Reads a source file for scanning. Modules of a registered source format
32
+ * are converted to TypeScript first so the scanner sees their classes.
33
+ */
34
+ readScanSource(file: string): Promise<string>;
35
+ /**
36
+ * Adapts a Vite-style resolver to the scanner's: only source files this
37
+ * scanner reads, outside `node_modules` (package declarations come from the
38
+ * `.d.ts` scanner instead).
39
+ */
40
+ toResolveImport(resolve: FastCompileResolve): ResolveImport;
41
+ /** Scans the `.d.ts` declarations of `packages` into the registry, once each. */
42
+ ensureDtsRegistryForPackages(packages: Iterable<string>): void;
43
+ ensureDtsRegistryForSource(code: string, id: string, program?: OxcProgram): void;
44
+ /**
45
+ * Scans the modules behind `specifiers`, imported by `importer`: packages
46
+ * from their `.d.ts` declarations, everything else from source.
47
+ */
48
+ scanImports(specifiers: string[], importer: string, resolve: FastCompileResolve): Promise<void>;
49
+ /**
50
+ * Scans the files behind `specs`, imported by `id`, into the registry and
51
+ * records `id` as their importer.
52
+ */
53
+ resolveImportSpecifiers(specs: string[], id: string, resolveImport: ResolveImport): Promise<void>;
54
+ /**
55
+ * The element selector of a component or directive class. `external` are
56
+ * registries contributed through `analog.setup()`.
57
+ */
58
+ lookupSelector(className: string, external?: readonly ComponentRegistryEntries[]): string | null;
59
+ /** The files scanned for `importer`. */
60
+ dependenciesOf(importer: string): string[];
61
+ entriesOf(file: string): RegistryEntry[];
62
+ /** Drops what was scanned from `file`, so the next scan reads it again. */
63
+ invalidate(file: string): void;
64
+ private addEntry;
65
+ private scanOnDemand;
66
+ /**
67
+ * Scan a file and everything it re-exports, resolving specifiers through
68
+ * Vite so path aliases work. Tuple barrels and NgModules can list classes
69
+ * their file imports without re-exporting, so their imports are followed
70
+ * too. Returns every file scanned.
71
+ */
72
+ private scanWithReExports;
73
+ }
74
+ export {};
@@ -0,0 +1,178 @@
1
+ import { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from "./utils/plugin-config.js";
2
+ import { parseOxc } from "./compiler/utils.js";
3
+ import { scanFile } from "./compiler/registry.js";
4
+ import { collectAllImports, collectImportedPackages, collectReExports, scanPackageDts } from "./compiler/dts-reader.js";
5
+ import "./compiler/index.js";
6
+ import { promises } from "node:fs";
7
+ import { normalizePath } from "vite";
8
+ //#region packages/vite-plugin-angular/src/lib/component-scanner.ts
9
+ /**
10
+ * Angular classes scanned from source files and package `.d.ts` declarations,
11
+ * so source formats can look up the selectors of the components they import
12
+ * before any compiler sees their modules. Shared by the fast compile and NGP
13
+ * plugins.
14
+ */
15
+ var ComponentScanner = class {
16
+ registry = /* @__PURE__ */ new Map();
17
+ scannedDtsPackages = /* @__PURE__ */ new Set();
18
+ /** Files scanned on demand, mapped to the barrel chain each pulled in. */
19
+ lazyScans = /* @__PURE__ */ new Map();
20
+ /** Modules compiled against each scanned file. */
21
+ importersByFile = /* @__PURE__ */ new Map();
22
+ sourceFormats = [];
23
+ root = "";
24
+ /** Where package declarations are looked up from. */
25
+ get projectRoot() {
26
+ return this.root;
27
+ }
28
+ reset(projectRoot) {
29
+ this.root = projectRoot;
30
+ this.registry.clear();
31
+ this.scannedDtsPackages.clear();
32
+ this.lazyScans.clear();
33
+ this.importersByFile.clear();
34
+ }
35
+ registerSourceFormat(format) {
36
+ if (!this.sourceFormats.includes(format)) this.sourceFormats.push(format);
37
+ }
38
+ sourceFormatOf(file) {
39
+ const path = file.split("?")[0];
40
+ return this.sourceFormats.find((format) => format.test(path));
41
+ }
42
+ /** Whether `file` is TypeScript or a module of a registered source format. */
43
+ isCompiledSource(file) {
44
+ return TS_EXT_REGEX.test(file) || this.sourceFormatOf(file) !== void 0;
45
+ }
46
+ /**
47
+ * Reads a source file for scanning. Modules of a registered source format
48
+ * are converted to TypeScript first so the scanner sees their classes.
49
+ */
50
+ async readScanSource(file) {
51
+ const code = await promises.readFile(file, "utf-8");
52
+ const format = this.sourceFormatOf(file);
53
+ return format ? format.toScanSource(code, file) : code;
54
+ }
55
+ /**
56
+ * Adapts a Vite-style resolver to the scanner's: only source files this
57
+ * scanner reads, outside `node_modules` (package declarations come from the
58
+ * `.d.ts` scanner instead).
59
+ */
60
+ toResolveImport(resolve) {
61
+ return async (spec, importer) => {
62
+ const resolved = await resolve(spec, importer);
63
+ if (!resolved || resolved.external) return null;
64
+ const file = normalizePath(resolved.id.split("?")[0]);
65
+ return this.isCompiledSource(file) && !EXCLUDED_TS_EXT_REGEX.test(file) && !file.includes("/node_modules/") ? file : null;
66
+ };
67
+ }
68
+ /** Scans the `.d.ts` declarations of `packages` into the registry, once each. */
69
+ ensureDtsRegistryForPackages(packages) {
70
+ for (const pkg of packages) {
71
+ if (this.scannedDtsPackages.has(pkg)) continue;
72
+ this.scannedDtsPackages.add(pkg);
73
+ try {
74
+ const dtsEntries = scanPackageDts(pkg, this.root || process.cwd(), this.scannedDtsPackages);
75
+ for (const entry of dtsEntries) this.addEntry(entry);
76
+ } catch {}
77
+ }
78
+ }
79
+ ensureDtsRegistryForSource(code, id, program) {
80
+ this.ensureDtsRegistryForPackages(collectImportedPackages(code, id, program));
81
+ }
82
+ /**
83
+ * Scans the modules behind `specifiers`, imported by `importer`: packages
84
+ * from their `.d.ts` declarations, everything else from source.
85
+ */
86
+ scanImports(specifiers, importer, resolve) {
87
+ this.ensureDtsRegistryForPackages(specifiers.filter((spec) => !spec.startsWith(".") && !spec.startsWith("/")).map((spec) => {
88
+ const parts = spec.split("/");
89
+ return spec.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
90
+ }));
91
+ return this.resolveImportSpecifiers(specifiers, importer, this.toResolveImport(resolve));
92
+ }
93
+ /**
94
+ * Scans the files behind `specs`, imported by `id`, into the registry and
95
+ * records `id` as their importer.
96
+ */
97
+ async resolveImportSpecifiers(specs, id, resolveImport) {
98
+ await Promise.all(specs.map(async (spec) => {
99
+ const file = await resolveImport(spec, id);
100
+ if (!file) return;
101
+ for (const scanned of await this.scanOnDemand(file, resolveImport)) {
102
+ let importers = this.importersByFile.get(scanned);
103
+ if (!importers) {
104
+ importers = /* @__PURE__ */ new Set();
105
+ this.importersByFile.set(scanned, importers);
106
+ }
107
+ importers.add(id);
108
+ }
109
+ }));
110
+ }
111
+ /**
112
+ * The element selector of a component or directive class. `external` are
113
+ * registries contributed through `analog.setup()`.
114
+ */
115
+ lookupSelector(className, external = []) {
116
+ const entry = this.registry.get(className) ?? external.map((r) => r.get(className)).find((e) => e !== void 0);
117
+ if (!entry || entry.kind !== "component" && entry.kind !== "directive") return null;
118
+ return entry.selector;
119
+ }
120
+ /** The files scanned for `importer`. */
121
+ dependenciesOf(importer) {
122
+ return [...this.importersByFile].filter(([, importers]) => importers.has(importer)).map(([file]) => file);
123
+ }
124
+ entriesOf(file) {
125
+ return [...this.registry.values()].filter((e) => e.fileName === file);
126
+ }
127
+ /** Drops what was scanned from `file`, so the next scan reads it again. */
128
+ invalidate(file) {
129
+ for (const entry of this.entriesOf(file)) this.registry.delete(entry.className);
130
+ this.lazyScans.clear();
131
+ }
132
+ addEntry(entry) {
133
+ if (!this.registry.has(entry.className)) this.registry.set(entry.className, entry);
134
+ }
135
+ scanOnDemand(file, resolveImport) {
136
+ let scan = this.lazyScans.get(file);
137
+ if (!scan) {
138
+ scan = this.scanWithReExports(file, resolveImport);
139
+ this.lazyScans.set(file, scan);
140
+ }
141
+ return scan;
142
+ }
143
+ /**
144
+ * Scan a file and everything it re-exports, resolving specifiers through
145
+ * Vite so path aliases work. Tuple barrels and NgModules can list classes
146
+ * their file imports without re-exporting, so their imports are followed
147
+ * too. Returns every file scanned.
148
+ */
149
+ async scanWithReExports(file, resolveImport) {
150
+ const visited = /* @__PURE__ */ new Set();
151
+ const visit = async (current) => {
152
+ if (visited.has(current)) return;
153
+ visited.add(current);
154
+ let code;
155
+ let program;
156
+ try {
157
+ code = await this.readScanSource(current);
158
+ program = parseOxc(current, code).program;
159
+ } catch {
160
+ return;
161
+ }
162
+ const entries = scanFile(code, current, program);
163
+ for (const entry of entries) this.addEntry(entry);
164
+ this.ensureDtsRegistryForSource(code, current, program);
165
+ const specifiers = entries.some((e) => e.kind === "tuple" || e.kind === "ngmodule") ? collectAllImports(code, current, program) : collectReExports(code, current, program);
166
+ for (const spec of specifiers) {
167
+ const dep = await resolveImport(spec, current);
168
+ if (dep) await visit(dep);
169
+ }
170
+ };
171
+ await visit(file);
172
+ return visited;
173
+ }
174
+ };
175
+ //#endregion
176
+ export { ComponentScanner };
177
+
178
+ //# sourceMappingURL=component-scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-scanner.js","names":[],"sources":["../../../src/lib/component-scanner.ts"],"sourcesContent":["import { promises as fsPromises } from 'node:fs';\nimport type { parseSync } from 'oxc-parser';\nimport { normalizePath } from 'vite';\n\nimport type { ComponentRegistryEntries } from './analog-plugin-interop.js';\nimport {\n collectAllImports,\n collectImportedPackages,\n collectReExports,\n scanFile,\n scanPackageDts,\n type ComponentRegistry,\n type RegistryEntry,\n} from './compiler/index.js';\nimport { parseOxc } from './compiler/utils.js';\nimport type {\n FastCompileResolve,\n FastCompileSourceFormat,\n} from './fast-compile-api.js';\nimport { EXCLUDED_TS_EXT_REGEX, TS_EXT_REGEX } from './utils/plugin-config.js';\n\ntype OxcProgram = ReturnType<typeof parseSync>['program'];\n\n/** Resolves an import to a source file to scan, or `null` to skip it. */\nexport type ResolveImport = (\n spec: string,\n importer: string,\n) => Promise<string | null>;\n\n/**\n * Angular classes scanned from source files and package `.d.ts` declarations,\n * so source formats can look up the selectors of the components they import\n * before any compiler sees their modules. Shared by the fast compile and NGP\n * plugins.\n */\nexport class ComponentScanner {\n readonly registry: ComponentRegistry = new Map();\n readonly scannedDtsPackages: Set<string> = new Set();\n /** Files scanned on demand, mapped to the barrel chain each pulled in. */\n readonly lazyScans: Map<string, Promise<Set<string>>> = new Map();\n /** Modules compiled against each scanned file. */\n readonly importersByFile: Map<string, Set<string>> = new Map();\n private readonly sourceFormats: FastCompileSourceFormat[] = [];\n private root = '';\n\n /** Where package declarations are looked up from. */\n get projectRoot(): string {\n return this.root;\n }\n\n reset(projectRoot: string): void {\n this.root = projectRoot;\n this.registry.clear();\n this.scannedDtsPackages.clear();\n this.lazyScans.clear();\n this.importersByFile.clear();\n }\n\n registerSourceFormat(format: FastCompileSourceFormat): void {\n if (!this.sourceFormats.includes(format)) {\n this.sourceFormats.push(format);\n }\n }\n\n sourceFormatOf(file: string): FastCompileSourceFormat | undefined {\n const path = file.split('?')[0];\n return this.sourceFormats.find((format) => format.test(path));\n }\n\n /** Whether `file` is TypeScript or a module of a registered source format. */\n isCompiledSource(file: string): boolean {\n return TS_EXT_REGEX.test(file) || this.sourceFormatOf(file) !== undefined;\n }\n\n /**\n * Reads a source file for scanning. Modules of a registered source format\n * are converted to TypeScript first so the scanner sees their classes.\n */\n async readScanSource(file: string): Promise<string> {\n const code = await fsPromises.readFile(file, 'utf-8');\n const format = this.sourceFormatOf(file);\n return format ? format.toScanSource(code, file) : code;\n }\n\n /**\n * Adapts a Vite-style resolver to the scanner's: only source files this\n * scanner reads, outside `node_modules` (package declarations come from the\n * `.d.ts` scanner instead).\n */\n toResolveImport(resolve: FastCompileResolve): ResolveImport {\n return async (spec, importer) => {\n const resolved = await resolve(spec, importer);\n if (!resolved || resolved.external) return null;\n const file = normalizePath(resolved.id.split('?')[0]);\n return this.isCompiledSource(file) &&\n !EXCLUDED_TS_EXT_REGEX.test(file) &&\n !file.includes('/node_modules/')\n ? file\n : null;\n };\n }\n\n /** Scans the `.d.ts` declarations of `packages` into the registry, once each. */\n ensureDtsRegistryForPackages(packages: Iterable<string>): void {\n for (const pkg of packages) {\n if (this.scannedDtsPackages.has(pkg)) continue;\n this.scannedDtsPackages.add(pkg);\n try {\n const dtsEntries = scanPackageDts(\n pkg,\n // Before a tsconfig resolves, look up packages from the working directory.\n this.root || process.cwd(),\n this.scannedDtsPackages,\n );\n for (const entry of dtsEntries) {\n this.addEntry(entry);\n }\n } catch {\n // Package may not have .d.ts files or may not be Angular\n }\n }\n }\n\n ensureDtsRegistryForSource(\n code: string,\n id: string,\n program?: OxcProgram,\n ): void {\n this.ensureDtsRegistryForPackages(\n collectImportedPackages(code, id, program),\n );\n }\n\n /**\n * Scans the modules behind `specifiers`, imported by `importer`: packages\n * from their `.d.ts` declarations, everything else from source.\n */\n scanImports(\n specifiers: string[],\n importer: string,\n resolve: FastCompileResolve,\n ): Promise<void> {\n this.ensureDtsRegistryForPackages(\n specifiers\n .filter((spec) => !spec.startsWith('.') && !spec.startsWith('/'))\n .map((spec) => {\n const parts = spec.split('/');\n return spec.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n }),\n );\n return this.resolveImportSpecifiers(\n specifiers,\n importer,\n this.toResolveImport(resolve),\n );\n }\n\n /**\n * Scans the files behind `specs`, imported by `id`, into the registry and\n * records `id` as their importer.\n */\n async resolveImportSpecifiers(\n specs: string[],\n id: string,\n resolveImport: ResolveImport,\n ): Promise<void> {\n await Promise.all(\n specs.map(async (spec) => {\n const file = await resolveImport(spec, id);\n if (!file) return;\n for (const scanned of await this.scanOnDemand(file, resolveImport)) {\n let importers = this.importersByFile.get(scanned);\n if (!importers) {\n importers = new Set();\n this.importersByFile.set(scanned, importers);\n }\n importers.add(id);\n }\n }),\n );\n }\n\n /**\n * The element selector of a component or directive class. `external` are\n * registries contributed through `analog.setup()`.\n */\n lookupSelector(\n className: string,\n external: readonly ComponentRegistryEntries[] = [],\n ): string | null {\n const entry =\n this.registry.get(className) ??\n external.map((r) => r.get(className)).find((e) => e !== undefined);\n if (!entry || (entry.kind !== 'component' && entry.kind !== 'directive')) {\n return null;\n }\n return entry.selector;\n }\n\n /** The files scanned for `importer`. */\n dependenciesOf(importer: string): string[] {\n return [...this.importersByFile]\n .filter(([, importers]) => importers.has(importer))\n .map(([file]) => file);\n }\n\n entriesOf(file: string): RegistryEntry[] {\n return [...this.registry.values()].filter((e) => e.fileName === file);\n }\n\n /** Drops what was scanned from `file`, so the next scan reads it again. */\n invalidate(file: string): void {\n for (const entry of this.entriesOf(file)) {\n this.registry.delete(entry.className);\n }\n this.lazyScans.clear();\n }\n\n private addEntry(entry: RegistryEntry): void {\n if (!this.registry.has(entry.className)) {\n this.registry.set(entry.className, entry);\n }\n }\n\n private scanOnDemand(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n let scan = this.lazyScans.get(file);\n if (!scan) {\n scan = this.scanWithReExports(file, resolveImport);\n this.lazyScans.set(file, scan);\n }\n return scan;\n }\n\n /**\n * Scan a file and everything it re-exports, resolving specifiers through\n * Vite so path aliases work. Tuple barrels and NgModules can list classes\n * their file imports without re-exporting, so their imports are followed\n * too. Returns every file scanned.\n */\n private async scanWithReExports(\n file: string,\n resolveImport: ResolveImport,\n ): Promise<Set<string>> {\n const visited = new Set<string>();\n const visit = async (current: string): Promise<void> => {\n if (visited.has(current)) return;\n visited.add(current);\n let code: string;\n let program: OxcProgram;\n try {\n code = await this.readScanSource(current);\n program = parseOxc(current, code).program;\n } catch {\n return;\n }\n const entries = scanFile(code, current, program);\n for (const entry of entries) {\n this.addEntry(entry);\n }\n this.ensureDtsRegistryForSource(code, current, program);\n const followsImports = entries.some(\n (e) => e.kind === 'tuple' || e.kind === 'ngmodule',\n );\n const specifiers = followsImports\n ? collectAllImports(code, current, program)\n : collectReExports(code, current, program);\n for (const spec of specifiers) {\n const dep = await resolveImport(spec, current);\n if (dep) await visit(dep);\n }\n };\n await visit(file);\n return visited;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAmCA,IAAa,mBAAb,MAA8B;CAC5B,2BAAuC,IAAI,IAAI;CAC/C,qCAA2C,IAAI,IAAI;;CAEnD,4BAAwD,IAAI,IAAI;;CAEhE,kCAAqD,IAAI,IAAI;CAC7D,gBAA4D,CAAC;CAC7D,OAAe;;CAGf,IAAI,cAAsB;EACxB,OAAO,KAAK;CACd;CAEA,MAAM,aAA2B;EAC/B,KAAK,OAAO;EACZ,KAAK,SAAS,MAAM;EACpB,KAAK,mBAAmB,MAAM;EAC9B,KAAK,UAAU,MAAM;EACrB,KAAK,gBAAgB,MAAM;CAC7B;CAEA,qBAAqB,QAAuC;EAC1D,IAAI,CAAC,KAAK,cAAc,SAAS,MAAM,GACrC,KAAK,cAAc,KAAK,MAAM;CAElC;CAEA,eAAe,MAAmD;EAChE,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC;EAC7B,OAAO,KAAK,cAAc,MAAM,WAAW,OAAO,KAAK,IAAI,CAAC;CAC9D;;CAGA,iBAAiB,MAAuB;EACtC,OAAO,aAAa,KAAK,IAAI,KAAK,KAAK,eAAe,IAAI,MAAM,KAAA;CAClE;;;;;CAMA,MAAM,eAAe,MAA+B;EAClD,MAAM,OAAO,MAAM,SAAW,SAAS,MAAM,OAAO;EACpD,MAAM,SAAS,KAAK,eAAe,IAAI;EACvC,OAAO,SAAS,OAAO,aAAa,MAAM,IAAI,IAAI;CACpD;;;;;;CAOA,gBAAgB,SAA4C;EAC1D,OAAO,OAAO,MAAM,aAAa;GAC/B,MAAM,WAAW,MAAM,QAAQ,MAAM,QAAQ;GAC7C,IAAI,CAAC,YAAY,SAAS,UAAU,OAAO;GAC3C,MAAM,OAAO,cAAc,SAAS,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE;GACpD,OAAO,KAAK,iBAAiB,IAAI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