@analogjs/vite-plugin-angular 3.0.0-alpha.99 → 3.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +13 -2
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/package.json +1 -14
- package/src/lib/analog-plugin-interop.js +1 -1
- package/src/lib/analog-plugin-interop.js.map +1 -1
- package/src/lib/angular-build-optimizer-plugin.js +1 -1
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.js +24 -8
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.js +1 -1
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.js +6 -5
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compilation-api/index.js +2 -1
- package/src/lib/compiler/angular-version.js +1 -1
- package/src/lib/compiler/angular-version.js.map +1 -1
- package/src/lib/compiler/class-field-lowering.js.map +1 -1
- package/src/lib/compiler/compile.js +27 -21
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/constants.js +4 -4
- package/src/lib/compiler/constants.js.map +1 -1
- package/src/lib/compiler/debug.js.map +1 -1
- package/src/lib/compiler/defer.js +1 -1
- package/src/lib/compiler/defer.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +5 -0
- package/src/lib/compiler/dts-reader.js +10 -4
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +7 -2
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +9 -8
- package/src/lib/compiler/jit-metadata.d.ts +3 -1
- package/src/lib/compiler/jit-metadata.js +10 -8
- package/src/lib/compiler/jit-metadata.js.map +1 -1
- package/src/lib/compiler/jit-transform.js +3 -5
- package/src/lib/compiler/jit-transform.js.map +1 -1
- package/src/lib/compiler/js-emitter.js +2 -4
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/compiler/metadata.js +10 -12
- package/src/lib/compiler/metadata.js.map +1 -1
- package/src/lib/compiler/registry.d.ts +6 -0
- package/src/lib/compiler/registry.js +21 -1
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.js.map +1 -1
- package/src/lib/compiler/type-elision.js +2 -2
- package/src/lib/compiler/type-elision.js.map +1 -1
- package/src/lib/compiler/utils.js +7 -5
- package/src/lib/compiler/utils.js.map +1 -1
- package/src/lib/compiler-plugin.js +7 -0
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/component-resolvers.js +1 -1
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/encapsulation-plugin.js +3 -2
- package/src/lib/encapsulation-plugin.js.map +1 -1
- package/src/lib/fast-compile-plugin.js +100 -17
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.js.map +1 -1
- package/src/lib/hot-update-batch.js +1 -1
- package/src/lib/hot-update-batch.js.map +1 -1
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-preprocessor.js.map +1 -1
- package/src/lib/stylesheet-registry.js.map +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +4 -2
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +2 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/utils/compilation-shared.js.map +1 -1
- package/src/lib/utils/css-extension-resolver.js.map +1 -1
- package/src/lib/utils/css-preprocessor-workers.js.map +1 -1
- package/src/lib/utils/debug-harness.js.map +1 -1
- package/src/lib/utils/debug-log-file.js +2 -1
- package/src/lib/utils/debug-log-file.js.map +1 -1
- package/src/lib/utils/debug.js.map +1 -1
- package/src/lib/utils/devkit.js +1 -1
- package/src/lib/utils/devkit.js.map +1 -1
- package/src/lib/utils/jit-inline-styles.js.map +1 -1
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/rolldown.js.map +1 -1
- package/src/lib/utils/safe-module-paths.js.map +1 -1
- package/src/lib/utils/transform-cache.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +2 -1
- package/src/lib/utils/tsconfig-resolver.js.map +1 -1
- package/src/lib/utils/virtual-ids.js.map +1 -1
- package/src/lib/utils/virtual-resources.js.map +1 -1
- package/src/lib/virtual-modules-plugin.js +4 -1
- package/src/lib/virtual-modules-plugin.js.map +1 -1
- package/migrations/migrations.json +0 -9
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +0 -2
- package/migrations/update-3-0-0/migrate-setup-vitest.js +0 -36
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-cache.js","names":[],"sources":["../../../../src/lib/utils/transform-cache.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\nimport { VERSION } from '@angular/compiler';\nimport { createDebug } from 'obug';\n\nconst debugCache = createDebug('analog-transform-cache');\n\n/**\n * The `{ get, put }` shape `@angular/build`'s `JavaScriptTransformer`\n * accepts. Keys are content hashes the\n * transformer derives from the file bytes plus every option that affects\n * output, so entries are immutable and never need invalidation — but the\n * digest does NOT cover the linker version, so stores must be namespaced\n * by Angular version (see {@link resolveTransformCacheDir}).\n */\nexport interface TransformCacheStore {\n get(key: string): Promise<Uint8Array | undefined> | Uint8Array | undefined;\n put(key: string, value: Uint8Array): Promise<void> | void;\n}\n\ninterface TransformCacheStats {\n hits: number;\n misses: number;\n writes: number;\n /** Approximate total ms spent in the linker worker for cache misses. */\n workerMs: number;\n}\n\n/**\n * Disk-backed content-addressed store for linked/transformed dependency\n * output. Entries are written atomically (temp + rename) so concurrent\n * dev servers can share a directory; all failures degrade to a miss.\n */\nexport function createPersistentTransformCache(\n baseDir: string,\n): TransformCacheStore & { stats: TransformCacheStats } {\n const stats: TransformCacheStats = {\n hits: 0,\n misses: 0,\n writes: 0,\n workerMs: 0,\n };\n // Miss timestamps by key: with the transformer's serialized worker, the\n // gap between a missed get and its put approximates linker time per file.\n const missedAt = new Map<string, number>();\n\n const entryPath = (key: string) => path.join(baseDir, key.slice(0, 2), key);\n\n return {\n stats,\n async get(key: string): Promise<Uint8Array | undefined> {\n try {\n const value = await fs.promises.readFile(entryPath(key));\n stats.hits++;\n debugCache('hit %s (hits=%d misses=%d)', key, stats.hits, stats.misses);\n return value;\n } catch {\n stats.misses++;\n missedAt.set(key, performance.now());\n debugCache(\n 'miss %s (hits=%d misses=%d)',\n key,\n stats.hits,\n stats.misses,\n );\n return undefined;\n }\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n const startedAt = missedAt.get(key);\n if (startedAt !== undefined) {\n missedAt.delete(key);\n stats.workerMs += performance.now() - startedAt;\n }\n try {\n const file = entryPath(key);\n await fs.promises.mkdir(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;\n await fs.promises.writeFile(tmp, value);\n await fs.promises.rename(tmp, file);\n stats.writes++;\n debugCache(\n 'put %s (writes=%d workerMs=%d)',\n key,\n stats.writes,\n Math.round(stats.workerMs),\n );\n } catch (e) {\n debugCache('put failed %s: %s', key, (e as Error)?.message);\n }\n },\n };\n}\n\n/**\n * Layer an unbounded in-memory map over a persistent store so repeat\n * transforms in the same session never touch the disk.\n */\nexport function withMemoryLayer(\n store: TransformCacheStore,\n): TransformCacheStore {\n const memory = new Map<string, Uint8Array>();\n return {\n async get(key: string): Promise<Uint8Array | undefined> {\n const cached = memory.get(key) ?? (await store.get(key));\n if (cached) memory.set(key, cached);\n return cached;\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n memory.set(key, value);\n await store.put(key, value);\n },\n };\n}\n\n/**\n * Resolve the shared on-disk cache directory: `node_modules/.cache` at the\n * nearest `node_modules` above `startDir` — the conventional tool-cache\n * location, so installs and `node_modules` cleans evict it without a\n * separate eviction pass. Namespaced by the installed Angular version\n * because the transformer's cache key does not cover the linker version.\n * Returns `null` (caching disabled) when no `node_modules` exists or the\n * `ANALOG_TRANSFORM_CACHE=0` kill switch is set.\n */\nexport function resolveTransformCacheDir(startDir: string): string | null {\n if (process.env['ANALOG_TRANSFORM_CACHE'] === '0') return null;\n let dir = path.resolve(startDir);\n for (;;) {\n if (fs.existsSync(path.join(dir, 'node_modules'))) {\n return path.join(\n dir,\n 'node_modules',\n '.cache',\n 'analog',\n 'transform-cache',\n VERSION.full,\n );\n }\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,YAAY,
|
|
1
|
+
{"version":3,"file":"transform-cache.js","names":[],"sources":["../../../../src/lib/utils/transform-cache.ts"],"sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as crypto from 'node:crypto';\nimport { VERSION } from '@angular/compiler';\nimport { createDebug } from 'obug';\n\nconst debugCache = createDebug('analog-transform-cache');\n\n/**\n * The `{ get, put }` shape `@angular/build`'s `JavaScriptTransformer`\n * accepts. Keys are content hashes the\n * transformer derives from the file bytes plus every option that affects\n * output, so entries are immutable and never need invalidation — but the\n * digest does NOT cover the linker version, so stores must be namespaced\n * by Angular version (see {@link resolveTransformCacheDir}).\n */\nexport interface TransformCacheStore {\n get(key: string): Promise<Uint8Array | undefined> | Uint8Array | undefined;\n put(key: string, value: Uint8Array): Promise<void> | void;\n}\n\ninterface TransformCacheStats {\n hits: number;\n misses: number;\n writes: number;\n /** Approximate total ms spent in the linker worker for cache misses. */\n workerMs: number;\n}\n\n/**\n * Disk-backed content-addressed store for linked/transformed dependency\n * output. Entries are written atomically (temp + rename) so concurrent\n * dev servers can share a directory; all failures degrade to a miss.\n */\nexport function createPersistentTransformCache(\n baseDir: string,\n): TransformCacheStore & { stats: TransformCacheStats } {\n const stats: TransformCacheStats = {\n hits: 0,\n misses: 0,\n writes: 0,\n workerMs: 0,\n };\n // Miss timestamps by key: with the transformer's serialized worker, the\n // gap between a missed get and its put approximates linker time per file.\n const missedAt = new Map<string, number>();\n\n const entryPath = (key: string) => path.join(baseDir, key.slice(0, 2), key);\n\n return {\n stats,\n async get(key: string): Promise<Uint8Array | undefined> {\n try {\n const value = await fs.promises.readFile(entryPath(key));\n stats.hits++;\n debugCache('hit %s (hits=%d misses=%d)', key, stats.hits, stats.misses);\n return value;\n } catch {\n stats.misses++;\n missedAt.set(key, performance.now());\n debugCache(\n 'miss %s (hits=%d misses=%d)',\n key,\n stats.hits,\n stats.misses,\n );\n return undefined;\n }\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n const startedAt = missedAt.get(key);\n if (startedAt !== undefined) {\n missedAt.delete(key);\n stats.workerMs += performance.now() - startedAt;\n }\n try {\n const file = entryPath(key);\n await fs.promises.mkdir(path.dirname(file), { recursive: true });\n const tmp = `${file}.${process.pid}.${crypto.randomBytes(4).toString('hex')}`;\n await fs.promises.writeFile(tmp, value);\n await fs.promises.rename(tmp, file);\n stats.writes++;\n debugCache(\n 'put %s (writes=%d workerMs=%d)',\n key,\n stats.writes,\n Math.round(stats.workerMs),\n );\n } catch (e) {\n debugCache('put failed %s: %s', key, (e as Error)?.message);\n }\n },\n };\n}\n\n/**\n * Layer an unbounded in-memory map over a persistent store so repeat\n * transforms in the same session never touch the disk.\n */\nexport function withMemoryLayer(\n store: TransformCacheStore,\n): TransformCacheStore {\n const memory = new Map<string, Uint8Array>();\n return {\n async get(key: string): Promise<Uint8Array | undefined> {\n const cached = memory.get(key) ?? (await store.get(key));\n if (cached) memory.set(key, cached);\n return cached;\n },\n async put(key: string, value: Uint8Array): Promise<void> {\n memory.set(key, value);\n await store.put(key, value);\n },\n };\n}\n\n/**\n * Resolve the shared on-disk cache directory: `node_modules/.cache` at the\n * nearest `node_modules` above `startDir` — the conventional tool-cache\n * location, so installs and `node_modules` cleans evict it without a\n * separate eviction pass. Namespaced by the installed Angular version\n * because the transformer's cache key does not cover the linker version.\n * Returns `null` (caching disabled) when no `node_modules` exists or the\n * `ANALOG_TRANSFORM_CACHE=0` kill switch is set.\n */\nexport function resolveTransformCacheDir(startDir: string): string | null {\n if (process.env['ANALOG_TRANSFORM_CACHE'] === '0') return null;\n let dir = path.resolve(startDir);\n for (;;) {\n if (fs.existsSync(path.join(dir, 'node_modules'))) {\n return path.join(\n dir,\n 'node_modules',\n '.cache',\n 'analog',\n 'transform-cache',\n VERSION.full,\n );\n }\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n"],"mappings":";;;;;;AAMA,IAAM,aAAa,YAAY,wBAAwB;;;;;;AA4BvD,SAAgB,+BACd,SACsD;CACtD,MAAM,QAA6B;EACjC,MAAM;EACN,QAAQ;EACR,QAAQ;EACR,UAAU;CACZ;CAGA,MAAM,2BAAW,IAAI,IAAoB;CAEzC,MAAM,aAAa,QAAgB,OAAK,KAAK,SAAS,IAAI,MAAM,GAAG,CAAC,GAAG,GAAG;CAE1E,OAAO;EACL;EACA,MAAM,IAAI,KAA8C;GACtD,IAAI;IACF,MAAM,QAAQ,MAAM,GAAG,SAAS,SAAS,UAAU,GAAG,CAAC;IACvD,MAAM;IACN,WAAW,8BAA8B,KAAK,MAAM,MAAM,MAAM,MAAM;IACtE,OAAO;GACT,QAAQ;IACN,MAAM;IACN,SAAS,IAAI,KAAK,YAAY,IAAI,CAAC;IACnC,WACE,+BACA,KACA,MAAM,MACN,MAAM,MACR;IACA;GACF;EACF;EACA,MAAM,IAAI,KAAa,OAA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AAI,WAAW,KAAK,OAAO;EAC3B,MAAM;CACR;AACF"}
|
|
@@ -14,6 +14,7 @@ import { globSync } from "tinyglobby";
|
|
|
14
14
|
*/
|
|
15
15
|
var ts = createRequire(import.meta.url)("typescript");
|
|
16
16
|
var TsconfigResolver = class {
|
|
17
|
+
options;
|
|
17
18
|
includeCache = [];
|
|
18
19
|
tsconfigOptionsCache = /* @__PURE__ */ new Map();
|
|
19
20
|
tsconfigGraphRootCache = /* @__PURE__ */ new Map();
|
|
@@ -200,6 +201,6 @@ function collectTsconfigPathRoots(resolvedTsConfigPath, options, rawTsconfig) {
|
|
|
200
201
|
return [...discoveredRoots];
|
|
201
202
|
}
|
|
202
203
|
//#endregion
|
|
203
|
-
export { TsconfigResolver };
|
|
204
|
+
export { TsconfigResolver, normalizeIncludeGlob };
|
|
204
205
|
|
|
205
206
|
//# sourceMappingURL=tsconfig-resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsconfig-resolver.js","names":[],"sources":["../../../../src/lib/utils/tsconfig-resolver.ts"],"sourcesContent":["/**\n * Shared tsconfig resolution logic used by both the ngtsc and compilation-api\n * compilation plugins. Encapsulates the caching, include-glob discovery,\n * tsconfig-graph expansion, and path-root resolution that were previously\n * duplicated across angular-vite-plugin.ts and compilation-api-plugin.ts.\n */\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport { normalizePath, ResolvedConfig } from 'vite';\nimport { globSync } from 'tinyglobby';\nimport { debugEmit, debugEmitV } from './debug.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface TsconfigResolverOptions {\n workspaceRoot: string;\n include: string[];\n liveReload: boolean;\n isTest: boolean;\n}\n\nexport class TsconfigResolver {\n private includeCache: string[] = [];\n private tsconfigOptionsCache = new Map<\n string,\n { options: any; rootNames: string[] }\n >();\n private tsconfigGraphRootCache = new Map<string, string[]>();\n private integrationIncludes: string[] = [];\n\n constructor(private options: TsconfigResolverOptions) {}\n\n /**\n * Replaces the include globs contributed by Vite plugins through\n * `analog.setup()`. Invalidates the include cache when the set changes.\n */\n setIntegrationIncludes(globs: string[]): void {\n if (\n globs.length === this.integrationIncludes.length &&\n globs.every((glob, index) => glob === this.integrationIncludes[index])\n ) {\n return;\n }\n this.integrationIncludes = [...globs];\n this.invalidateIncludeCache();\n }\n\n private get includeGlobs(): string[] {\n return [...this.options.include, ...this.integrationIncludes];\n }\n\n invalidateIncludeCache(): void {\n this.includeCache = [];\n }\n\n invalidateTsconfigCaches(): void {\n this.tsconfigOptionsCache.clear();\n this.tsconfigGraphRootCache.clear();\n }\n\n invalidateAll(): void {\n this.invalidateIncludeCache();\n this.invalidateTsconfigCaches();\n }\n\n ensureIncludeCache(): string[] {\n if (this.includeGlobs.length > 0 && this.includeCache.length === 0) {\n this.includeCache = this.findIncludes();\n debugEmit('include cache populated', {\n fileCount: this.includeCache.length,\n });\n }\n return this.includeCache;\n }\n\n readAngularTsconfigConfiguration(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ) {\n const isProd = config.mode === 'production';\n const emitSourceMaps = !isProd || !!config.build?.sourcemap;\n return compilerCli.readConfiguration(resolvedTsConfigPath, {\n suppressOutputPathCheck: true,\n outDir: undefined,\n sourceMap: emitSourceMaps,\n inlineSourceMap: false,\n inlineSources: emitSourceMaps,\n declaration: false,\n declarationMap: false,\n allowEmptyCodegenFiles: false,\n annotationsAs: 'decorators',\n enableResourceInlining: false,\n noEmitOnError: false,\n mapRoot: '',\n sourceRoot: '',\n supportTestBed: false,\n supportJitMode: false,\n });\n }\n\n getCachedTsconfigOptions(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): { options: any; rootNames: string[] } {\n const tsconfigKey = this.getTsconfigCacheKey(resolvedTsConfigPath, config);\n let cached = this.tsconfigOptionsCache.get(tsconfigKey);\n\n if (!cached) {\n const read = this.readAngularTsconfigConfiguration(\n resolvedTsConfigPath,\n config,\n );\n cached = { options: read.options, rootNames: read.rootNames };\n this.tsconfigOptionsCache.set(tsconfigKey, cached);\n debugEmit('tsconfig root names loaded', {\n resolvedTsConfigPath,\n rootNameCount: read.rootNames.length,\n });\n debugEmitV('tsconfig root names', {\n resolvedTsConfigPath,\n rootNames: read.rootNames.map((file: string) => normalizePath(file)),\n });\n }\n\n return cached;\n }\n\n collectExpandedTsconfigRoots(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n visited = new Set<string>(),\n ): string[] {\n const normalizedTsConfigPath = normalizePath(resolvedTsConfigPath);\n if (visited.has(normalizedTsConfigPath)) {\n return [];\n }\n\n const tsconfigKey = `${this.getTsconfigCacheKey(normalizedTsConfigPath, config)}|graph`;\n const cached = this.tsconfigGraphRootCache.get(tsconfigKey);\n if (cached) {\n return cached;\n }\n\n visited.add(normalizedTsConfigPath);\n\n const read = this.readAngularTsconfigConfiguration(\n normalizedTsConfigPath,\n config,\n );\n const rawTsconfig = (ts.readConfigFile(\n normalizedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n references?: Array<{ path?: unknown }>;\n };\n\n const expandedRoots = new Set(\n read.rootNames.map((file: string) => normalizePath(file)),\n );\n const pathRoots = collectTsconfigPathRoots(\n normalizedTsConfigPath,\n read.options,\n rawTsconfig,\n );\n for (const pathRoot of pathRoots) {\n expandedRoots.add(pathRoot);\n }\n\n const referenceConfigs = (rawTsconfig.references ?? [])\n .flatMap((reference) =>\n typeof reference.path === 'string'\n ? [\n resolveReferenceTsconfigPath(\n reference.path,\n normalizedTsConfigPath,\n ),\n ]\n : [],\n )\n .filter((reference): reference is string => !!reference);\n\n for (const referenceConfig of referenceConfigs) {\n for (const referenceRoot of this.collectExpandedTsconfigRoots(\n referenceConfig,\n config,\n visited,\n )) {\n expandedRoots.add(referenceRoot);\n }\n }\n\n const expandedRootList = [...expandedRoots];\n this.tsconfigGraphRootCache.set(tsconfigKey, expandedRootList);\n debugEmit('expanded tsconfig graph roots', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n directRootNameCount: read.rootNames.length,\n pathRootCount: pathRoots.length,\n referenceConfigCount: referenceConfigs.length,\n expandedRootCount: expandedRootList.length,\n });\n debugEmitV('expanded tsconfig graph root files', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n pathRoots,\n referenceConfigs,\n rootNames: expandedRootList,\n });\n\n return expandedRootList;\n }\n\n private getTsconfigCacheKey(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const isProd = config.mode === 'production';\n return [\n resolvedTsConfigPath,\n isProd ? 'prod' : 'dev',\n this.options.isTest ? 'test' : 'app',\n config.build?.lib ? 'lib' : 'nolib',\n !isProd || config.build?.sourcemap ? 'maps' : 'nomaps',\n this.options.liveReload ? 'live-reload' : 'no-live-reload',\n ].join('|');\n }\n\n private findIncludes(): string[] {\n const globs = this.includeGlobs.map((glob) =>\n normalizeIncludeGlob(this.options.workspaceRoot, glob),\n );\n const files = globSync(globs, { dot: true, absolute: true });\n debugEmit('include discovery', {\n patternCount: globs.length,\n fileCount: files.length,\n });\n debugEmitV('include discovery files', {\n globs,\n files: files.map((file) => normalizePath(file)),\n });\n return files;\n }\n}\n\nexport function normalizeIncludeGlob(\n workspaceRoot: string,\n glob: string,\n): string {\n const normalizedWorkspaceRoot = normalizePath(resolve(workspaceRoot));\n const normalizedGlob = normalizePath(glob);\n\n if (\n normalizedGlob === normalizedWorkspaceRoot ||\n normalizedGlob.startsWith(`${normalizedWorkspaceRoot}/`)\n ) {\n return normalizedGlob;\n }\n\n if (normalizedGlob.startsWith('/')) {\n return `${normalizedWorkspaceRoot}${normalizedGlob}`;\n }\n\n return normalizePath(resolve(normalizedWorkspaceRoot, normalizedGlob));\n}\n\nfunction resolveReferenceTsconfigPath(\n referencePath: string,\n ownerTsconfigPath: string,\n): string | undefined {\n const ownerDir = dirname(ownerTsconfigPath);\n const resolvedReference = normalizePath(\n isAbsolute(referencePath)\n ? referencePath\n : resolve(ownerDir, referencePath),\n );\n\n if (existsSync(resolvedReference)) {\n try {\n if (statSync(resolvedReference).isDirectory()) {\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n return existsSync(nestedTsconfig)\n ? normalizePath(nestedTsconfig)\n : undefined;\n }\n } catch {\n return undefined;\n }\n return resolvedReference;\n }\n\n if (!resolvedReference.endsWith('.json')) {\n const asJson = `${resolvedReference}.json`;\n if (existsSync(asJson)) {\n return normalizePath(asJson);\n }\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n if (existsSync(nestedTsconfig)) {\n return normalizePath(nestedTsconfig);\n }\n }\n\n return undefined;\n}\n\nfunction collectTsconfigPathRoots(\n resolvedTsConfigPath: string,\n options: any,\n rawTsconfig: {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n },\n): string[] {\n const tsPaths = rawTsconfig.compilerOptions?.paths ?? options.paths;\n if (!tsPaths) {\n return [];\n }\n\n const tsconfigDir = dirname(resolvedTsConfigPath);\n const configuredBaseUrl =\n typeof options.baseUrl === 'string'\n ? options.baseUrl\n : typeof rawTsconfig.compilerOptions?.baseUrl === 'string'\n ? rawTsconfig.compilerOptions.baseUrl\n : undefined;\n const resolvedBaseUrl = configuredBaseUrl\n ? isAbsolute(configuredBaseUrl)\n ? configuredBaseUrl\n : resolve(tsconfigDir, configuredBaseUrl)\n : tsconfigDir;\n const discoveredRoots = new Set<string>();\n\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n const resolvedTarget = normalizePath(\n isAbsolute(target) ? target : resolve(resolvedBaseUrl, target),\n );\n\n if (target.includes('*')) {\n for (const match of globSync(resolvedTarget, {\n dot: true,\n absolute: true,\n })) {\n discoveredRoots.add(normalizePath(match));\n }\n continue;\n }\n\n if (existsSync(resolvedTarget)) {\n discoveredRoots.add(resolvedTarget);\n }\n }\n }\n\n return [...disc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AC,CACA,iBAAgB,IAAI,cAAc,MAAM,CAAC;AAE3C;;AAGF,MAAI,WAAW,eAAe,CAC5B,iBAAgB,IAAI,eAAe;;AAKzC,QAAO,CAAC,GAAG,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"tsconfig-resolver.js","names":[],"sources":["../../../../src/lib/utils/tsconfig-resolver.ts"],"sourcesContent":["/**\n * Shared tsconfig resolution logic used by both the ngtsc and compilation-api\n * compilation plugins. Encapsulates the caching, include-glob discovery,\n * tsconfig-graph expansion, and path-root resolution that were previously\n * duplicated across angular-vite-plugin.ts and compilation-api-plugin.ts.\n */\n\nimport * as compilerCli from '@angular/compiler-cli';\nimport { existsSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, join, resolve } from 'node:path';\nimport { createRequire } from 'node:module';\nimport { normalizePath, ResolvedConfig } from 'vite';\nimport { globSync } from 'tinyglobby';\nimport { debugEmit, debugEmitV } from './debug.js';\n\nconst require = createRequire(import.meta.url);\nconst ts = require('typescript');\n\nexport interface TsconfigResolverOptions {\n workspaceRoot: string;\n include: string[];\n liveReload: boolean;\n isTest: boolean;\n}\n\nexport class TsconfigResolver {\n private includeCache: string[] = [];\n private tsconfigOptionsCache = new Map<\n string,\n { options: any; rootNames: string[] }\n >();\n private tsconfigGraphRootCache = new Map<string, string[]>();\n private integrationIncludes: string[] = [];\n\n constructor(private options: TsconfigResolverOptions) {}\n\n /**\n * Replaces the include globs contributed by Vite plugins through\n * `analog.setup()`. Invalidates the include cache when the set changes.\n */\n setIntegrationIncludes(globs: string[]): void {\n if (\n globs.length === this.integrationIncludes.length &&\n globs.every((glob, index) => glob === this.integrationIncludes[index])\n ) {\n return;\n }\n this.integrationIncludes = [...globs];\n this.invalidateIncludeCache();\n }\n\n private get includeGlobs(): string[] {\n return [...this.options.include, ...this.integrationIncludes];\n }\n\n invalidateIncludeCache(): void {\n this.includeCache = [];\n }\n\n invalidateTsconfigCaches(): void {\n this.tsconfigOptionsCache.clear();\n this.tsconfigGraphRootCache.clear();\n }\n\n invalidateAll(): void {\n this.invalidateIncludeCache();\n this.invalidateTsconfigCaches();\n }\n\n ensureIncludeCache(): string[] {\n if (this.includeGlobs.length > 0 && this.includeCache.length === 0) {\n this.includeCache = this.findIncludes();\n debugEmit('include cache populated', {\n fileCount: this.includeCache.length,\n });\n }\n return this.includeCache;\n }\n\n readAngularTsconfigConfiguration(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ) {\n const isProd = config.mode === 'production';\n const emitSourceMaps = !isProd || !!config.build?.sourcemap;\n return compilerCli.readConfiguration(resolvedTsConfigPath, {\n suppressOutputPathCheck: true,\n outDir: undefined,\n sourceMap: emitSourceMaps,\n inlineSourceMap: false,\n inlineSources: emitSourceMaps,\n declaration: false,\n declarationMap: false,\n allowEmptyCodegenFiles: false,\n annotationsAs: 'decorators',\n enableResourceInlining: false,\n noEmitOnError: false,\n mapRoot: '',\n sourceRoot: '',\n supportTestBed: false,\n supportJitMode: false,\n });\n }\n\n getCachedTsconfigOptions(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): { options: any; rootNames: string[] } {\n const tsconfigKey = this.getTsconfigCacheKey(resolvedTsConfigPath, config);\n let cached = this.tsconfigOptionsCache.get(tsconfigKey);\n\n if (!cached) {\n const read = this.readAngularTsconfigConfiguration(\n resolvedTsConfigPath,\n config,\n );\n cached = { options: read.options, rootNames: read.rootNames };\n this.tsconfigOptionsCache.set(tsconfigKey, cached);\n debugEmit('tsconfig root names loaded', {\n resolvedTsConfigPath,\n rootNameCount: read.rootNames.length,\n });\n debugEmitV('tsconfig root names', {\n resolvedTsConfigPath,\n rootNames: read.rootNames.map((file: string) => normalizePath(file)),\n });\n }\n\n return cached;\n }\n\n collectExpandedTsconfigRoots(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n visited = new Set<string>(),\n ): string[] {\n const normalizedTsConfigPath = normalizePath(resolvedTsConfigPath);\n if (visited.has(normalizedTsConfigPath)) {\n return [];\n }\n\n const tsconfigKey = `${this.getTsconfigCacheKey(normalizedTsConfigPath, config)}|graph`;\n const cached = this.tsconfigGraphRootCache.get(tsconfigKey);\n if (cached) {\n return cached;\n }\n\n visited.add(normalizedTsConfigPath);\n\n const read = this.readAngularTsconfigConfiguration(\n normalizedTsConfigPath,\n config,\n );\n const rawTsconfig = (ts.readConfigFile(\n normalizedTsConfigPath,\n ts.sys.readFile,\n ).config ?? {}) as {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n references?: Array<{ path?: unknown }>;\n };\n\n const expandedRoots = new Set(\n read.rootNames.map((file: string) => normalizePath(file)),\n );\n const pathRoots = collectTsconfigPathRoots(\n normalizedTsConfigPath,\n read.options,\n rawTsconfig,\n );\n for (const pathRoot of pathRoots) {\n expandedRoots.add(pathRoot);\n }\n\n const referenceConfigs = (rawTsconfig.references ?? [])\n .flatMap((reference) =>\n typeof reference.path === 'string'\n ? [\n resolveReferenceTsconfigPath(\n reference.path,\n normalizedTsConfigPath,\n ),\n ]\n : [],\n )\n .filter((reference): reference is string => !!reference);\n\n for (const referenceConfig of referenceConfigs) {\n for (const referenceRoot of this.collectExpandedTsconfigRoots(\n referenceConfig,\n config,\n visited,\n )) {\n expandedRoots.add(referenceRoot);\n }\n }\n\n const expandedRootList = [...expandedRoots];\n this.tsconfigGraphRootCache.set(tsconfigKey, expandedRootList);\n debugEmit('expanded tsconfig graph roots', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n directRootNameCount: read.rootNames.length,\n pathRootCount: pathRoots.length,\n referenceConfigCount: referenceConfigs.length,\n expandedRootCount: expandedRootList.length,\n });\n debugEmitV('expanded tsconfig graph root files', {\n resolvedTsConfigPath: normalizedTsConfigPath,\n pathRoots,\n referenceConfigs,\n rootNames: expandedRootList,\n });\n\n return expandedRootList;\n }\n\n private getTsconfigCacheKey(\n resolvedTsConfigPath: string,\n config: ResolvedConfig,\n ): string {\n const isProd = config.mode === 'production';\n return [\n resolvedTsConfigPath,\n isProd ? 'prod' : 'dev',\n this.options.isTest ? 'test' : 'app',\n config.build?.lib ? 'lib' : 'nolib',\n !isProd || config.build?.sourcemap ? 'maps' : 'nomaps',\n this.options.liveReload ? 'live-reload' : 'no-live-reload',\n ].join('|');\n }\n\n private findIncludes(): string[] {\n const globs = this.includeGlobs.map((glob) =>\n normalizeIncludeGlob(this.options.workspaceRoot, glob),\n );\n const files = globSync(globs, { dot: true, absolute: true });\n debugEmit('include discovery', {\n patternCount: globs.length,\n fileCount: files.length,\n });\n debugEmitV('include discovery files', {\n globs,\n files: files.map((file) => normalizePath(file)),\n });\n return files;\n }\n}\n\nexport function normalizeIncludeGlob(\n workspaceRoot: string,\n glob: string,\n): string {\n const normalizedWorkspaceRoot = normalizePath(resolve(workspaceRoot));\n const normalizedGlob = normalizePath(glob);\n\n if (\n normalizedGlob === normalizedWorkspaceRoot ||\n normalizedGlob.startsWith(`${normalizedWorkspaceRoot}/`)\n ) {\n return normalizedGlob;\n }\n\n if (normalizedGlob.startsWith('/')) {\n return `${normalizedWorkspaceRoot}${normalizedGlob}`;\n }\n\n return normalizePath(resolve(normalizedWorkspaceRoot, normalizedGlob));\n}\n\nfunction resolveReferenceTsconfigPath(\n referencePath: string,\n ownerTsconfigPath: string,\n): string | undefined {\n const ownerDir = dirname(ownerTsconfigPath);\n const resolvedReference = normalizePath(\n isAbsolute(referencePath)\n ? referencePath\n : resolve(ownerDir, referencePath),\n );\n\n if (existsSync(resolvedReference)) {\n try {\n if (statSync(resolvedReference).isDirectory()) {\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n return existsSync(nestedTsconfig)\n ? normalizePath(nestedTsconfig)\n : undefined;\n }\n } catch {\n return undefined;\n }\n return resolvedReference;\n }\n\n if (!resolvedReference.endsWith('.json')) {\n const asJson = `${resolvedReference}.json`;\n if (existsSync(asJson)) {\n return normalizePath(asJson);\n }\n const nestedTsconfig = join(resolvedReference, 'tsconfig.json');\n if (existsSync(nestedTsconfig)) {\n return normalizePath(nestedTsconfig);\n }\n }\n\n return undefined;\n}\n\nfunction collectTsconfigPathRoots(\n resolvedTsConfigPath: string,\n options: any,\n rawTsconfig: {\n compilerOptions?: {\n baseUrl?: unknown;\n paths?: Record<string, string[]>;\n };\n },\n): string[] {\n const tsPaths = rawTsconfig.compilerOptions?.paths ?? options.paths;\n if (!tsPaths) {\n return [];\n }\n\n const tsconfigDir = dirname(resolvedTsConfigPath);\n const configuredBaseUrl =\n typeof options.baseUrl === 'string'\n ? options.baseUrl\n : typeof rawTsconfig.compilerOptions?.baseUrl === 'string'\n ? rawTsconfig.compilerOptions.baseUrl\n : undefined;\n const resolvedBaseUrl = configuredBaseUrl\n ? isAbsolute(configuredBaseUrl)\n ? configuredBaseUrl\n : resolve(tsconfigDir, configuredBaseUrl)\n : tsconfigDir;\n const discoveredRoots = new Set<string>();\n\n for (const targets of Object.values(tsPaths)) {\n for (const target of targets as string[]) {\n const resolvedTarget = normalizePath(\n isAbsolute(target) ? target : resolve(resolvedBaseUrl, target),\n );\n\n if (target.includes('*')) {\n for (const match of globSync(resolvedTarget, {\n dot: true,\n absolute: true,\n })) {\n discoveredRoots.add(normalizePath(match));\n }\n continue;\n }\n\n if (existsSync(resolvedTarget)) {\n discoveredRoots.add(resolvedTarget);\n }\n }\n }\n\n return [...discoveredRoots];\n}\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,KADU,cAAc,YAAY,GAC/B,CAAA,CAAQ,YAAY;AAS/B,IAAa,mBAAb,MAA8B;CASR;CARpB,eAAiC,CAAC;CAClC,uCAA+B,IAAI,IAGjC;CACF,yCAAiC,IAAI,IAAsB;CAC3D,sBAAwC,CAAC;CAEzC,YAAY,SAA0C;EAAlC,KAAA,UAAA;CAAmC;;;;;CAMvD,uBAAuB,OAAuB;EAC5C,IACE,MAAM,WAAW,KAAK,oBAAoB,UAC1C,MAAM,OAAO,MAAM,UAAU,SAAS,KAAK,oBAAoB,MAAM,GAErE;EAEF,KAAK,sBAAsB,CAAC,GAAG,KAAK;EACp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;GACN;EACF;EACA,OAAO;CACT;CAEA,IAAI,CAAC,kBAAkB,SAAS,OAAO,GAAG;EACxC,MAAM,SAAS,GAAG,kBAAkB;EACpC,IAAI,WAAW,MAAM,GACnB,OAAO,cAAc,MAAM;EAE7B,MAAM,iBAAiB,KAAK,mBAAmB,eAAe;EAC9D,IAAI,WAAW,cAAc,GAC3B,OAAO,cAAc,cAAc;CAEvC;AAGF;AAEA,SAAS,yBACP,sBACA,SACA,aAMU;CACV,MAAM,UAAU,YAAY,iBAAiB,SAAS,QAAQ;CAC9D,IAAI,CAAC,SACH,OAAO,CAAC;CAGV,MAAM,cAAc,QAAQ,oBAAoB;CAChD,MAAM,oBACJ,OAAO,QAAQ,YAAY,WACvB,QAAQ,UACR,OAAO,YAAY,iBAAiB,YAAY,WAC9C,YAAY,gBAAgB,UAC5B,KAAA;CACR,MAAM,kBAAkB,oBACpB,WAAW,iBAAiB,IAC1B,oBACA,QAAQ,aAAa,iBAAiB,IACxC;CACJ,MAAM,kCAAkB,IAAI,IAAY;CAExC,KAAK,MAAM,WAAW,OAAO,OAAO,OAAO,GACzC,KAAK,MAAM,UAAU,SAAqB;EACxC,MAAM,iBAAiB,cACrB,WAAW,MAAM,IAAI,SAAS,QAAQ,iBAAiB,MAAM,CAC/D;EAEA,IAAI,OAAO,SAAS,GAAG,GAAG;GACxB,KAAK,MAAM,SAAS,SAAS,gBAAgB;IAC3C,KAAK;IACL,UAAU;GACZ,CAAC,GACC,gBAAgB,IAAI,cAAc,KAAK,CAAC;GAE1C;EACF;EAEA,IAAI,WAAW,cAAc,GAC3B,gBAAgB,IAAI,cAAc;CAEtC;CAGF,OAAO,CAAC,GAAG,eAAe;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-ids.js","names":[],"sources":["../../../../src/lib/utils/virtual-ids.ts"],"sourcesContent":["// Virtual module id helpers for external component resources (template files).\n// Routing through virtual ids keeps Vite's built-in plugins (vite:asset, the\n// server.fs Denied ID check) out of the picture: the id Vite sees has no\n// file extension, so extension-based matchers never fire, and it does not\n// match the /[?&](raw|inline)\\b/ security regex.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids. See #2263 / #2283 / #2310.\n\nexport const VIRTUAL_RAW_PREFIX = 'virtual:@analogjs/vite-plugin-angular:raw:';\n\nfunction encode(absPath: string): string {\n return Buffer.from(absPath, 'utf-8').toString('base64url');\n}\n\nfunction decode(encoded: string): string {\n return Buffer.from(encoded, 'base64url').toString('utf-8');\n}\n\nexport function toVirtualRawId(absPath: string): string {\n return `${VIRTUAL_RAW_PREFIX}${encode(absPath)}`;\n}\n\nexport function isVirtualRawId(id: string): boolean {\n const stripped = id.startsWith('\\0') ? id.slice(1) : id;\n return stripped.startsWith(VIRTUAL_RAW_PREFIX);\n}\n\nexport function fromVirtualRawId(id: string): string {\n const normalizedId = id.startsWith('\\0') ? id.slice(1) : id;\n if (!normalizedId.startsWith(VIRTUAL_RAW_PREFIX)) {\n throw new Error(`Invalid virtual raw id: ${id}`);\n }\n return decode(normalizedId.slice(VIRTUAL_RAW_PREFIX.length));\n}\n"],"mappings":";AAUA,IAAa,qBAAqB;AAElC,SAAS,OAAO,SAAyB;
|
|
1
|
+
{"version":3,"file":"virtual-ids.js","names":[],"sources":["../../../../src/lib/utils/virtual-ids.ts"],"sourcesContent":["// Virtual module id helpers for external component resources (template files).\n// Routing through virtual ids keeps Vite's built-in plugins (vite:asset, the\n// server.fs Denied ID check) out of the picture: the id Vite sees has no\n// file extension, so extension-based matchers never fire, and it does not\n// match the /[?&](raw|inline)\\b/ security regex.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids. See #2263 / #2283 / #2310.\n\nexport const VIRTUAL_RAW_PREFIX = 'virtual:@analogjs/vite-plugin-angular:raw:';\n\nfunction encode(absPath: string): string {\n return Buffer.from(absPath, 'utf-8').toString('base64url');\n}\n\nfunction decode(encoded: string): string {\n return Buffer.from(encoded, 'base64url').toString('utf-8');\n}\n\nexport function toVirtualRawId(absPath: string): string {\n return `${VIRTUAL_RAW_PREFIX}${encode(absPath)}`;\n}\n\nexport function isVirtualRawId(id: string): boolean {\n const stripped = id.startsWith('\\0') ? id.slice(1) : id;\n return stripped.startsWith(VIRTUAL_RAW_PREFIX);\n}\n\nexport function fromVirtualRawId(id: string): string {\n const normalizedId = id.startsWith('\\0') ? id.slice(1) : id;\n if (!normalizedId.startsWith(VIRTUAL_RAW_PREFIX)) {\n throw new Error(`Invalid virtual raw id: ${id}`);\n }\n return decode(normalizedId.slice(VIRTUAL_RAW_PREFIX.length));\n}\n"],"mappings":";AAUA,IAAa,qBAAqB;AAElC,SAAS,OAAO,SAAyB;CACvC,OAAO,OAAO,KAAK,SAAS,OAAO,CAAC,CAAC,SAAS,WAAW;AAC3D;AAEA,SAAS,OAAO,SAAyB;CACvC,OAAO,OAAO,KAAK,SAAS,WAAW,CAAC,CAAC,SAAS,OAAO;AAC3D;AAEA,SAAgB,eAAe,SAAyB;CACtD,OAAO,GAAG,qBAAqB,OAAO,OAAO;AAC/C;AAEA,SAAgB,eAAe,IAAqB;CAElD,QADiB,GAAG,WAAW,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,GAAA,CACrC,WAAW,kBAAkB;AAC/C;AAEA,SAAgB,iBAAiB,IAAoB;CACnD,MAAM,eAAe,GAAG,WAAW,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI;CACzD,IAAI,CAAC,aAAa,WAAA,4CAA6B,GAC7C,MAAM,IAAI,MAAM,2BAA2B,IAAI;CAEjD,OAAO,OAAO,aAAa,MAAM,EAAyB,CAAC;AAC7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-resources.js","names":[],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates)\n// through virtual module ids. Both angular-vite-plugin and fast-compile-plugin\n// use these so the rewriting + loading behavior stays in sync between them.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport {\n fromVirtualRawId,\n isVirtualRawId,\n toVirtualRawId,\n} from './virtual-ids.js';\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n"],"mappings":";;;;;AAsBA,SAAS,kBACP,IACA,UACoB;CACpB,MAAM,WAAW,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"virtual-resources.js","names":[],"sources":["../../../../src/lib/utils/virtual-resources.ts"],"sourcesContent":["// Shared Vite plugin helpers for routing component resources (templates)\n// through virtual module ids. Both angular-vite-plugin and fast-compile-plugin\n// use these so the rewriting + loading behavior stays in sync between them.\n//\n// Style ?inline imports now flow through Vite's native CSS pipeline via\n// safeModulePaths (see safe-module-paths.ts). Only template ?raw imports\n// still use virtual ids.\n\nimport { promises as fsPromises } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath } from 'vite';\n\nimport {\n fromVirtualRawId,\n isVirtualRawId,\n toVirtualRawId,\n} from './virtual-ids.js';\n\ninterface PluginContextLike {\n addWatchFile(path: string): void;\n}\n\nfunction resolveImportPath(\n id: string,\n importer: string | undefined,\n): string | undefined {\n const filePath = id.split('?')[0];\n return isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n}\n\n/**\n * Rewrite a user `.html?raw` import to a virtual raw id. Returns undefined\n * when the id doesn't match, so callers can fall through to the next check.\n *\n * Routed through a virtual id (rather than `?analog-raw`) so the path Vite\n * sees has no file extension — keeps vite:asset / vite:css from re-tagging\n * the id before our load hook runs.\n */\nexport function rewriteHtmlRawImport(\n id: string,\n importer: string | undefined,\n): string | undefined {\n if (!id.includes('.html?raw')) return undefined;\n const resolved = resolveImportPath(id, importer);\n return resolved ? toVirtualRawId(resolved) : undefined;\n}\n\n/**\n * Load a virtual raw module: reads the backing file, registers it for HMR\n * watching, and returns its content as a default-exported string. Returns\n * undefined when the id is not a virtual raw id.\n */\nexport async function loadVirtualRawModule(\n ctx: PluginContextLike,\n id: string,\n): Promise<string | undefined> {\n if (!isVirtualRawId(id)) return undefined;\n const filePath = fromVirtualRawId(id);\n ctx.addWatchFile(filePath);\n const content = await fsPromises.readFile(filePath, 'utf-8');\n return `export default ${JSON.stringify(content)}`;\n}\n"],"mappings":";;;;;AAsBA,SAAS,kBACP,IACA,UACoB;CACpB,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;CAC/B,OAAO,WAAW,QAAQ,IACtB,cAAc,QAAQ,IACtB,WACE,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC,IAClD,KAAA;AACR;;;;;;;;;AAUA,SAAgB,qBACd,IACA,UACoB;CACpB,IAAI,CAAC,GAAG,SAAS,WAAW,GAAG,OAAO,KAAA;CACtC,MAAM,WAAW,kBAAkB,IAAI,QAAQ;CAC/C,OAAO,WAAW,eAAe,QAAQ,IAAI,KAAA;AAC/C;;;;;;AAOA,eAAsB,qBACpB,KACA,IAC6B;CAC7B,IAAI,CAAC,eAAe,EAAE,GAAG,OAAO,KAAA;CAChC,MAAM,WAAW,iBAAiB,EAAE;CACpC,IAAI,aAAa,QAAQ;CACzB,MAAM,UAAU,MAAM,SAAW,SAAS,UAAU,OAAO;CAC3D,OAAO,kBAAkB,KAAK,UAAU,OAAO;AACjD"}
|
|
@@ -8,7 +8,10 @@ function virtualModulesPlugin(pluginOptions) {
|
|
|
8
8
|
enforce: "pre",
|
|
9
9
|
resolveId(id, importer) {
|
|
10
10
|
if (id.startsWith("virtual:@analogjs/vite-plugin-angular:raw:")) return `\0${id}`;
|
|
11
|
-
if (pluginOptions.jit && id.startsWith("angular:jit:"))
|
|
11
|
+
if (pluginOptions.jit && id.startsWith("angular:jit:")) {
|
|
12
|
+
const filePath = normalizePath(resolve(dirname(importer), id.split(";")[1]));
|
|
13
|
+
return toVirtualRawId(filePath);
|
|
14
|
+
}
|
|
12
15
|
if (id.includes(".html?raw")) {
|
|
13
16
|
const filePath = id.split("?")[0];
|
|
14
17
|
const resolved = isAbsolute(filePath) ? normalizePath(filePath) : importer ? normalizePath(resolve(dirname(importer), filePath)) : void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAQA,SAAgB,qBACd,eACQ;
|
|
1
|
+
{"version":3,"file":"virtual-modules-plugin.js","names":[],"sources":["../../../src/lib/virtual-modules-plugin.ts"],"sourcesContent":["import { dirname, isAbsolute, resolve } from 'node:path';\nimport { normalizePath, Plugin } from 'vite';\nimport { VIRTUAL_RAW_PREFIX, toVirtualRawId } from './utils/virtual-ids.js';\n\nexport interface VirtualModulesPluginOptions {\n jit: boolean;\n}\n\nexport function virtualModulesPlugin(\n pluginOptions: VirtualModulesPluginOptions,\n): Plugin {\n return {\n name: '@analogjs/vite-plugin-angular:virtual-modules',\n enforce: 'pre',\n resolveId(id, importer) {\n if (id.startsWith(VIRTUAL_RAW_PREFIX)) {\n return `\\0${id}`;\n }\n\n if (pluginOptions.jit && id.startsWith('angular:jit:')) {\n const filePath = normalizePath(\n resolve(dirname(importer as string), id.split(';')[1]),\n );\n return toVirtualRawId(filePath);\n }\n\n // Intercept .html?raw imports to bypass Vite server.fs restrictions\n if (id.includes('.html?raw')) {\n const filePath = id.split('?')[0];\n const resolved = isAbsolute(filePath)\n ? normalizePath(filePath)\n : importer\n ? normalizePath(resolve(dirname(importer), filePath))\n : undefined;\n if (resolved) {\n return toVirtualRawId(resolved);\n }\n }\n\n return undefined;\n },\n };\n}\n"],"mappings":";;;;AAQA,SAAgB,qBACd,eACQ;CACR,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,IAAI,UAAU;GACtB,IAAI,GAAG,WAAA,4CAA6B,GAClC,OAAO,KAAK;GAGd,IAAI,cAAc,OAAO,GAAG,WAAW,cAAc,GAAG;IACtD,MAAM,WAAW,cACf,QAAQ,QAAQ,QAAkB,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,CACvD;IACA,OAAO,eAAe,QAAQ;GAChC;GAGA,IAAI,GAAG,SAAS,WAAW,GAAG;IAC5B,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,CAAC;IAC/B,MAAM,WAAW,WAAW,QAAQ,IAChC,cAAc,QAAQ,IACtB,WACE,cAAc,QAAQ,QAAQ,QAAQ,GAAG,QAAQ,CAAC,IAClD,KAAA;IACN,IAAI,UACF,OAAO,eAAe,QAAQ;GAElC;EAGF;CACF;AACF"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"generators": {
|
|
3
|
-
"update-3-0-0-migrate-setup-vitest": {
|
|
4
|
-
"version": "3.0.0-alpha.25",
|
|
5
|
-
"description": "Migrate from @analogjs/vite-plugin-angular/setup-vitest to @analogjs/vitest-angular/setup-zone in Nx workspaces",
|
|
6
|
-
"implementation": "./update-3-0-0/migrate-setup-vitest"
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { addDependenciesToPackageJson, readJson, runTasksInSerial, visitNotIgnoredFiles } from "@nx/devkit";
|
|
2
|
-
//#region packages/vite-plugin-angular/migrations/update-3-0-0/migrate-setup-vitest.ts
|
|
3
|
-
var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
|
|
4
|
-
var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
|
|
5
|
-
var SUPPORTED_EXTENSIONS = new Set([
|
|
6
|
-
".cjs",
|
|
7
|
-
".cts",
|
|
8
|
-
".js",
|
|
9
|
-
".jsx",
|
|
10
|
-
".mjs",
|
|
11
|
-
".mts",
|
|
12
|
-
".ts",
|
|
13
|
-
".tsx"
|
|
14
|
-
]);
|
|
15
|
-
function getAnalogVersion(tree) {
|
|
16
|
-
if (!tree.exists("package.json")) return "*";
|
|
17
|
-
const packageJson = readJson(tree, "package.json");
|
|
18
|
-
return packageJson.devDependencies?.["@analogjs/vite-plugin-angular"] || packageJson.dependencies?.["@analogjs/vite-plugin-angular"] || "*";
|
|
19
|
-
}
|
|
20
|
-
async function migrateSetupVitest(tree) {
|
|
21
|
-
const filesToUpdate = [];
|
|
22
|
-
visitNotIgnoredFiles(tree, "", (filePath) => {
|
|
23
|
-
const extension = filePath.slice(filePath.lastIndexOf("."));
|
|
24
|
-
if (!SUPPORTED_EXTENSIONS.has(extension)) return;
|
|
25
|
-
const content = tree.read(filePath, "utf-8");
|
|
26
|
-
if (!content?.includes(OLD_IMPORT)) return;
|
|
27
|
-
tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));
|
|
28
|
-
filesToUpdate.push(filePath);
|
|
29
|
-
});
|
|
30
|
-
if (filesToUpdate.length === 0) return;
|
|
31
|
-
return runTasksInSerial(addDependenciesToPackageJson(tree, {}, { "@analogjs/vitest-angular": getAnalogVersion(tree) }, "package.json", true));
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
export { migrateSetupVitest as default };
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=migrate-setup-vitest.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/update-3-0-0/migrate-setup-vitest.ts"],"sourcesContent":["import {\n addDependenciesToPackageJson,\n readJson,\n runTasksInSerial,\n Tree,\n visitNotIgnoredFiles,\n} from '@nx/devkit';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\nconst SUPPORTED_EXTENSIONS = new Set([\n '.cjs',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.mts',\n '.ts',\n '.tsx',\n]);\n\nfunction getAnalogVersion(tree: Tree): string {\n if (!tree.exists('package.json')) {\n return '*';\n }\n\n const packageJson = readJson<{\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n }>(tree, 'package.json');\n\n return (\n packageJson.devDependencies?.['@analogjs/vite-plugin-angular'] ||\n packageJson.dependencies?.['@analogjs/vite-plugin-angular'] ||\n '*'\n );\n}\n\nexport default async function migrateSetupVitest(tree: Tree) {\n const filesToUpdate: string[] = [];\n\n visitNotIgnoredFiles(tree, '', (filePath) => {\n const extension = filePath.slice(filePath.lastIndexOf('.'));\n if (!SUPPORTED_EXTENSIONS.has(extension)) {\n return;\n }\n\n const content = tree.read(filePath, 'utf-8');\n if (!content?.includes(OLD_IMPORT)) {\n return;\n }\n\n tree.write(filePath, content.replaceAll(OLD_IMPORT, NEW_IMPORT));\n filesToUpdate.push(filePath);\n });\n\n if (filesToUpdate.length === 0) {\n return;\n }\n\n const installTask = addDependenciesToPackageJson(\n tree,\n {},\n {\n '@analogjs/vitest-angular': getAnalogVersion(tree),\n },\n 'package.json',\n true,\n );\n\n return runTasksInSerial(installTask);\n}\n"],"mappings":";;AAQA,IAAM,aAAa;AACnB,IAAM,aAAa;AACnB,IAAM,uBAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,iBAAiB,MAAoB;AAC5C,KAAI,CAAC,KAAK,OAAO,eAAe,CAC9B,QAAO;CAGT,MAAM,cAAc,SAGjB,MAAM,eAAe;AAExB,QACE,YAAY,kBAAkB,oCAC9B,YAAY,eAAe,oCAC3B;;AAIJ,eAA8B,mBAAmB,MAAY;CAC3D,MAAM,gBAA0B,EAAE;AAElC,sBAAqB,MAAM,KAAK,aAAa;EAC3C,MAAM,YAAY,SAAS,MAAM,SAAS,YAAY,IAAI,CAAC;AAC3D,MAAI,CAAC,qBAAqB,IAAI,UAAU,CACtC;EAGF,MAAM,UAAU,KAAK,KAAK,UAAU,QAAQ;AAC5C,MAAI,CAAC,SAAS,SAAS,WAAW,CAChC;AAGF,OAAK,MAAM,UAAU,QAAQ,WAAW,YAAY,WAAW,CAAC;AAChE,gBAAc,KAAK,SAAS;GAC5B;AAEF,KAAI,cAAc,WAAW,EAC3B;AAaF,QAAO,iBAVa,6BAClB,MACA,EAAE,EACF,EACE,4BAA4B,iBAAiB,KAAK,EACnD,EACD,gBACA,KACD,CAEmC"}
|