@analogjs/vite-plugin-angular 3.0.0-beta.30 → 3.0.0-beta.31
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 +1 -1
- package/src/lib/angular-vite-plugin.js +2 -1
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.js +3 -0
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compiler/compile.js +22 -10
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/index.js +2 -2
- package/src/lib/compiler/resource-inliner.d.ts +7 -8
- package/src/lib/compiler/resource-inliner.js +8 -16
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.d.ts +8 -0
- package/src/lib/compiler/style-ast.js +24 -3
- package/src/lib/compiler/style-ast.js.map +1 -1
- package/src/lib/fast-compile-plugin.js +23 -19
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.d.ts +2 -0
- package/src/lib/host.js +2 -0
- package/src/lib/host.js.map +1 -1
- package/src/lib/utils/stylesheet-warning.d.ts +2 -0
- package/src/lib/utils/stylesheet-warning.js +8 -0
- package/src/lib/utils/stylesheet-warning.js.map +1 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SourceFileCache, angularFullVersion, createAngularCompilation } from "../utils/devkit.js";
|
|
2
2
|
import { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugEmit, debugHmr, debugHmrV, debugStyles, debugStylesV } from "../utils/debug.js";
|
|
3
|
+
import { warnStylesheetError } from "../utils/stylesheet-warning.js";
|
|
3
4
|
import { createCompilerPlugin, createRolldownCompilerPlugin } from "../compiler-plugin.js";
|
|
4
5
|
import { TS_EXT_REGEX, createTsConfigGetter, getTsConfigPath } from "../utils/plugin-config.js";
|
|
5
6
|
import { TsconfigResolver } from "../utils/tsconfig-resolver.js";
|
|
@@ -171,6 +172,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
171
172
|
fileReplacements: toAngularCompilationFileReplacements(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),
|
|
172
173
|
modifiedFiles,
|
|
173
174
|
async transformStylesheet(data, containingFile, resourceFile, order, className) {
|
|
175
|
+
if (resourceFile && !data) data = readFileSync(resourceFile, "utf-8");
|
|
174
176
|
const filename = resourceFile ?? containingFile.replace(".ts", `.${pluginOptions.inlineStylesExtension}`);
|
|
175
177
|
const preprocessed = preprocessStylesheetResult(data, filename, stylePreprocessor, {
|
|
176
178
|
filename,
|
|
@@ -213,6 +215,7 @@ function angularCompilationPlugin(options = {}) {
|
|
|
213
215
|
resourceFile: resourceFile ?? "(inline)",
|
|
214
216
|
error: String(e)
|
|
215
217
|
});
|
|
218
|
+
warnStylesheetError(resolvedConfig.logger, filename, e);
|
|
216
219
|
}
|
|
217
220
|
return stylesheetResult?.code || "";
|
|
218
221
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from '../utils/debug.js';\nimport {\n getTsConfigPath,\n createTsConfigGetter,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n discoverAnalogIntegrations,\n type TransformFilter,\n} from '../analog-plugin-interop.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n getBrowserModeCliOverride,\n} from '../utils/compilation-shared.js';\nimport { createHotUpdateBatcher } from '../hot-update-batch.js';\nimport { angularVitestPlugins } from '../angular-vitest-plugin.js';\nimport { buildOptimizerPlugin } from '../angular-build-optimizer-plugin.js';\nimport { jitPlugin } from '../angular-jit-plugin.js';\nimport { liveReloadPlugin } from '../live-reload-plugin.js';\nimport { virtualModulesPlugin } from '../virtual-modules-plugin.js';\nimport { encapsulationPlugin } from '../encapsulation-plugin.js';\nimport { nxFolderPlugin } from '../nx-folder-plugin.js';\nimport { routerPlugin } from '../router-plugin.js';\nimport { replaceFiles } from '../plugins/file-replacements.plugin.js';\nimport { cssExtensionStyleResolverPlugin } from '../utils/css-extension-resolver.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\n/**\n * @experimental The Angular Compilation API plugin may change in future releases.\n */\nexport interface AngularCompilationPluginOptions {\n tsconfig?: string | (() => string);\n workspaceRoot?: string;\n inlineStylesExtension?: string;\n jit?: boolean;\n liveReload?: boolean;\n disableTypeChecking?: boolean;\n supportedBrowsers?: string[];\n fileReplacements?: FileReplacement[];\n include?: string[];\n debug?: DebugOption;\n}\n\n/**\n * Compiles Angular applications using Angular's private Compilation API.\n *\n * @experimental This plugin may change in future releases.\n */\nexport function angularCompilationPlugin(\n options: AngularCompilationPluginOptions = {},\n): Plugin[] {\n if (\n angularFullVersion < 200100 ||\n typeof createAngularCompilation !== 'function'\n ) {\n throw new Error(\n '[@analogjs/vite-plugin-angular]: angularCompilationPlugin requires Angular v20.1 or later and a matching @angular/build package with the Compilation API.',\n );\n }\n\n applyDebugOption(options.debug, options.workspaceRoot);\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const pluginOptions = {\n tsconfigGetter: createTsConfigGetter(options.tsconfig),\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options.inlineStylesExtension ?? 'css',\n jit: options.jit ?? isTest,\n liveReload: options.liveReload ?? true,\n disableTypeChecking: options.disableTypeChecking ?? true,\n supportedBrowsers: options.supportedBrowsers ?? ['safari 15'],\n fileReplacements: options.fileReplacements ?? [],\n include: options.include ?? [],\n isAstroIntegration: process.env['ANALOG_ASTRO'] === 'true',\n };\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n let stylePreprocessor: StylePreprocessor | undefined;\n let transformFilter: TransformFilter | undefined;\n let externalizeStylesRequested = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n const hotUpdates = createHotUpdateBatcher((ids) =>\n performCompilation(resolvedConfig, ids),\n );\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let deferInitialCompilation = isVitestVscode;\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || externalizeStylesRequested);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const transformCompilerOptions = (\n tsCompilerOptions: Record<string, unknown>,\n ) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n externalizeStylesRequested,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n };\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(workerFile: string) {\n return workerFile;\n },\n },\n angularFullVersion >= 220200\n ? {\n enableHmr: shouldEnableLiveReload(),\n externalRuntimeStyles: shouldExternalizeStyles(),\n includeTestMetadata: isTest || shouldEnableLiveReload(),\n instrumentForCoverage: !isTest,\n }\n : (transformCompilerOptions as unknown as Parameters<\n typeof compilation.initialize\n >[2]),\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (stylesheetRegistry && stylePreprocessor && existsSync(key)) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n\n // Free the compilation before chunks render; `transform` still reads `outputFiles`.\n if (!watchMode && !isTest) {\n await compilation.close?.();\n angularCompilation = undefined;\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n const integrations = await discoverAnalogIntegrations(config);\n stylePreprocessor = integrations.stylePreprocessor;\n transformFilter = integrations.transformFilter;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n externalizeStylesRequested = integrations.externalizeStyles;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n const compilerPlugin: Plugin = {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n api: { getTsConfigPath: resolveTsConfigPath },\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\n };\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`, registered once at the\n // `angularCompilationPlugin()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n const integrations = await discoverAnalogIntegrations(config);\n integrations.configureStylesheetRegistry?.(stylesheetRegistry, {\n workspaceRoot: pluginOptions.workspaceRoot,\n });\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n const browser = (config as any).test?.browser;\n deferInitialCompilation =\n isVitestVscode ||\n (!!browser &&\n (getBrowserModeCliOverride() ?? browser.enabled) === true);\n\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n hotUpdates.configureServer(server);\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!deferInitialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n await pendingCompilation;\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n await hotUpdates.schedule(ctx.file, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath =\n stylesheetRegistry?.getServedSourcePath(filename);\n\n if (servedSourcePath) {\n debugStylesV('resolveId: mapped served stylesheet to source', {\n filename,\n resolvedPath: servedSourcePath,\n });\n return servedSourcePath + search;\n }\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n if (/[?&]raw\\b/.test(id)) return;\n if (transformFilter && !transformFilter(code, id)) {\n return;\n }\n\n // Angular emits every file in the program, not only files with\n // Angular decorators, and `@analogjs/platform` excludes `.ts` from\n // Vite's own transform. So serve Angular's output for any emitted\n // file; only the \"not emitted\" warning below is decorator-specific.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (deferInitialCompilation && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n await hotUpdates.wait();\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n async closeBundle() {\n hotUpdates.close();\n await compilationLock;\n await angularCompilation?.close?.();\n angularCompilation = undefined;\n outputFiles.clear();\n classNames.clear();\n sourceFileCache.clear();\n tsconfigResolver.invalidateAll();\n stylesheetRegistry = undefined;\n pendingCompilation = null;\n initialCompilation = false;\n },\n };\n\n return [\n cssExtensionStyleResolverPlugin(),\n replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),\n virtualModulesPlugin({ jit: pluginOptions.jit }),\n compilerPlugin,\n pluginOptions.liveReload && liveReloadPlugin({ classNames, fileEmitter }),\n ...(isTest && !isStackBlitz\n ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map)\n : []),\n pluginOptions.jit &&\n jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),\n buildOptimizerPlugin({\n jit: pluginOptions.jit,\n }),\n routerPlugin(),\n nxFolderPlugin(),\n encapsulationPlugin(),\n ].filter(Boolean) as Plugin[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,IAAM,KADU,cAAc,YAAY,GAC/B,CAAA,CAAQ,YAAY;;;;;;AAuB/B,SAAgB,yBACd,UAA2C,CAAC,GAClC;CACV,IACE,qBAAqB,UACrB,OAAO,6BAA6B,YAEpC,MAAM,IAAI,MACR,2JACF;CAGF,iBAAiB,QAAQ,OAAO,QAAQ,aAAa;CACrD,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,eAAe,CAAC,CAAC,QAAQ,SAAS;CACxC,MAAM,gBAAgB;EACpB,gBAAgB,qBAAqB,QAAQ,QAAQ;EACrD,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,IAAI;EACd,uBAAuB,QAAQ,yBAAyB;EACxD,KAAK,QAAQ,OAAO;EACpB,YAAY,QAAQ,cAAc;EAClC,qBAAqB,QAAQ,uBAAuB;EACpD,mBAAmB,QAAQ,qBAAqB,CAAC,WAAW;EAC5D,kBAAkB,QAAQ,oBAAoB,CAAC;EAC/C,SAAS,QAAQ,WAAW,CAAC;EAC7B,oBAAoB,QAAQ,IAAI,oBAAoB;CACtD;CACA,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;CAChB,IAAI;CACJ,IAAI;CACJ,IAAI,6BAA6B;CAIjC,I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BAAqB,KAAA;GACrB,qBAAqB;GACrB,qBAAqB;EACvB;CACF;CAEA,OAAO;EACL,gCAAgC;EAChC,aAAa,cAAc,kBAAkB,cAAc,aAAa;EACxE,qBAAqB,EAAE,KAAK,cAAc,IAAI,CAAC;EAC/C;EACA,cAAc,cAAc,iBAAiB;GAAE;GAAY;EAAY,CAAC;EACxE,GAAI,UAAU,CAAC,eACX,sBAAsB,OAAO,YAAY,IAAI,cAAc,EAAE,CAAC,CAAC,EAAE,GAAG,IACpE,CAAC;EACL,cAAc,OACZ,UAAU,EAAE,uBAAuB,cAAc,sBAAsB,CAAC;EAC1E,qBAAqB,EACnB,KAAK,cAAc,IACrB,CAAC;EACD,aAAa;EACb,eAAe;EACf,oBAAoB;CACtB,CAAC,CAAC,OAAO,OAAO;AAClB"}
|
|
1
|
+
{"version":3,"file":"compilation-api-plugin.js","names":[],"sources":["../../../../src/lib/compilation-api/compilation-api-plugin.ts"],"sourcesContent":["import { type createAngularCompilation as createAngularCompilationType } from '@angular/build/private';\nimport { union } from 'es-toolkit';\nimport { createHash } from 'node:crypto';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, isAbsolute, join, relative, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport {\n normalizePath,\n Plugin,\n preprocessCSS,\n ResolvedConfig,\n ViteDevServer,\n} from 'vite';\n\nimport {\n createAngularCompilation,\n SourceFileCache,\n angularFullVersion,\n} from '../utils/devkit.js';\nimport {\n activateDeferredDebug,\n applyDebugOption,\n debugCompilationApi,\n debugCompiler,\n debugEmit,\n debugHmr,\n debugHmrV,\n debugStyles,\n debugStylesV,\n type DebugOption,\n} from '../utils/debug.js';\nimport { warnStylesheetError } from '../utils/stylesheet-warning.js';\nimport {\n getTsConfigPath,\n createTsConfigGetter,\n TS_EXT_REGEX,\n type TsConfigResolutionContext,\n} from '../utils/plugin-config.js';\nimport { TsconfigResolver } from '../utils/tsconfig-resolver.js';\nimport { isRolldown } from '../utils/rolldown.js';\nimport {\n createCompilerPlugin,\n createRolldownCompilerPlugin,\n} from '../compiler-plugin.js';\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n registerStylesheetContent,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport {\n discoverAnalogIntegrations,\n type TransformFilter,\n} from '../analog-plugin-interop.js';\nimport { type FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport type { EmitFileResult } from '../models.js';\nimport type { SourceFileCache as SourceFileCacheType } from '../utils/source-file-cache.js';\nimport {\n injectViteIgnoreForHmrMetadata,\n isIgnoredHmrFile,\n toAngularCompilationFileReplacements,\n mapTemplateUpdatesToFiles,\n refreshStylesheetRegistryForFile,\n DiagnosticModes,\n isTestWatchMode,\n getBrowserModeCliOverride,\n} from '../utils/compilation-shared.js';\nimport { createHotUpdateBatcher } from '../hot-update-batch.js';\nimport { angularVitestPlugins } from '../angular-vitest-plugin.js';\nimport { buildOptimizerPlugin } from '../angular-build-optimizer-plugin.js';\nimport { jitPlugin } from '../angular-jit-plugin.js';\nimport { liveReloadPlugin } from '../live-reload-plugin.js';\nimport { virtualModulesPlugin } from '../virtual-modules-plugin.js';\nimport { encapsulationPlugin } from '../encapsulation-plugin.js';\nimport { nxFolderPlugin } from '../nx-folder-plugin.js';\nimport { routerPlugin } from '../router-plugin.js';\nimport { replaceFiles } from '../plugins/file-replacements.plugin.js';\nimport { cssExtensionStyleResolverPlugin } from '../utils/css-extension-resolver.js';\nimport { loadVirtualRawModule } from '../utils/virtual-resources.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\n/**\n * @experimental The Angular Compilation API plugin may change in future releases.\n */\nexport interface AngularCompilationPluginOptions {\n tsconfig?: string | (() => string);\n workspaceRoot?: string;\n inlineStylesExtension?: string;\n jit?: boolean;\n liveReload?: boolean;\n disableTypeChecking?: boolean;\n supportedBrowsers?: string[];\n fileReplacements?: FileReplacement[];\n include?: string[];\n debug?: DebugOption;\n}\n\n/**\n * Compiles Angular applications using Angular's private Compilation API.\n *\n * @experimental This plugin may change in future releases.\n */\nexport function angularCompilationPlugin(\n options: AngularCompilationPluginOptions = {},\n): Plugin[] {\n if (\n angularFullVersion < 200100 ||\n typeof createAngularCompilation !== 'function'\n ) {\n throw new Error(\n '[@analogjs/vite-plugin-angular]: angularCompilationPlugin requires Angular v20.1 or later and a matching @angular/build package with the Compilation API.',\n );\n }\n\n applyDebugOption(options.debug, options.workspaceRoot);\n const isTest = process.env['NODE_ENV'] === 'test' || !!process.env['VITEST'];\n const isStackBlitz = !!process.versions['webcontainer'];\n const pluginOptions = {\n tsconfigGetter: createTsConfigGetter(options.tsconfig),\n workspaceRoot:\n options.workspaceRoot ??\n process.env['NX_WORKSPACE_ROOT'] ??\n process.cwd(),\n inlineStylesExtension: options.inlineStylesExtension ?? 'css',\n jit: options.jit ?? isTest,\n liveReload: options.liveReload ?? true,\n disableTypeChecking: options.disableTypeChecking ?? true,\n supportedBrowsers: options.supportedBrowsers ?? ['safari 15'],\n fileReplacements: options.fileReplacements ?? [],\n include: options.include ?? [],\n isAstroIntegration: process.env['ANALOG_ASTRO'] === 'true',\n };\n let resolvedConfig: ResolvedConfig;\n let tsConfigResolutionContext: TsConfigResolutionContext | null = null;\n let watchMode = false;\n let stylePreprocessor: StylePreprocessor | undefined;\n let transformFilter: TransformFilter | undefined;\n let externalizeStylesRequested = false;\n\n // Persistent compilation instance — kept alive across rebuilds so Angular\n // can diff prior state and emit `templateUpdates` for HMR.\n let angularCompilation:\n | Awaited<ReturnType<typeof createAngularCompilationType>>\n | undefined;\n const sourceFileCache: SourceFileCacheType = new SourceFileCache();\n const outputFiles = new Map<string, EmitFileResult>();\n const classNames = new Map<string, string>();\n let stylesheetRegistry: AnalogStylesheetRegistry | undefined;\n let compilationLock = Promise.resolve();\n let pendingCompilation: Promise<void> | null = null;\n let initialCompilation = false;\n let viteServer: ViteDevServer | undefined;\n const hotUpdates = createHotUpdateBatcher((ids) =>\n performCompilation(resolvedConfig, ids),\n );\n\n const tsconfigResolver = new TsconfigResolver({\n workspaceRoot: pluginOptions.workspaceRoot,\n include: pluginOptions.include,\n liveReload: pluginOptions.liveReload,\n isTest,\n });\n const isVitestVscode = !!process.env['VITEST_VSCODE'];\n let deferInitialCompilation = isVitestVscode;\n let testWatchMode = isTestWatchMode();\n\n function hasViteHmrTransport(): boolean {\n return resolvedConfig ? resolvedConfig.server.hmr !== false : true;\n }\n\n function shouldEnableLiveReload(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n return !!(\n effectiveWatchMode &&\n pluginOptions.liveReload &&\n hasViteHmrTransport()\n );\n }\n\n function shouldExternalizeStyles(): boolean {\n const effectiveWatchMode = isTest ? testWatchMode : watchMode;\n if (!effectiveWatchMode) return false;\n return !!(shouldEnableLiveReload() || externalizeStylesRequested);\n }\n\n function resolveTsConfigPath() {\n const tsconfigValue = pluginOptions.tsconfigGetter();\n return getTsConfigPath(\n tsConfigResolutionContext!.root,\n tsconfigValue,\n tsConfigResolutionContext!.isProd,\n isTest,\n tsConfigResolutionContext!.isLib,\n );\n }\n\n function resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const includedFiles = tsconfigResolver.ensureIncludeCache();\n const cached = tsconfigResolver.getCachedTsconfigOptions(\n resolvedTsConfigPath,\n config,\n );\n const expandedGraphRoots = tsconfigResolver.collectExpandedTsconfigRoots(\n resolvedTsConfigPath,\n config,\n );\n const mergedRootNames = union(\n cached.rootNames,\n expandedGraphRoots,\n includedFiles,\n ).map((file) => normalizePath(file));\n\n if (mergedRootNames.length === cached.rootNames.length) {\n return resolvedTsConfigPath;\n }\n\n const resolvedCacheDir = isAbsolute(config.cacheDir)\n ? config.cacheDir\n : resolve(config.root, config.cacheDir);\n const wrapperDir = join(\n resolvedCacheDir,\n 'analog-angular',\n 'compilation-api',\n );\n const rawTsconfig = (ts.readConfigFile(\n resolvedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as { references?: unknown[] };\n const wrapperPayload = {\n extends: normalizePath(resolvedTsConfigPath),\n files: [...mergedRootNames].sort(),\n ...(rawTsconfig.references ? { references: rawTsconfig.references } : {}),\n };\n const wrapperHash = createHash('sha1')\n .update(JSON.stringify(wrapperPayload))\n .digest('hex')\n .slice(0, 12);\n const wrapperPath = join(\n wrapperDir,\n `tsconfig.includes.${wrapperHash}.json`,\n );\n\n mkdirSync(wrapperDir, { recursive: true });\n if (!existsSync(wrapperPath)) {\n writeFileSync(\n wrapperPath,\n `${JSON.stringify(wrapperPayload, null, 2)}\\n`,\n 'utf-8',\n );\n }\n\n debugCompilationApi('generated include wrapper tsconfig', {\n originalTsconfig: resolvedTsConfigPath,\n wrapperTsconfig: wrapperPath,\n includeCount: includedFiles.length,\n rootNameCount: mergedRootNames.length,\n });\n\n return wrapperPath;\n }\n\n const normalizeEmitterLookupId = (file: string) => {\n const normalizedFile = normalizePath(file);\n if (!normalizedFile.startsWith('/@fs/')) return normalizedFile;\n const fsPath = normalizedFile\n .slice('/@fs'.length)\n .replace(/^\\/([A-Za-z]:\\/)/, '$1');\n return normalizePath(fsPath);\n };\n\n let outputFile: ((file: string) => void) | undefined;\n const fileEmitter = (file: string) => {\n const normalizedFile = normalizeEmitterLookupId(file);\n outputFile?.(normalizedFile);\n return outputFiles.get(normalizedFile);\n };\n\n async function performAngularCompilation(\n config: ResolvedConfig,\n ids?: string[],\n ) {\n const compilation = (angularCompilation ??= await (\n createAngularCompilation as typeof createAngularCompilationType\n )(!!pluginOptions.jit, false));\n const modifiedFiles = ids?.length\n ? new Set(ids.map((file) => normalizePath(file)))\n : undefined;\n if (modifiedFiles?.size) {\n sourceFileCache.invalidate(modifiedFiles);\n }\n if (modifiedFiles?.size && compilation.update) {\n debugCompilationApi('incremental update', {\n files: [...modifiedFiles],\n });\n await compilation.update(modifiedFiles);\n }\n\n const resolvedTsConfigPath = resolveTsConfigPath();\n const compilationApiTsConfigPath = resolveCompilationApiTsConfigPath(\n resolvedTsConfigPath,\n config,\n );\n debugEmit('compilation initialize', {\n resolvedTsConfigPath,\n compilationApiTsConfigPath,\n modifiedFileCount: modifiedFiles?.size ?? 0,\n });\n const transformCompilerOptions = (\n tsCompilerOptions: Record<string, unknown>,\n ) => {\n if (shouldExternalizeStyles()) {\n tsCompilerOptions['externalRuntimeStyles'] = true;\n }\n\n if (shouldEnableLiveReload()) {\n tsCompilerOptions['_enableHmr'] = true;\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n debugCompiler('tsCompilerOptions (compilation API)', {\n liveReload: pluginOptions.liveReload,\n viteHmr: hasViteHmrTransport(),\n externalizeStylesRequested,\n watchMode,\n shouldExternalize: shouldExternalizeStyles(),\n externalRuntimeStyles: !!tsCompilerOptions['externalRuntimeStyles'],\n hmrEnabled: !!tsCompilerOptions['_enableHmr'],\n });\n\n if (tsCompilerOptions['compilationMode'] === 'partial') {\n tsCompilerOptions['supportTestBed'] = true;\n tsCompilerOptions['supportJitMode'] = true;\n }\n\n if (!isTest && resolvedConfig.build?.lib) {\n tsCompilerOptions['declaration'] = true;\n tsCompilerOptions['declarationMap'] = watchMode;\n tsCompilerOptions['inlineSources'] = true;\n }\n\n if (isTest) {\n tsCompilerOptions['supportTestBed'] = true;\n }\n\n return tsCompilerOptions;\n };\n const compilationResult = await compilation.initialize(\n compilationApiTsConfigPath,\n {\n fileReplacements: toAngularCompilationFileReplacements(\n pluginOptions.fileReplacements,\n pluginOptions.workspaceRoot,\n ),\n modifiedFiles,\n async transformStylesheet(\n data: string,\n containingFile: string,\n resourceFile: string | null,\n order: number,\n className: string | null,\n ) {\n // @angular/build >= 22.2.4 no longer reads external stylesheets in readResource\n if (resourceFile && !data) {\n data = readFileSync(resourceFile, 'utf-8');\n }\n\n const filename =\n resourceFile ??\n containingFile.replace(\n '.ts',\n `.${pluginOptions.inlineStylesExtension}`,\n );\n\n const preprocessed = preprocessStylesheetResult(\n data,\n filename,\n stylePreprocessor,\n {\n filename,\n containingFile,\n resourceFile,\n className,\n order,\n inline: !resourceFile,\n },\n );\n\n if (shouldEnableLiveReload() && className && containingFile) {\n classNames.set(normalizePath(containingFile), className as string);\n }\n\n if (shouldExternalizeStyles()) {\n const stylesheetId = registerStylesheetContent(\n stylesheetRegistry!,\n {\n code: preprocessed.code,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n containingFile,\n className: className as string | undefined,\n order,\n inlineStylesExtension: pluginOptions.inlineStylesExtension,\n resourceFile: resourceFile ?? undefined,\n },\n );\n\n debugStyles('stylesheet deferred to Vite pipeline', {\n stylesheetId,\n resourceFile: resourceFile ?? '(inline)',\n });\n\n return stylesheetId;\n }\n\n debugStyles('stylesheet processed inline via preprocessCSS', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n dataLength: preprocessed.code.length,\n });\n\n let stylesheetResult;\n try {\n stylesheetResult = await preprocessCSS(\n preprocessed.code,\n `${filename}?direct`,\n resolvedConfig,\n );\n } catch (e) {\n debugStyles('preprocessCSS error', {\n filename,\n resourceFile: resourceFile ?? '(inline)',\n error: String(e),\n });\n warnStylesheetError(resolvedConfig.logger, filename, e);\n }\n\n return stylesheetResult?.code || '';\n },\n processWebWorker(workerFile: string) {\n return workerFile;\n },\n },\n angularFullVersion >= 220200\n ? {\n enableHmr: shouldEnableLiveReload(),\n externalRuntimeStyles: shouldExternalizeStyles(),\n includeTestMetadata: isTest || shouldEnableLiveReload(),\n instrumentForCoverage: !isTest,\n }\n : (transformCompilerOptions as unknown as Parameters<\n typeof compilation.initialize\n >[2]),\n );\n\n // Preprocess external stylesheets for Tailwind CSS @reference\n debugStyles('external stylesheets from compilation API', {\n count: compilationResult.externalStylesheets?.size ?? 0,\n hasPreprocessor: !!stylePreprocessor,\n hasInlineMap: !!stylesheetRegistry,\n });\n const preprocessStats = { total: 0, injected: 0, skipped: 0, errors: 0 };\n for (const [key, value] of compilationResult.externalStylesheets ?? []) {\n preprocessStats.total++;\n const angularHash = `${value}.css`;\n stylesheetRegistry?.registerExternalRequest(angularHash, key);\n\n if (stylesheetRegistry && stylePreprocessor && existsSync(key)) {\n try {\n const rawCss = readFileSync(key, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n key,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(preprocessed.code, key);\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId: angularHash,\n sourcePath: key,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [key, normalizePath(key), basename(key), key.replace(/^\\//, '')],\n );\n\n if (servedCss && servedCss !== rawCss) {\n preprocessStats.injected++;\n } else {\n preprocessStats.skipped++;\n }\n } catch (e) {\n preprocessStats.errors++;\n console.warn(\n `[@analogjs/vite-plugin-angular] failed to preprocess external stylesheet: ${key}: ${e}`,\n );\n }\n } else {\n preprocessStats.skipped++;\n }\n }\n debugStyles('external stylesheet preprocessing complete', preprocessStats);\n\n const diagnostics = await compilation.diagnoseFiles(\n pluginOptions.disableTypeChecking\n ? DiagnosticModes.All & ~DiagnosticModes.Semantic\n : DiagnosticModes.All,\n );\n\n const errors = diagnostics.errors?.length ? diagnostics.errors : [];\n const warnings = diagnostics.warnings?.length ? diagnostics.warnings : [];\n\n const templateUpdates = mapTemplateUpdatesToFiles(\n compilationResult.templateUpdates,\n );\n if (templateUpdates.size > 0) {\n debugHmr('compilation API template updates', {\n count: templateUpdates.size,\n files: [...templateUpdates.keys()],\n });\n }\n\n const affectedFiles = await compilation.emitAffectedFiles();\n debugEmit('emitAffectedFiles summary', {\n count: affectedFiles.length,\n templateUpdateCount: templateUpdates.size,\n knownOutputCountBefore: outputFiles.size,\n });\n\n for (const file of affectedFiles) {\n const normalizedFilename = normalizePath(file.filename);\n const templateUpdate = templateUpdates.get(normalizedFilename);\n\n if (templateUpdate) {\n classNames.set(normalizedFilename, templateUpdate.className);\n }\n\n outputFiles.set(normalizedFilename, {\n content: file.contents,\n dependencies: [],\n errors: errors.map((error: { text?: string }) => error.text || ''),\n warnings: warnings.map(\n (warning: { text?: string }) => warning.text || '',\n ),\n hmrUpdateCode: templateUpdate?.code,\n hmrEligible: !!templateUpdate?.code,\n });\n }\n\n // Free the compilation before chunks render; `transform` still reads `outputFiles`.\n if (!watchMode && !isTest) {\n await compilation.close?.();\n angularCompilation = undefined;\n }\n }\n\n async function performCompilation(config: ResolvedConfig, ids?: string[]) {\n let resolve: (() => unknown) | undefined;\n const previousLock = compilationLock;\n compilationLock = new Promise<void>((r) => {\n resolve = r;\n });\n try {\n await previousLock;\n const integrations = await discoverAnalogIntegrations(config);\n stylePreprocessor = integrations.stylePreprocessor;\n transformFilter = integrations.transformFilter;\n tsconfigResolver.setIntegrationIncludes(integrations.include);\n externalizeStylesRequested = integrations.externalizeStyles;\n await performAngularCompilation(config, ids);\n } finally {\n resolve!();\n }\n }\n\n function isComponentStyleSheet(id: string): boolean {\n return id.includes('ngcomp=');\n }\n\n function getFilenameFromPath(id: string): string {\n try {\n return new URL(id, 'http://localhost').pathname.replace(/^\\//, '');\n } catch {\n const queryIndex = id.indexOf('?');\n const pathname = queryIndex >= 0 ? id.slice(0, queryIndex) : id;\n return pathname.replace(/^\\//, '');\n }\n }\n\n function sendHMRComponentUpdate(server: ViteDevServer, id: string) {\n debugHmrV('ws send: angular component update', {\n id,\n timestamp: Date.now(),\n });\n server.ws.send('angular:component-update', {\n id: encodeURIComponent(id),\n timestamp: Date.now(),\n });\n classNames.delete(id);\n }\n\n const compilerPlugin: Plugin = {\n name: '@analogjs/vite-plugin-angular-compilation-api',\n api: { getTsConfigPath: resolveTsConfigPath },\n enforce: 'pre' as const,\n async config(config, { command }) {\n activateDeferredDebug(command);\n watchMode = command === 'serve';\n const isProd =\n config.mode === 'production' ||\n process.env['NODE_ENV'] === 'production';\n\n tsConfigResolutionContext = {\n root: config.root || '.',\n isProd,\n isLib: !!config?.build?.lib,\n };\n\n debugCompilationApi('enabled (Angular %s)', angularFullVersion);\n\n // Angular Compilation API handles TypeScript transforms — disable\n // esbuild/oxc so they don't compete.\n debugCompilationApi('esbuild/oxc disabled, Angular handles transforms');\n\n // The compilation API owns user-source transforms, but deps\n // optimization still bundles partial-compiled Angular libs from\n // node_modules (`ɵɵngDeclareInjectable/Factory`). Without the\n // linker plugin, those declarations reach the browser unprocessed\n // and Angular tries to JIT-compile them at runtime. Mirror the\n // deps-optimizer wiring from `angular-vite-plugin.ts` so the\n // linker runs on `.[cm]?js` deps under both rolldown and esbuild.\n const useRolldown = isRolldown();\n const preliminaryTsConfigPath = resolveTsConfigPath();\n const compilerPluginOptions = {\n tsconfig: preliminaryTsConfigPath,\n sourcemap: !isProd,\n advancedOptimizations: isProd,\n jit: pluginOptions.jit,\n incremental: watchMode,\n };\n\n // No `resolve.conditions` extension here: the `style` condition is\n // scoped to `.css`-extension requests by\n // `cssExtensionStyleResolverPlugin`, registered once at the\n // `angularCompilationPlugin()` factory level. Adding `style` globally caused\n // Tailwind v4's JS plugin resolver to pick the `style` exports of\n // packages such as `tailwindcss-primeui`, which then crashed Node's\n // ESM loader when it tried to import the resulting `.css` file.\n return {\n esbuild: undefined,\n oxc: undefined,\n optimizeDeps: {\n include: ['rxjs/operators', 'rxjs', 'tslib'],\n exclude: ['@angular/platform-server'],\n ...(useRolldown\n ? {\n rolldownOptions: {\n plugins: [\n createRolldownCompilerPlugin(\n compilerPluginOptions,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }\n : {\n esbuildOptions: {\n plugins: [\n createCompilerPlugin(\n compilerPluginOptions,\n isTest,\n !pluginOptions.isAstroIntegration,\n ),\n ],\n },\n }),\n },\n };\n },\n async configResolved(config) {\n resolvedConfig = config;\n\n stylesheetRegistry = new AnalogStylesheetRegistry();\n const integrations = await discoverAnalogIntegrations(config);\n integrations.configureStylesheetRegistry?.(stylesheetRegistry, {\n workspaceRoot: pluginOptions.workspaceRoot,\n });\n debugStyles('stylesheet registry initialized (Angular Compilation API)');\n\n if (isTest) {\n const browser = (config as any).test?.browser;\n deferInitialCompilation =\n isVitestVscode ||\n (!!browser &&\n (getBrowserModeCliOverride() ?? browser.enabled) === true);\n\n testWatchMode =\n !(config.server.watch === null) ||\n (config as any).test?.watch === true ||\n testWatchMode;\n }\n },\n configureServer(server) {\n viteServer = server;\n hotUpdates.configureServer(server);\n\n const invalidateCompilation = async () => {\n tsconfigResolver.invalidateAll();\n await performCompilation(resolvedConfig);\n };\n server.watcher.on('add', invalidateCompilation);\n server.watcher.on('unlink', invalidateCompilation);\n server.watcher.on('change', (file) => {\n if (file.includes('tsconfig')) {\n tsconfigResolver.invalidateTsconfigCaches();\n }\n });\n },\n async buildStart() {\n if (!deferInitialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n await pendingCompilation;\n pendingCompilation = null;\n initialCompilation = true;\n }\n },\n async handleHotUpdate(ctx) {\n if (isIgnoredHmrFile(ctx.file)) {\n debugHmr('ignored file change', { file: ctx.file });\n return [];\n }\n\n if (TS_EXT_REGEX.test(ctx.file)) {\n const [fileId] = ctx.file.split('?');\n debugHmr('TS file changed', { file: ctx.file, fileId });\n\n await hotUpdates.schedule(ctx.file, [fileId]);\n\n let result;\n\n if (shouldEnableLiveReload()) {\n result = fileEmitter(fileId);\n debugHmr('TS file emitted', {\n fileId,\n hmrEligible: !!result?.hmrEligible,\n hasClassName: !!classNames.get(fileId),\n });\n }\n\n if (\n shouldEnableLiveReload() &&\n result?.hmrEligible &&\n classNames.get(fileId)\n ) {\n const relativeFileId = `${normalizePath(\n relative(process.cwd(), fileId),\n )}@${classNames.get(fileId)}`;\n\n debugHmr('sending component update', { relativeFileId });\n sendHMRComponentUpdate(ctx.server, relativeFileId);\n\n return ctx.modules.map((mod) => {\n if (mod.id === ctx.file) {\n mod.isSelfAccepting = true;\n }\n return mod;\n });\n }\n }\n\n if (/\\.(html|htm)$/.test(ctx.file)) {\n debugHmr('template file changed', { file: ctx.file });\n // Recompile to pick up template changes\n pendingCompilation = performCompilation(resolvedConfig);\n }\n\n if (/\\.(css|less|sass|scss)$/.test(ctx.file)) {\n debugHmr('stylesheet file changed', { file: ctx.file });\n refreshStylesheetRegistryForFile(\n ctx.file,\n stylesheetRegistry,\n stylePreprocessor,\n );\n }\n\n return ctx.modules;\n },\n resolveId(id) {\n // Map angular component stylesheets\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const search = new URL(id, 'http://localhost').search;\n const servedSourcePath =\n stylesheetRegistry?.getServedSourcePath(filename);\n\n if (servedSourcePath) {\n debugStylesV('resolveId: mapped served stylesheet to source', {\n filename,\n resolvedPath: servedSourcePath,\n });\n return servedSourcePath + search;\n }\n\n if (stylesheetRegistry?.hasServed(filename)) {\n return id;\n }\n\n const componentStyles =\n stylesheetRegistry?.resolveExternalSource(filename);\n if (componentStyles) {\n return componentStyles + new URL(id, 'http://localhost').search;\n }\n }\n\n return undefined;\n },\n async load(id) {\n // Virtual raw ids back JIT-emitted templateUrl/styleUrl imports.\n // virtual-modules-plugin resolves them; this plugin is the active\n // compilation plugin in compilation-API mode, so load must read the\n // backing file (jit=true is the test-mode default).\n const rawModule = await loadVirtualRawModule(this, id);\n if (rawModule !== undefined) return rawModule;\n\n // Serve component stylesheets from registry\n if (isComponentStyleSheet(id)) {\n const filename = getFilenameFromPath(id);\n const componentStyles = stylesheetRegistry?.getServedContent(filename);\n if (componentStyles) {\n stylesheetRegistry?.registerActiveRequest(id);\n return componentStyles;\n }\n }\n\n return;\n },\n transform: {\n filter: {\n id: {\n include: [TS_EXT_REGEX],\n exclude: [\n /node_modules/,\n 'type=script',\n '@ng/component',\n /[?&]raw\\b/,\n ],\n },\n },\n async handler(code, id) {\n if (/[?&]raw\\b/.test(id)) return;\n if (transformFilter && !transformFilter(code, id)) {\n return;\n }\n\n // Angular emits every file in the program, not only files with\n // Angular decorators, and `@analogjs/platform` excludes `.ts` from\n // Vite's own transform. So serve Angular's output for any emitted\n // file; only the \"not emitted\" warning below is decorator-specific.\n const isAngular =\n /(Component|Directive|Pipe|Injectable|NgModule)\\(/.test(code);\n\n if (id.includes('.ts?')) {\n id = id.replace(/\\?(.*)/, '');\n }\n\n if (isTest) {\n if (deferInitialCompilation && !initialCompilation) {\n pendingCompilation = performCompilation(resolvedConfig);\n initialCompilation = true;\n }\n\n const tsMod = viteServer?.moduleGraph.getModuleById(id);\n if (tsMod) {\n const invalidated = tsMod.lastInvalidationTimestamp;\n if (testWatchMode && invalidated) {\n pendingCompilation = performCompilation(resolvedConfig, [id]);\n }\n }\n }\n\n if (pendingCompilation) {\n await pendingCompilation;\n pendingCompilation = null;\n }\n await hotUpdates.wait();\n\n const typescriptResult = fileEmitter(id);\n if (!typescriptResult) {\n debugCompilationApi('transform skip (file not emitted)', { id });\n if (isAngular) {\n this.warn(\n `[@analogjs/vite-plugin-angular]: \"${id}\" contains Angular decorators but is not in the TypeScript program. ` +\n `Ensure it is included in your tsconfig.`,\n );\n }\n return;\n }\n\n if (typescriptResult.warnings && typescriptResult.warnings.length > 0) {\n this.warn(`${typescriptResult.warnings.join('\\n')}`);\n }\n\n if (typescriptResult.errors && typescriptResult.errors.length > 0) {\n this.error(`${typescriptResult.errors.join('\\n')}`);\n }\n\n let data = typescriptResult.content ?? '';\n\n // Re-inject @vite-ignore for Angular HMR dynamic imports\n if (data.includes('HmrLoad')) {\n const hasMetaUrl = data.includes('getReplaceMetadataURL');\n if (hasMetaUrl) {\n data = injectViteIgnoreForHmrMetadata(data);\n }\n }\n\n return {\n code: data,\n map: null,\n };\n },\n },\n async closeBundle() {\n hotUpdates.close();\n await compilationLock;\n await angularCompilation?.close?.();\n angularCompilation = undefined;\n outputFiles.clear();\n classNames.clear();\n sourceFileCache.clear();\n tsconfigResolver.invalidateAll();\n stylesheetRegistry = undefined;\n pendingCompilation = null;\n initialCompilation = false;\n },\n };\n\n return [\n cssExtensionStyleResolverPlugin(),\n replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot),\n virtualModulesPlugin({ jit: pluginOptions.jit }),\n compilerPlugin,\n pluginOptions.liveReload && liveReloadPlugin({ classNames, fileEmitter }),\n ...(isTest && !isStackBlitz\n ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map)\n : []),\n pluginOptions.jit &&\n jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),\n buildOptimizerPlugin({\n jit: pluginOptions.jit,\n }),\n routerPlugin(),\n nxFolderPlugin(),\n encapsulationPlugin(),\n ].filter(Boolean) as Plugin[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,IAAM,KADU,cAAc,YAAY,GAC/B,CAAA,CAAQ,YAAY;;;;;;AAuB/B,SAAgB,yBACd,UAA2C,CAAC,GAClC;CACV,IACE,qBAAqB,UACrB,OAAO,6BAA6B,YAEpC,MAAM,IAAI,MACR,2JACF;CAGF,iBAAiB,QAAQ,OAAO,QAAQ,aAAa;CACrD,MAAM,SAAA,QAAA,IAAA,aAAqC,UAAU,CAAC,CAAC,QAAQ,IAAI;CACnE,MAAM,eAAe,CAAC,CAAC,QAAQ,SAAS;CACxC,MAAM,gBAAgB;EACpB,gBAAgB,qBAAqB,QAAQ,QAAQ;EACrD,eACE,QAAQ,iBACR,QAAQ,IAAI,wBACZ,QAAQ,IAAI;EACd,uBAAuB,QAAQ,yBAAyB;EACxD,KAAK,QAAQ,OAAO;EACpB,YAAY,QAAQ,cAAc;EAClC,qBAAqB,QAAQ,uBAAuB;EACpD,mBAAmB,QAAQ,qBAAqB,CAAC,WAAW;EAC5D,kBAAkB,QAAQ,oBAAoB,CAAC;EAC/C,SAAS,QAAQ,WAAW,CAAC;EAC7B,oBAAoB,QAAQ,IAAI,oBAAoB;CACtD;CACA,IAAI;CACJ,IAAI,4BAA8D;CAClE,IAAI,YAAY;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,MAAM;GACjB,MAAM;GACN,MAAM,oBAAoB,QAAQ;GAClC,qBAAqB,KAAA;GACrB,YAAY,MAAM;GAClB,WAAW,MAAM;GACjB,gBAAgB,MAAM;GACtB,iBAAiB,cAAc;GAC/B,qBAAqB,KAAA;GACrB,qBAAqB;GACrB,qBAAqB;EACvB;CACF;CAEA,OAAO;EACL,gCAAgC;EAChC,aAAa,cAAc,kBAAkB,cAAc,aAAa;EACxE,qBAAqB,EAAE,KAAK,cAAc,IAAI,CAAC;EAC/C;EACA,cAAc,cAAc,iBAAiB;GAAE;GAAY;EAAY,CAAC;EACxE,GAAI,UAAU,CAAC,eACX,sBAAsB,OAAO,YAAY,IAAI,cAAc,EAAE,CAAC,CAAC,EAAE,GAAG,IACpE,CAAC;EACL,cAAc,OACZ,UAAU,EAAE,uBAAuB,cAAc,sBAAsB,CAAC;EAC1E,qBAAqB,EACnB,KAAK,cAAc,IACrB,CAAC;EACD,aAAa;EACb,eAAe;EACf,oBAAoB;CACtB,CAAC,CAAC,OAAO,OAAO;AAClB"}
|
|
@@ -8,6 +8,7 @@ import { collectStringConstants, detectFieldDecorators, detectSignals, extractCo
|
|
|
8
8
|
import { buildDeferDependencyMap } from "./defer.js";
|
|
9
9
|
import { buildCtorParameters, buildPropDecorators } from "./jit-metadata.js";
|
|
10
10
|
import { debugCompile } from "./debug.js";
|
|
11
|
+
import { inlineStyleRanges } from "./style-ast.js";
|
|
11
12
|
import * as fs from "node:fs";
|
|
12
13
|
import * as path$1 from "node:path";
|
|
13
14
|
import * as o from "@angular/compiler";
|
|
@@ -111,6 +112,7 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
111
112
|
const startTimeMs = debugCompile.enabled ? performance.now() : 0;
|
|
112
113
|
debugCompile("compile %s (mode=%s, registry=%d entries)", fileName, isPartial ? "partial" : "full", registry?.size ?? 0);
|
|
113
114
|
const oxcProgram = opts.oxcProgram ?? parseOxc(fileName, sourceCode).program;
|
|
115
|
+
const styleRanges = resolvedInlineStyles && inlineStyleRanges(oxcProgram);
|
|
114
116
|
const oxcClassMap = /* @__PURE__ */ new Map();
|
|
115
117
|
for (const stmt of oxcProgram.body) {
|
|
116
118
|
const decl = stmt.type === "ExportNamedDeclaration" || stmt.type === "ExportDefaultDeclaration" ? stmt.declaration : stmt;
|
|
@@ -125,6 +127,7 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
125
127
|
const typeOnlyImports = detectTypeOnlyImportNames(sourceCode, oxcProgram);
|
|
126
128
|
const importSpecifierByName = /* @__PURE__ */ new Map();
|
|
127
129
|
const importedNames = /* @__PURE__ */ new Set();
|
|
130
|
+
const typeOnlyImportedNames = /* @__PURE__ */ new Set();
|
|
128
131
|
for (const stmt of oxcProgram.body) {
|
|
129
132
|
if (stmt.type !== "ImportDeclaration") continue;
|
|
130
133
|
const moduleSpecifier = stmt.source.value;
|
|
@@ -132,9 +135,11 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
132
135
|
for (const element of stmt.specifiers) {
|
|
133
136
|
if (element.type !== "ImportSpecifier") continue;
|
|
134
137
|
const localName = element.local.name;
|
|
135
|
-
importedNames.add(localName);
|
|
136
138
|
importSpecifierByName.set(localName, moduleSpecifier);
|
|
137
|
-
if (isDeclarationTypeOnly || element.importKind === "type")
|
|
139
|
+
if (isDeclarationTypeOnly || element.importKind === "type") {
|
|
140
|
+
typeOnlyImports.add(localName);
|
|
141
|
+
typeOnlyImportedNames.add(localName);
|
|
142
|
+
} else importedNames.add(localName);
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
const localSelectors = /* @__PURE__ */ new Map();
|
|
@@ -150,6 +155,7 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
150
155
|
const classResults = [];
|
|
151
156
|
const topLevelClasses = new Set(oxcProgram.body.map((stmt) => toTopLevelStatement(stmt).decl));
|
|
152
157
|
const syntheticImports = /* @__PURE__ */ new Map();
|
|
158
|
+
const dependencyLocalName = (name) => typeOnlyImportedNames.has(name) ? `ɵngDep_${name}` : name;
|
|
153
159
|
for (const node of findAllClasses(oxcProgram)) {
|
|
154
160
|
const decorators = node.decorators;
|
|
155
161
|
if (!decorators || decorators.length === 0) continue;
|
|
@@ -217,7 +223,7 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
217
223
|
for (const memberName of expanded) {
|
|
218
224
|
const memberEntry = registry?.get(memberName);
|
|
219
225
|
if (!memberEntry || memberEntry.kind === "tuple") continue;
|
|
220
|
-
const memberRef = new o.WrappedNodeExpr(memberName);
|
|
226
|
+
const memberRef = new o.WrappedNodeExpr(dependencyLocalName(memberName));
|
|
221
227
|
if (!importedNames.has(memberName)) {
|
|
222
228
|
const memberSpecifier = resolveSyntheticImportSpecifier(fileName, memberEntry, tupleSpecifier);
|
|
223
229
|
if (memberSpecifier) syntheticImports.set(memberName, memberSpecifier);
|
|
@@ -258,7 +264,7 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
258
264
|
const exportedEntry = registry?.get(exportedName);
|
|
259
265
|
if (exportedEntry) {
|
|
260
266
|
const kind = exportedEntry.kind === "pipe" ? 1 : 0;
|
|
261
|
-
const exportedRef = new o.WrappedNodeExpr(exportedName);
|
|
267
|
+
const exportedRef = new o.WrappedNodeExpr(dependencyLocalName(exportedName));
|
|
262
268
|
const exportedSpecifier = resolveSyntheticImportSpecifier(fileName, exportedEntry, moduleSpecifier);
|
|
263
269
|
if (exportedSpecifier) syntheticImports.set(exportedName, exportedSpecifier);
|
|
264
270
|
const decl = {
|
|
@@ -337,7 +343,7 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
337
343
|
}
|
|
338
344
|
const kind = entry.kind === "pipe" ? 1 : 0;
|
|
339
345
|
const decl = {
|
|
340
|
-
type: new o.WrappedNodeExpr(name),
|
|
346
|
+
type: new o.WrappedNodeExpr(dependencyLocalName(name)),
|
|
341
347
|
selector: entry.selector || `_unresolved-${name}`,
|
|
342
348
|
kind,
|
|
343
349
|
...kind === 1 ? { name: entry.pipeName } : {}
|
|
@@ -365,8 +371,10 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
365
371
|
} catch {
|
|
366
372
|
console.warn(`[fast-compile] Could not read style file "${url}" for ${className}`);
|
|
367
373
|
}
|
|
368
|
-
|
|
369
|
-
|
|
374
|
+
const styleRange = styleRanges?.get(dec);
|
|
375
|
+
if (resolvedInlineStyles && styleRange) for (let k = 0; k < styleRange.count; k++) {
|
|
376
|
+
const css = resolvedInlineStyles.get(styleRange.start + k);
|
|
377
|
+
if (css !== void 0) meta.styles[k] = css;
|
|
370
378
|
}
|
|
371
379
|
resolvedResources.set(dec, {
|
|
372
380
|
template: templateContent || void 0,
|
|
@@ -715,9 +723,13 @@ function compile(sourceCode, fileName, optionsOrRegistry) {
|
|
|
715
723
|
}
|
|
716
724
|
const ms = new MagicString(sourceCode, { filename: fileName });
|
|
717
725
|
if (!sourceCode.includes("import * as i0 from")) ms.prepend("import * as i0 from \"@angular/core\";\n");
|
|
718
|
-
for (const [name, specifier] of syntheticImports)
|
|
719
|
-
|
|
720
|
-
importedNames.
|
|
726
|
+
for (const [name, specifier] of syntheticImports) {
|
|
727
|
+
const localName = dependencyLocalName(name);
|
|
728
|
+
if (!importedNames.has(localName)) {
|
|
729
|
+
const binding = localName === name ? name : `${name} as ${localName}`;
|
|
730
|
+
ms.prepend(`import { ${binding} } from "${specifier}";\n`);
|
|
731
|
+
importedNames.add(localName);
|
|
732
|
+
}
|
|
721
733
|
}
|
|
722
734
|
if (classResults.length > 0) {
|
|
723
735
|
const statements = oxcProgram.body.map(toTopLevelStatement);
|