@analogjs/vite-plugin-angular 3.0.0-alpha.7 → 3.0.0-alpha.71
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 +30 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.d.ts +2 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js +49 -0
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -0
- package/migrations/migration.json +7 -1
- package/migrations/migrations.json +9 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.d.ts +2 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.js +36 -0
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -0
- package/package.json +51 -12
- package/src/index.d.ts +5 -2
- package/src/index.js +6 -2
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.d.ts +40 -0
- package/src/lib/analog-plugin-interop.js +61 -0
- package/src/lib/analog-plugin-interop.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +4 -4
- package/src/lib/angular-build-optimizer-plugin.js +57 -62
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +3 -3
- package/src/lib/angular-jit-plugin.js +51 -37
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-pending-tasks.plugin.d.ts +7 -7
- package/src/lib/angular-pending-tasks.plugin.js +17 -18
- package/src/lib/angular-pending-tasks.plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +177 -69
- package/src/lib/angular-vite-plugin.js +1227 -1084
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +26 -17
- package/src/lib/angular-vitest-plugin.js +106 -114
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +29 -0
- package/src/lib/compilation-api/compilation-api-plugin.js +491 -0
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -0
- package/src/lib/compilation-api/index.d.ts +1 -0
- package/src/lib/compilation-api/index.js +1 -0
- package/src/lib/compiler/angular-version.d.ts +19 -0
- package/src/lib/compiler/angular-version.js +31 -0
- package/src/lib/compiler/angular-version.js.map +1 -0
- package/src/lib/compiler/class-field-lowering.d.ts +23 -0
- package/src/lib/compiler/class-field-lowering.js +131 -0
- package/src/lib/compiler/class-field-lowering.js.map +1 -0
- package/src/lib/compiler/compile.d.ts +50 -0
- package/src/lib/compiler/compile.js +814 -0
- package/src/lib/compiler/compile.js.map +1 -0
- package/src/lib/compiler/constants.d.ts +24 -0
- package/src/lib/compiler/constants.js +59 -0
- package/src/lib/compiler/constants.js.map +1 -0
- package/src/lib/compiler/debug.d.ts +22 -0
- package/src/lib/compiler/debug.js +20 -0
- package/src/lib/compiler/debug.js.map +1 -0
- package/src/lib/compiler/defer.d.ts +57 -0
- package/src/lib/compiler/defer.js +154 -0
- package/src/lib/compiler/defer.js.map +1 -0
- package/src/lib/compiler/dts-reader.d.ts +45 -0
- package/src/lib/compiler/dts-reader.js +395 -0
- package/src/lib/compiler/dts-reader.js.map +1 -0
- package/src/lib/compiler/hmr.d.ts +16 -0
- package/src/lib/compiler/hmr.js +69 -0
- package/src/lib/compiler/hmr.js.map +1 -0
- package/src/lib/compiler/index.d.ts +8 -0
- package/src/lib/compiler/index.js +8 -0
- package/src/lib/compiler/jit-metadata.d.ts +14 -0
- package/src/lib/compiler/jit-metadata.js +168 -0
- package/src/lib/compiler/jit-metadata.js.map +1 -0
- package/src/lib/compiler/jit-transform.d.ts +24 -0
- package/src/lib/compiler/jit-transform.js +204 -0
- package/src/lib/compiler/jit-transform.js.map +1 -0
- package/src/lib/compiler/js-emitter.d.ts +10 -0
- package/src/lib/compiler/js-emitter.js +446 -0
- package/src/lib/compiler/js-emitter.js.map +1 -0
- package/src/lib/compiler/metadata.d.ts +36 -0
- package/src/lib/compiler/metadata.js +710 -0
- package/src/lib/compiler/metadata.js.map +1 -0
- package/src/lib/compiler/registry.d.ts +56 -0
- package/src/lib/compiler/registry.js +176 -0
- package/src/lib/compiler/registry.js.map +1 -0
- package/src/lib/compiler/resource-inliner.d.ts +43 -0
- package/src/lib/compiler/resource-inliner.js +230 -0
- package/src/lib/compiler/resource-inliner.js.map +1 -0
- package/src/lib/compiler/style-ast.d.ts +9 -0
- package/src/lib/compiler/style-ast.js +54 -0
- package/src/lib/compiler/style-ast.js.map +1 -0
- package/src/lib/compiler/styles.d.ts +13 -0
- package/src/lib/compiler/test-helpers.d.ts +7 -0
- package/src/lib/compiler/type-elision.d.ts +28 -0
- package/src/lib/compiler/type-elision.js +211 -0
- package/src/lib/compiler/type-elision.js.map +1 -0
- package/src/lib/compiler/utils.d.ts +40 -0
- package/src/lib/compiler/utils.js +76 -0
- package/src/lib/compiler/utils.js.map +1 -0
- package/src/lib/compiler-plugin.d.ts +13 -12
- package/src/lib/compiler-plugin.js +40 -44
- package/src/lib/compiler-plugin.js.map +1 -1
- package/src/lib/component-resolvers.d.ts +23 -5
- package/src/lib/component-resolvers.js +107 -64
- package/src/lib/component-resolvers.js.map +1 -1
- package/src/lib/encapsulation-plugin.d.ts +13 -0
- package/src/lib/encapsulation-plugin.js +48 -0
- package/src/lib/encapsulation-plugin.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +28 -0
- package/src/lib/fast-compile-plugin.js +414 -0
- package/src/lib/fast-compile-plugin.js.map +1 -0
- package/src/lib/host.d.ts +10 -8
- package/src/lib/host.js +113 -101
- package/src/lib/host.js.map +1 -1
- package/src/lib/live-reload-plugin.d.ts +5 -5
- package/src/lib/live-reload-plugin.js +61 -63
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/models.d.ts +9 -9
- package/src/lib/nx-folder-plugin.d.ts +5 -5
- package/src/lib/nx-folder-plugin.js +18 -16
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +4 -4
- package/src/lib/plugins/file-replacements.plugin.js +40 -62
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +1 -1
- package/src/lib/router-plugin.js +35 -23
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-pipeline.d.ts +15 -0
- package/src/lib/style-pipeline.js +31 -0
- package/src/lib/style-pipeline.js.map +1 -0
- package/src/lib/style-preprocessor.d.ts +35 -0
- package/src/lib/style-preprocessor.js +35 -0
- package/src/lib/style-preprocessor.js.map +1 -0
- package/src/lib/stylesheet-registry.d.ts +74 -0
- package/src/lib/stylesheet-registry.js +174 -0
- package/src/lib/stylesheet-registry.js.map +1 -0
- package/src/lib/tailwind-plugin.d.ts +34 -0
- package/src/lib/tailwind-plugin.js +116 -0
- package/src/lib/tailwind-plugin.js.map +1 -0
- package/src/lib/tools/package.json +2 -7
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +33 -38
- 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 +51 -62
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/tools/src/index.js +0 -2
- package/src/lib/utils/compilation-shared.d.ts +62 -0
- package/src/lib/utils/compilation-shared.js +138 -0
- package/src/lib/utils/compilation-shared.js.map +1 -0
- package/src/lib/utils/compiler-plugin-options.d.ts +11 -11
- package/src/lib/utils/css-extension-resolver.d.ts +32 -0
- package/src/lib/utils/css-extension-resolver.js +73 -0
- package/src/lib/utils/css-extension-resolver.js.map +1 -0
- package/src/lib/utils/debug-harness.d.ts +23 -0
- package/src/lib/utils/debug-harness.js +88 -0
- package/src/lib/utils/debug-harness.js.map +1 -0
- package/src/lib/utils/debug-log-file.d.ts +5 -0
- package/src/lib/utils/debug-log-file.js +56 -0
- package/src/lib/utils/debug-log-file.js.map +1 -0
- package/src/lib/utils/debug.d.ts +28 -0
- package/src/lib/utils/debug.js +39 -0
- package/src/lib/utils/debug.js.map +1 -0
- package/src/lib/utils/devkit.d.ts +6 -6
- package/src/lib/utils/devkit.js +34 -38
- package/src/lib/utils/devkit.js.map +1 -1
- package/src/lib/utils/hmr-candidates.d.ts +28 -28
- package/src/lib/utils/jit-inline-styles.d.ts +3 -0
- package/src/lib/utils/jit-inline-styles.js +16 -0
- package/src/lib/utils/jit-inline-styles.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +41 -0
- package/src/lib/utils/plugin-config.js +85 -0
- package/src/lib/utils/plugin-config.js.map +1 -0
- package/src/lib/utils/rolldown.d.ts +2 -0
- package/src/lib/utils/rolldown.js +12 -0
- package/src/lib/utils/rolldown.js.map +1 -0
- package/src/lib/utils/safe-module-paths.d.ts +16 -0
- package/src/lib/utils/safe-module-paths.js +29 -0
- package/src/lib/utils/safe-module-paths.js.map +1 -0
- package/src/lib/utils/source-file-cache.d.ts +8 -15
- package/src/lib/utils/source-file-cache.js +35 -37
- package/src/lib/utils/source-file-cache.js.map +1 -1
- package/src/lib/utils/tailwind-reference.d.ts +12 -0
- package/src/lib/utils/tailwind-reference.js +99 -0
- package/src/lib/utils/tailwind-reference.js.map +1 -0
- package/src/lib/utils/transform-cache.d.ts +43 -0
- package/src/lib/utils/transform-cache.js +97 -0
- package/src/lib/utils/transform-cache.js.map +1 -0
- package/src/lib/utils/tsconfig-resolver.d.ts +28 -0
- package/src/lib/utils/tsconfig-resolver.js +191 -0
- package/src/lib/utils/tsconfig-resolver.js.map +1 -0
- package/src/lib/utils/virtual-ids.d.ts +4 -0
- package/src/lib/utils/virtual-ids.js +23 -0
- package/src/lib/utils/virtual-ids.js.map +1 -0
- package/src/lib/utils/virtual-resources.d.ts +19 -0
- package/src/lib/utils/virtual-resources.js +38 -0
- package/src/lib/utils/virtual-resources.js.map +1 -0
- package/src/lib/virtual-modules-plugin.d.ts +5 -0
- package/src/lib/virtual-modules-plugin.js +23 -0
- package/src/lib/virtual-modules-plugin.js.map +1 -0
- package/src/test-setup.d.ts +2 -0
- package/setup-vitest.d.ts +0 -4
- package/setup-vitest.js +0 -215
- package/setup-vitest.js.map +0 -1
- package/src/lib/models.js +0 -1
- package/src/lib/models.js.map +0 -1
- package/src/lib/tools/README.md +0 -3
- package/src/lib/tools/src/index.d.ts +0 -0
- package/src/lib/tools/src/index.js.map +0 -1
- package/src/lib/utils/compiler-plugin-options.js +0 -1
- package/src/lib/utils/compiler-plugin-options.js.map +0 -1
- package/src/lib/utils/hmr-candidates.js +0 -272
- package/src/lib/utils/hmr-candidates.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compilation-shared.js","names":[],"sources":["../../../../src/lib/utils/compilation-shared.ts"],"sourcesContent":["/**\n * Shared utilities used by both angular-vite-plugin.ts and\n * compilation-api/compilation-api-plugin.ts.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { basename, isAbsolute, resolve } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { normalizePath } from 'vite';\n\nimport {\n AnalogStylesheetRegistry,\n preprocessStylesheetResult,\n rewriteRelativeCssImports,\n} from '../stylesheet-registry.js';\nimport { normalizeStylesheetDependencies } from '../style-preprocessor.js';\nimport type { StylePreprocessor } from '../style-preprocessor.js';\nimport type { FileReplacement } from '../plugins/file-replacements.plugin.js';\nimport { debugStylesV } from './debug.js';\n\nexport enum DiagnosticModes {\n None = 0,\n Option = 1 << 0,\n Syntactic = 1 << 1,\n Semantic = 1 << 2,\n All = Option | Syntactic | Semantic,\n}\n\nexport function injectViteIgnoreForHmrMetadata(code: string): string {\n let patched = code.replace(\n /\\bimport\\(([a-zA-Z_$][\\w$]*\\.\\u0275\\u0275getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n\n if (patched === code) {\n patched = patched.replace(\n /import\\((\\S+getReplaceMetadataURL)/g,\n 'import(/* @vite-ignore */ $1',\n );\n }\n\n return patched;\n}\n\nexport function isIgnoredHmrFile(file: string): boolean {\n return file.endsWith('.tsbuildinfo');\n}\n\n/**\n * Convert Analog/Angular CLI-style file replacements into the flat record\n * expected by `AngularHostOptions.fileReplacements`.\n *\n * Only browser replacements (`{ replace, with }`) are converted. SSR-only\n * replacements (`{ replace, ssr }`) are left for the Vite runtime plugin to\n * handle — they should not be baked into the Angular compilation host because\n * that would apply them to both browser and server builds.\n *\n * Relative paths are resolved against `workspaceRoot` so that the host\n * receives the same absolute paths it would get from the Angular CLI.\n */\nexport function toAngularCompilationFileReplacements(\n replacements: FileReplacement[],\n workspaceRoot: string,\n): Record<string, string> | undefined {\n const mappedReplacements = replacements.flatMap((replacement) => {\n if (!('with' in replacement)) {\n return [];\n }\n\n return [\n [\n isAbsolute(replacement.replace)\n ? replacement.replace\n : resolve(workspaceRoot, replacement.replace),\n isAbsolute(replacement.with)\n ? replacement.with\n : resolve(workspaceRoot, replacement.with),\n ] as const,\n ];\n });\n\n return mappedReplacements.length\n ? Object.fromEntries(mappedReplacements)\n : undefined;\n}\n\n/**\n * Map Angular's `templateUpdates` (keyed by `encodedFilePath@ClassName`)\n * back to absolute file paths with their associated HMR code and component\n * class name.\n *\n * Angular's private Compilation API emits template update keys in the form\n * `encodeURIComponent(relativePath + '@' + className)`. We decode and resolve\n * them so the caller can look up updates by the same normalized absolute path\n * used elsewhere in the plugin (`outputFiles`, `classNames`, etc.).\n */\nexport function mapTemplateUpdatesToFiles(\n templateUpdates: ReadonlyMap<string, string> | undefined,\n): Map<\n string,\n {\n className: string;\n code: string;\n }\n> {\n const updatesByFile = new Map<string, { className: string; code: string }>();\n\n templateUpdates?.forEach((code, encodedUpdateId) => {\n const [file, className = ''] =\n decodeURIComponent(encodedUpdateId).split('@');\n const resolvedFile = normalizePath(resolve(process.cwd(), file));\n\n updatesByFile.set(resolvedFile, {\n className,\n code,\n });\n });\n\n return updatesByFile;\n}\n\nexport function describeStylesheetContent(code: string): {\n length: number;\n digest: string;\n preview: string;\n} {\n return {\n length: code.length,\n digest: createHash('sha256').update(code).digest('hex').slice(0, 12),\n preview: code.replace(/\\s+/g, ' ').trim().slice(0, 160),\n };\n}\n\n/**\n * Refreshes any already-served stylesheet records that map back to a changed\n * source file.\n *\n * This is the critical bridge for externalized Angular component styles during\n * HMR. Angular's resource watcher can notice that `/src/...component.css`\n * changed before Angular recompilation has had a chance to repopulate the\n * stylesheet registry. If we emit a CSS update against the existing virtual\n * stylesheet id without first refreshing the registry content, the browser gets\n * a hot update containing stale CSS. By rewriting the existing served records\n * from disk up front, HMR always pushes the latest source content.\n */\nexport function refreshStylesheetRegistryForFile(\n file: string,\n stylesheetRegistry?: AnalogStylesheetRegistry,\n stylePreprocessor?: StylePreprocessor,\n): void {\n const normalizedFile = normalizePath(file.split('?')[0]);\n if (!stylesheetRegistry || !existsSync(normalizedFile)) {\n return;\n }\n\n const publicIds = stylesheetRegistry.getPublicIdsForSource(normalizedFile);\n if (publicIds.length === 0) {\n return;\n }\n\n const rawCss = readFileSync(normalizedFile, 'utf-8');\n const preprocessed = preprocessStylesheetResult(\n rawCss,\n normalizedFile,\n stylePreprocessor,\n );\n const servedCss = rewriteRelativeCssImports(\n preprocessed.code,\n normalizedFile,\n );\n\n for (const publicId of publicIds) {\n stylesheetRegistry.registerServedStylesheet(\n {\n publicId,\n sourcePath: normalizedFile,\n originalCode: rawCss,\n normalizedCode: servedCss,\n dependencies: normalizeStylesheetDependencies(\n preprocessed.dependencies,\n ),\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n },\n [\n normalizedFile,\n normalizePath(normalizedFile),\n basename(normalizedFile),\n normalizedFile.replace(/^\\//, ''),\n ],\n );\n }\n\n debugStylesV('stylesheet registry refreshed from source file', {\n file: normalizedFile,\n publicIds,\n dependencies: preprocessed.dependencies,\n diagnostics: preprocessed.diagnostics,\n tags: preprocessed.tags,\n source: describeStylesheetContent(rawCss),\n served: describeStylesheetContent(servedCss),\n });\n}\n\n/**\n * Checks for vitest run from the command line\n * @returns boolean\n */\nexport function isTestWatchMode(args = process.argv): boolean {\n // vitest --run\n const hasRun = args.find((arg) => arg.includes('--run'));\n if (hasRun) {\n return false;\n }\n\n // vitest run\n if (args.includes('run')) {\n return false;\n }\n\n // vitest --no-run\n const hasNoRun = args.find((arg) => arg.includes('--no-run'));\n if (hasNoRun) {\n return true;\n }\n\n // check for --watch=false or --no-watch\n const hasWatch = args.find((arg) => arg.includes('watch'));\n if (hasWatch && ['false', 'no'].some((neg) => hasWatch.includes(neg))) {\n return false;\n }\n\n // check for --watch false\n const watchIndex = args.findIndex((arg) => arg.includes('watch'));\n const watchArg = args[watchIndex + 1];\n if (watchArg && watchArg === 'false') {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,IAAY,kBAAL,yBAAA,iBAAA;AACL,iBAAA,gBAAA,UAAA,KAAA;AACA,iBAAA,gBAAA,YAAA,KAAA;AACA,iBAAA,gBAAA,eAAA,KAAA;AACA,iBAAA,gBAAA,cAAA,KAAA;AACA,iBAAA,gBAAA,SAAA,KAAA;;KACD;AAED,SAAgB,+BAA+B,MAAsB;CACnE,IAAI,UAAU,KAAK,QACjB,oEACA,+BACD;AAED,KAAI,YAAY,KACd,WAAU,QAAQ,QAChB,uCACA,+BACD;AAGH,QAAO;;AAGT,SAAgB,iBAAiB,MAAuB;AACtD,QAAO,KAAK,SAAS,eAAe;;;;;;;;;;;;;;AAetC,SAAgB,qCACd,cACA,eACoC;CACpC,MAAM,qBAAqB,aAAa,SAAS,gBAAgB;AAC/D,MAAI,EAAE,UAAU,aACd,QAAO,EAAE;AAGX,SAAO,CACL,CACE,WAAW,YAAY,QAAQ,GAC3B,YAAY,UACZ,QAAQ,eAAe,YAAY,QAAQ,EAC/C,WAAW,YAAY,KAAK,GACxB,YAAY,OACZ,QAAQ,eAAe,YAAY,KAAK,CAC7C,CACF;GACD;AAEF,QAAO,mBAAmB,SACtB,OAAO,YAAY,mBAAmB,GACtC,KAAA;;;;;;;;;;;;AAaN,SAAgB,0BACd,iBAOA;CACA,MAAM,gCAAgB,IAAI,KAAkD;AAE5E,kBAAiB,SAAS,MAAM,oBAAoB;EAClD,MAAM,CAAC,MAAM,YAAY,MACvB,mBAAmB,gBAAgB,CAAC,MAAM,IAAI;EAChD,MAAM,eAAe,cAAc,QAAQ,QAAQ,KAAK,EAAE,KAAK,CAAC;AAEhE,gBAAc,IAAI,cAAc;GAC9B;GACA;GACD,CAAC;GACF;AAEF,QAAO;;AAGT,SAAgB,0BAA0B,MAIxC;AACA,QAAO;EACL,QAAQ,KAAK;EACb,QAAQ,WAAW,SAAS,CAAC,OAAO,KAAK,CAAC,OAAO,MAAM,CAAC,MAAM,GAAG,GAAG;EACpE,SAAS,KAAK,QAAQ,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI;EACxD;;;;;;;;;;;;;;AAeH,SAAgB,iCACd,MACA,oBACA,mBACM;CACN,MAAM,iBAAiB,cAAc,KAAK,MAAM,IAAI,CAAC,GAAG;AACxD,KAAI,CAAC,sBAAsB,CAAC,WAAW,eAAe,CACpD;CAGF,MAAM,YAAY,mBAAmB,sBAAsB,eAAe;AAC1E,KAAI,UAAU,WAAW,EACvB;CAGF,MAAM,SAAS,aAAa,gBAAgB,QAAQ;CACpD,MAAM,eAAe,2BACnB,QACA,gBACA,kBACD;CACD,MAAM,YAAY,0BAChB,aAAa,MACb,eACD;AAED,MAAK,MAAM,YAAY,UACrB,oBAAmB,yBACjB;EACE;EACA,YAAY;EACZ,cAAc;EACd,gBAAgB;EAChB,cAAc,gCACZ,aAAa,aACd;EACD,aAAa,aAAa;EAC1B,MAAM,aAAa;EACpB,EACD;EACE;EACA,cAAc,eAAe;EAC7B,SAAS,eAAe;EACxB,eAAe,QAAQ,OAAO,GAAG;EAClC,CACF;AAGH,cAAa,kDAAkD;EAC7D,MAAM;EACN;EACA,cAAc,aAAa;EAC3B,aAAa,aAAa;EAC1B,MAAM,aAAa;EACnB,QAAQ,0BAA0B,OAAO;EACzC,QAAQ,0BAA0B,UAAU;EAC7C,CAAC;;;;;;AAOJ,SAAgB,gBAAgB,OAAO,QAAQ,MAAe;AAG5D,KADe,KAAK,MAAM,QAAQ,IAAI,SAAS,QAAQ,CAAC,CAEtD,QAAO;AAIT,KAAI,KAAK,SAAS,MAAM,CACtB,QAAO;AAKT,KADiB,KAAK,MAAM,QAAQ,IAAI,SAAS,WAAW,CAAC,CAE3D,QAAO;CAIT,MAAM,WAAW,KAAK,MAAM,QAAQ,IAAI,SAAS,QAAQ,CAAC;AAC1D,KAAI,YAAY,CAAC,SAAS,KAAK,CAAC,MAAM,QAAQ,SAAS,SAAS,IAAI,CAAC,CACnE,QAAO;CAKT,MAAM,WAAW,KADE,KAAK,WAAW,QAAQ,IAAI,SAAS,QAAQ,CAAC,GAC9B;AACnC,KAAI,YAAY,aAAa,QAC3B,QAAO;AAGT,QAAO"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { SourceFileCache } from
|
|
1
|
+
import { SourceFileCache } from "./source-file-cache";
|
|
2
2
|
export interface CompilerPluginOptions {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
sourcemap: boolean;
|
|
4
|
+
tsconfig: string;
|
|
5
|
+
jit?: boolean;
|
|
6
|
+
/** Skip TypeScript compilation setup. This is useful to re-use the TypeScript compilation from another plugin. */
|
|
7
|
+
noopTypeScriptCompilation?: boolean;
|
|
8
|
+
advancedOptimizations?: boolean;
|
|
9
|
+
thirdPartySourcemaps?: boolean;
|
|
10
|
+
fileReplacements?: Record<string, string>;
|
|
11
|
+
sourceFileCache?: SourceFileCache;
|
|
12
|
+
incremental: boolean;
|
|
13
13
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as vite from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves bare-specifier `.css` imports with the `style` package-export
|
|
4
|
+
* condition in scope, without leaking `style` into Vite's global
|
|
5
|
+
* `resolve.conditions`.
|
|
6
|
+
*
|
|
7
|
+
* Two real cases pull in opposite directions on this condition:
|
|
8
|
+
*
|
|
9
|
+
* 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:
|
|
10
|
+
* Material's prebuilt theme entries are gated *only* under the `style`
|
|
11
|
+
* condition (no `default`, no `import`), so without `style` in scope
|
|
12
|
+
* the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
|
|
13
|
+
*
|
|
14
|
+
* 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS
|
|
15
|
+
* plugin resolver inherits Vite's global conditions. If `style` is
|
|
16
|
+
* injected globally, that resolver matches the package's `style`
|
|
17
|
+
* export (a `.css` file) and feeds it to Node's ESM loader, which
|
|
18
|
+
* can't load `.css` and throws
|
|
19
|
+
* `Internal server error: Unknown file extension ".css"`.
|
|
20
|
+
*
|
|
21
|
+
* The fix: scope the `style` condition to requests that *look* like CSS
|
|
22
|
+
* assets — bare specifiers ending in `.css` (with optional query suffix
|
|
23
|
+
* for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through
|
|
24
|
+
* to Vite's normal resolver chain, so packages with mixed exports
|
|
25
|
+
* (`tailwindcss-primeui` exposes both `style` and `import`) resolve to
|
|
26
|
+
* their JS surface.
|
|
27
|
+
*
|
|
28
|
+
* Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes
|
|
29
|
+
* `vite.createIdResolver(config, options)`. Their resolver-call signatures
|
|
30
|
+
* differ — this plugin normalizes both.
|
|
31
|
+
*/
|
|
32
|
+
export declare function cssExtensionStyleResolverPlugin(): vite.Plugin;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as vite from "vite";
|
|
2
|
+
//#region packages/vite-plugin-angular/src/lib/utils/css-extension-resolver.ts
|
|
3
|
+
/**
|
|
4
|
+
* Resolves bare-specifier `.css` imports with the `style` package-export
|
|
5
|
+
* condition in scope, without leaking `style` into Vite's global
|
|
6
|
+
* `resolve.conditions`.
|
|
7
|
+
*
|
|
8
|
+
* Two real cases pull in opposite directions on this condition:
|
|
9
|
+
*
|
|
10
|
+
* 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:
|
|
11
|
+
* Material's prebuilt theme entries are gated *only* under the `style`
|
|
12
|
+
* condition (no `default`, no `import`), so without `style` in scope
|
|
13
|
+
* the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.
|
|
14
|
+
*
|
|
15
|
+
* 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS
|
|
16
|
+
* plugin resolver inherits Vite's global conditions. If `style` is
|
|
17
|
+
* injected globally, that resolver matches the package's `style`
|
|
18
|
+
* export (a `.css` file) and feeds it to Node's ESM loader, which
|
|
19
|
+
* can't load `.css` and throws
|
|
20
|
+
* `Internal server error: Unknown file extension ".css"`.
|
|
21
|
+
*
|
|
22
|
+
* The fix: scope the `style` condition to requests that *look* like CSS
|
|
23
|
+
* assets — bare specifiers ending in `.css` (with optional query suffix
|
|
24
|
+
* for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through
|
|
25
|
+
* to Vite's normal resolver chain, so packages with mixed exports
|
|
26
|
+
* (`tailwindcss-primeui` exposes both `style` and `import`) resolve to
|
|
27
|
+
* their JS surface.
|
|
28
|
+
*
|
|
29
|
+
* Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes
|
|
30
|
+
* `vite.createIdResolver(config, options)`. Their resolver-call signatures
|
|
31
|
+
* differ — this plugin normalizes both.
|
|
32
|
+
*/
|
|
33
|
+
function cssExtensionStyleResolverPlugin() {
|
|
34
|
+
let resolveCss;
|
|
35
|
+
return {
|
|
36
|
+
name: "@analogjs/vite-plugin-angular:css-style-resolver",
|
|
37
|
+
enforce: "pre",
|
|
38
|
+
configResolved(config) {
|
|
39
|
+
const styleResolveOptions = {
|
|
40
|
+
...config.resolve,
|
|
41
|
+
conditions: [...config.resolve.conditions ?? [], "style"]
|
|
42
|
+
};
|
|
43
|
+
const createIdResolver = vite.createIdResolver;
|
|
44
|
+
if (typeof createIdResolver === "function") {
|
|
45
|
+
const r = createIdResolver(config, styleResolveOptions);
|
|
46
|
+
resolveCss = async (id, importer, environment) => {
|
|
47
|
+
return await r(environment ?? { name: "client" }, id, importer, false);
|
|
48
|
+
};
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const legacyCreateResolver = config.createResolver;
|
|
52
|
+
if (typeof legacyCreateResolver === "function") {
|
|
53
|
+
const r = legacyCreateResolver(styleResolveOptions);
|
|
54
|
+
resolveCss = async (id, importer) => {
|
|
55
|
+
return await r(id, importer, false, false);
|
|
56
|
+
};
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
throw new Error("[@analogjs/vite-plugin-angular]: neither vite.createIdResolver (Vite 8) nor ResolvedConfig.createResolver (Vite 7) is available. Unsupported Vite version.");
|
|
60
|
+
},
|
|
61
|
+
async resolveId(id, importer) {
|
|
62
|
+
if (!resolveCss) return null;
|
|
63
|
+
if (id.startsWith(".") || id.startsWith("/") || /^[A-Za-z]:\//.test(id) || id.startsWith("\0") || id.startsWith("data:") || id.startsWith("virtual:")) return null;
|
|
64
|
+
if (!/\.css(?:\?|$)/.test(id)) return null;
|
|
65
|
+
const env = this.environment;
|
|
66
|
+
return await resolveCss(id, importer, env) ?? null;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { cssExtensionStyleResolverPlugin };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=css-extension-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-extension-resolver.js","names":[],"sources":["../../../../src/lib/utils/css-extension-resolver.ts"],"sourcesContent":["import * as vite from 'vite';\n\ntype CssResolver = (\n id: string,\n importer: string | undefined,\n environment?: { name: string } | undefined,\n) => Promise<string | undefined>;\n\n/**\n * Resolves bare-specifier `.css` imports with the `style` package-export\n * condition in scope, without leaking `style` into Vite's global\n * `resolve.conditions`.\n *\n * Two real cases pull in opposite directions on this condition:\n *\n * 1. `import '@angular/material/prebuilt-themes/azure-blue.css'` from TS:\n * Material's prebuilt theme entries are gated *only* under the `style`\n * condition (no `default`, no `import`), so without `style` in scope\n * the request fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`.\n *\n * 2. `@plugin 'tailwindcss-primeui'` from a CSS file: Tailwind v4's JS\n * plugin resolver inherits Vite's global conditions. If `style` is\n * injected globally, that resolver matches the package's `style`\n * export (a `.css` file) and feeds it to Node's ESM loader, which\n * can't load `.css` and throws\n * `Internal server error: Unknown file extension \".css\"`.\n *\n * The fix: scope the `style` condition to requests that *look* like CSS\n * assets — bare specifiers ending in `.css` (with optional query suffix\n * for `?inline`, `?module`, etc.). Non-CSS bare specifiers fall through\n * to Vite's normal resolver chain, so packages with mixed exports\n * (`tailwindcss-primeui` exposes both `style` and `import`) resolve to\n * their JS surface.\n *\n * Vite 7 exposes `ResolvedConfig.createResolver(options)`; Vite 8 exposes\n * `vite.createIdResolver(config, options)`. Their resolver-call signatures\n * differ — this plugin normalizes both.\n */\nexport function cssExtensionStyleResolverPlugin(): vite.Plugin {\n let resolveCss: CssResolver | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular:css-style-resolver',\n enforce: 'pre',\n\n configResolved(config) {\n const styleResolveOptions = {\n ...config.resolve,\n conditions: [...(config.resolve.conditions ?? []), 'style'],\n };\n\n const createIdResolver = (\n vite as unknown as {\n createIdResolver?: (\n c: vite.ResolvedConfig,\n o: typeof styleResolveOptions,\n ) => (\n environment: { name: string },\n id: string,\n importer: string | undefined,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createIdResolver;\n\n if (typeof createIdResolver === 'function') {\n const r = createIdResolver(config, styleResolveOptions);\n resolveCss = async (id, importer, environment) => {\n return await r(\n environment ?? { name: 'client' },\n id,\n importer,\n false,\n );\n };\n return;\n }\n\n const legacyCreateResolver = (\n config as unknown as {\n createResolver?: (\n o: typeof styleResolveOptions,\n ) => (\n id: string,\n importer: string | undefined,\n aliasOnly: boolean,\n ssr: boolean,\n ) => Promise<string | undefined>;\n }\n ).createResolver;\n\n if (typeof legacyCreateResolver === 'function') {\n const r = legacyCreateResolver(styleResolveOptions);\n resolveCss = async (id, importer) => {\n return await r(id, importer, false, false);\n };\n return;\n }\n\n // Both APIs have been stable across the supported Vite range\n // (7.x via `ResolvedConfig.createResolver`, 8.x via\n // `vite.createIdResolver`). If neither is present, fail loudly\n // rather than silently regressing CSS imports of `style`-only\n // package exports such as `@angular/material/prebuilt-themes/*`.\n throw new Error(\n '[@analogjs/vite-plugin-angular]: neither vite.createIdResolver ' +\n '(Vite 8) nor ResolvedConfig.createResolver (Vite 7) is available. ' +\n 'Unsupported Vite version.',\n );\n },\n\n async resolveId(id, importer) {\n if (!resolveCss) return null;\n\n // Skip non-bare specifiers — relative, absolute, virtual, and\n // data-URI imports don't consult package exports, so the `style`\n // condition is irrelevant for them.\n if (\n id.startsWith('.') ||\n id.startsWith('/') ||\n /^[A-Za-z]:\\//.test(id) ||\n id.startsWith('\\0') ||\n id.startsWith('data:') ||\n id.startsWith('virtual:')\n ) {\n return null;\n }\n\n // Only fire on `.css` requests (with optional query, e.g. `?inline`,\n // `?module`). Non-CSS bare specifiers go through Vite's normal\n // resolver chain unchanged, which is critical for packages whose\n // exports include both `style` and `import`/`default` — e.g.\n // `tailwindcss-primeui`, where `@plugin` resolution must land on\n // the JS file, not the CSS file.\n if (!/\\.css(?:\\?|$)/.test(id)) return null;\n\n const env = (this as unknown as { environment?: { name: string } })\n .environment;\n const resolved = await resolveCss(id, importer, env);\n return resolved ?? null;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,kCAA+C;CAC7D,IAAI;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;EAET,eAAe,QAAQ;GACrB,MAAM,sBAAsB;IAC1B,GAAG,OAAO;IACV,YAAY,CAAC,GAAI,OAAO,QAAQ,cAAc,EAAE,EAAG,QAAQ;IAC5D;GAED,MAAM,mBACJ,KAWA;AAEF,OAAI,OAAO,qBAAqB,YAAY;IAC1C,MAAM,IAAI,iBAAiB,QAAQ,oBAAoB;AACvD,iBAAa,OAAO,IAAI,UAAU,gBAAgB;AAChD,YAAO,MAAM,EACX,eAAe,EAAE,MAAM,UAAU,EACjC,IACA,UACA,MACD;;AAEH;;GAGF,MAAM,uBACJ,OAUA;AAEF,OAAI,OAAO,yBAAyB,YAAY;IAC9C,MAAM,IAAI,qBAAqB,oBAAoB;AACnD,iBAAa,OAAO,IAAI,aAAa;AACnC,YAAO,MAAM,EAAE,IAAI,UAAU,OAAO,MAAM;;AAE5C;;AAQF,SAAM,IAAI,MACR,6JAGD;;EAGH,MAAM,UAAU,IAAI,UAAU;AAC5B,OAAI,CAAC,WAAY,QAAO;AAKxB,OACE,GAAG,WAAW,IAAI,IAClB,GAAG,WAAW,IAAI,IAClB,eAAe,KAAK,GAAG,IACvB,GAAG,WAAW,KAAK,IACnB,GAAG,WAAW,QAAQ,IACtB,GAAG,WAAW,WAAW,CAEzB,QAAO;AAST,OAAI,CAAC,gBAAgB,KAAK,GAAG,CAAE,QAAO;GAEtC,MAAM,MAAO,KACV;AAEH,UADiB,MAAM,WAAW,IAAI,UAAU,IAAI,IACjC;;EAEtB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Debugger } from "obug";
|
|
2
|
+
export type DebugMode = "build" | "dev";
|
|
3
|
+
export interface DebugModeOptions<S extends string = string> {
|
|
4
|
+
scopes?: boolean | S[];
|
|
5
|
+
mode?: DebugMode;
|
|
6
|
+
/**
|
|
7
|
+
* Write debug output to log files under `tmp/debug/` in the workspace root.
|
|
8
|
+
* - `true` or `'single'` — all output to `tmp/debug/analog.log`
|
|
9
|
+
* - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`
|
|
10
|
+
*/
|
|
11
|
+
logFile?: boolean | "single" | "scoped";
|
|
12
|
+
}
|
|
13
|
+
export type DebugOption<S extends string = string> = boolean | S[] | DebugModeOptions<S> | DebugModeOptions<S>[];
|
|
14
|
+
export interface DebugHarness<S extends string = string> {
|
|
15
|
+
applyDebugOption(debug: DebugOption<S> | undefined, workspaceRoot?: string): void;
|
|
16
|
+
activateDeferredDebug(command: "build" | "serve"): void;
|
|
17
|
+
/** @internal test-only reset */
|
|
18
|
+
_resetDeferredDebug(): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function createDebugHarness<S extends string = string>(config: {
|
|
21
|
+
fallbackNamespace: string;
|
|
22
|
+
instanceGroups: Debugger[][];
|
|
23
|
+
}): DebugHarness<S>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog } from "./debug-log-file.js";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { enable } from "obug";
|
|
4
|
+
//#region packages/vite-plugin-angular/src/lib/utils/debug-harness.ts
|
|
5
|
+
/**
|
|
6
|
+
* Duplicates of this file (keep in sync):
|
|
7
|
+
* packages/platform/src/lib/utils/debug-harness.ts
|
|
8
|
+
* packages/vite-plugin-angular/src/lib/utils/debug-harness.ts
|
|
9
|
+
*/
|
|
10
|
+
function resolveNamespaces(scopes, fallback) {
|
|
11
|
+
if (scopes === true || scopes === void 0) return fallback;
|
|
12
|
+
if (Array.isArray(scopes) && scopes.length) return scopes.join(",");
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function extractLogFile(debug) {
|
|
16
|
+
if (typeof debug === "boolean") return false;
|
|
17
|
+
if (Array.isArray(debug)) {
|
|
18
|
+
if (debug.length === 0 || typeof debug[0] === "string") return false;
|
|
19
|
+
return debug.find((e) => !!e.logFile)?.logFile ?? false;
|
|
20
|
+
}
|
|
21
|
+
return debug.logFile ?? false;
|
|
22
|
+
}
|
|
23
|
+
function createDebugHarness(config) {
|
|
24
|
+
let pendingDebug = [];
|
|
25
|
+
function installFileWrappers(logFile, root) {
|
|
26
|
+
if (logFile === "scoped") {
|
|
27
|
+
const dirPath = join(root, DEBUG_LOG_DIR);
|
|
28
|
+
for (const group of config.instanceGroups) wrapInstancesForScopedFileLog(group, dirPath);
|
|
29
|
+
} else {
|
|
30
|
+
const filePath = join(root, DEBUG_LOG_DIR, DEBUG_LOG_FILENAME);
|
|
31
|
+
for (const group of config.instanceGroups) wrapInstancesForFileLog(group, filePath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function applyEntry(entry, fallback, logFile, root) {
|
|
35
|
+
if (!entry.mode) {
|
|
36
|
+
const ns = resolveNamespaces(entry.scopes ?? true, fallback);
|
|
37
|
+
if (ns) enable(ns);
|
|
38
|
+
if (logFile) installFileWrappers(logFile, root);
|
|
39
|
+
} else pendingDebug.push({
|
|
40
|
+
entry,
|
|
41
|
+
logFile,
|
|
42
|
+
root
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
applyDebugOption(debug, workspaceRoot) {
|
|
47
|
+
if (debug == null || debug === false) return;
|
|
48
|
+
const logFile = extractLogFile(debug);
|
|
49
|
+
const root = workspaceRoot ?? process.env["NX_WORKSPACE_ROOT"] ?? process.cwd();
|
|
50
|
+
if (typeof debug === "boolean") {
|
|
51
|
+
const ns = resolveNamespaces(debug, config.fallbackNamespace);
|
|
52
|
+
if (ns) enable(ns);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(debug)) {
|
|
56
|
+
if (debug.length === 0) return;
|
|
57
|
+
if (typeof debug[0] === "string") {
|
|
58
|
+
const ns = debug.join(",");
|
|
59
|
+
if (ns) enable(ns);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
for (const entry of debug) {
|
|
63
|
+
const entryLogFile = entry.logFile ?? false;
|
|
64
|
+
applyEntry(entry, config.fallbackNamespace, entryLogFile || logFile, root);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
applyEntry(debug, config.fallbackNamespace, logFile, root);
|
|
69
|
+
},
|
|
70
|
+
activateDeferredDebug(command) {
|
|
71
|
+
if (pendingDebug.length === 0) return;
|
|
72
|
+
const currentMode = command === "serve" ? "dev" : "build";
|
|
73
|
+
for (const { entry, logFile, root } of pendingDebug) if (entry.mode === currentMode) {
|
|
74
|
+
const ns = resolveNamespaces(entry.scopes ?? true, config.fallbackNamespace);
|
|
75
|
+
if (ns) enable(ns);
|
|
76
|
+
if (logFile) installFileWrappers(logFile, root);
|
|
77
|
+
}
|
|
78
|
+
pendingDebug = [];
|
|
79
|
+
},
|
|
80
|
+
_resetDeferredDebug() {
|
|
81
|
+
pendingDebug = [];
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { createDebugHarness };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=debug-harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-harness.js","names":[],"sources":["../../../../src/lib/utils/debug-harness.ts"],"sourcesContent":["/**\n * Duplicates of this file (keep in sync):\n * packages/platform/src/lib/utils/debug-harness.ts\n * packages/vite-plugin-angular/src/lib/utils/debug-harness.ts\n */\nimport { join } from 'node:path';\nimport { enable } from 'obug';\nimport type { Debugger } from 'obug';\n\nimport {\n DEBUG_LOG_DIR,\n DEBUG_LOG_FILENAME,\n wrapInstancesForFileLog,\n wrapInstancesForScopedFileLog,\n} from './debug-log-file.js';\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions<S extends string = string> {\n scopes?: boolean | S[];\n mode?: DebugMode;\n /**\n * Write debug output to log files under `tmp/debug/` in the workspace root.\n * - `true` or `'single'` — all output to `tmp/debug/analog.log`\n * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`\n */\n logFile?: boolean | 'single' | 'scoped';\n}\n\nexport type DebugOption<S extends string = string> =\n | boolean\n | S[]\n | DebugModeOptions<S>\n | DebugModeOptions<S>[];\n\nexport interface DebugHarness<S extends string = string> {\n applyDebugOption(\n debug: DebugOption<S> | undefined,\n workspaceRoot?: string,\n ): void;\n activateDeferredDebug(command: 'build' | 'serve'): void;\n /** @internal test-only reset */\n _resetDeferredDebug(): void;\n}\n\nfunction resolveNamespaces(\n scopes: boolean | string[] | undefined,\n fallback: string,\n): string | null {\n if (scopes === true || scopes === undefined) return fallback;\n if (Array.isArray(scopes) && scopes.length) return scopes.join(',');\n return null;\n}\n\nfunction extractLogFile(\n debug: DebugOption,\n): true | 'single' | 'scoped' | false {\n if (typeof debug === 'boolean') return false;\n if (Array.isArray(debug)) {\n if (debug.length === 0 || typeof debug[0] === 'string') return false;\n const entry = (debug as DebugModeOptions[]).find((e) => !!e.logFile);\n return entry?.logFile ?? false;\n }\n return (debug as DebugModeOptions).logFile ?? false;\n}\n\nexport function createDebugHarness<S extends string = string>(config: {\n fallbackNamespace: string;\n instanceGroups: Debugger[][];\n}): DebugHarness<S> {\n interface PendingEntry {\n entry: DebugModeOptions<S>;\n logFile: true | 'single' | 'scoped' | false;\n root: string;\n }\n\n let pendingDebug: PendingEntry[] = [];\n\n function installFileWrappers(\n logFile: true | 'single' | 'scoped',\n root: string,\n ): void {\n if (logFile === 'scoped') {\n const dirPath = join(root, DEBUG_LOG_DIR);\n for (const group of config.instanceGroups) {\n wrapInstancesForScopedFileLog(group, dirPath);\n }\n } else {\n const filePath = join(root, DEBUG_LOG_DIR, DEBUG_LOG_FILENAME);\n for (const group of config.instanceGroups) {\n wrapInstancesForFileLog(group, filePath);\n }\n }\n }\n\n function applyEntry(\n entry: DebugModeOptions<S>,\n fallback: string,\n logFile: true | 'single' | 'scoped' | false,\n root: string,\n ): void {\n if (!entry.mode) {\n const ns = resolveNamespaces(entry.scopes ?? true, fallback);\n if (ns) enable(ns);\n if (logFile) installFileWrappers(logFile, root);\n } else {\n pendingDebug.push({ entry, logFile, root });\n }\n }\n\n return {\n applyDebugOption(\n debug: DebugOption<S> | undefined,\n workspaceRoot?: string,\n ): void {\n if (debug == null || debug === false) return;\n\n const logFile = extractLogFile(debug);\n const root =\n workspaceRoot ?? process.env['NX_WORKSPACE_ROOT'] ?? process.cwd();\n\n if (typeof debug === 'boolean') {\n const ns = resolveNamespaces(debug, config.fallbackNamespace);\n if (ns) enable(ns);\n return;\n }\n\n if (Array.isArray(debug)) {\n if (debug.length === 0) return;\n\n if (typeof debug[0] === 'string') {\n const ns = (debug as string[]).join(',');\n if (ns) enable(ns);\n return;\n }\n\n for (const entry of debug as DebugModeOptions<S>[]) {\n const entryLogFile = entry.logFile ?? false;\n applyEntry(\n entry,\n config.fallbackNamespace,\n entryLogFile || logFile,\n root,\n );\n }\n return;\n }\n\n applyEntry(debug, config.fallbackNamespace, logFile, root);\n },\n\n activateDeferredDebug(command: 'build' | 'serve'): void {\n if (pendingDebug.length === 0) return;\n\n const currentMode = command === 'serve' ? 'dev' : 'build';\n\n for (const { entry, logFile, root } of pendingDebug) {\n if (entry.mode === currentMode) {\n const ns = resolveNamespaces(\n entry.scopes ?? true,\n config.fallbackNamespace,\n );\n if (ns) enable(ns);\n if (logFile) installFileWrappers(logFile, root);\n }\n }\n\n pendingDebug = [];\n },\n\n _resetDeferredDebug(): void {\n pendingDebug = [];\n },\n };\n}\n"],"mappings":";;;;;;;;;AA6CA,SAAS,kBACP,QACA,UACe;AACf,KAAI,WAAW,QAAQ,WAAW,KAAA,EAAW,QAAO;AACpD,KAAI,MAAM,QAAQ,OAAO,IAAI,OAAO,OAAQ,QAAO,OAAO,KAAK,IAAI;AACnE,QAAO;;AAGT,SAAS,eACP,OACoC;AACpC,KAAI,OAAO,UAAU,UAAW,QAAO;AACvC,KAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,MAAI,MAAM,WAAW,KAAK,OAAO,MAAM,OAAO,SAAU,QAAO;AAE/D,SADe,MAA6B,MAAM,MAAM,CAAC,CAAC,EAAE,QAAQ,EACtD,WAAW;;AAE3B,QAAQ,MAA2B,WAAW;;AAGhD,SAAgB,mBAA8C,QAG1C;CAOlB,IAAI,eAA+B,EAAE;CAErC,SAAS,oBACP,SACA,MACM;AACN,MAAI,YAAY,UAAU;GACxB,MAAM,UAAU,KAAK,MAAM,cAAc;AACzC,QAAK,MAAM,SAAS,OAAO,eACzB,+BAA8B,OAAO,QAAQ;SAE1C;GACL,MAAM,WAAW,KAAK,MAAM,eAAe,mBAAmB;AAC9D,QAAK,MAAM,SAAS,OAAO,eACzB,yBAAwB,OAAO,SAAS;;;CAK9C,SAAS,WACP,OACA,UACA,SACA,MACM;AACN,MAAI,CAAC,MAAM,MAAM;GACf,MAAM,KAAK,kBAAkB,MAAM,UAAU,MAAM,SAAS;AAC5D,OAAI,GAAI,QAAO,GAAG;AAClB,OAAI,QAAS,qBAAoB,SAAS,KAAK;QAE/C,cAAa,KAAK;GAAE;GAAO;GAAS;GAAM,CAAC;;AAI/C,QAAO;EACL,iBACE,OACA,eACM;AACN,OAAI,SAAS,QAAQ,UAAU,MAAO;GAEtC,MAAM,UAAU,eAAe,MAAM;GACrC,MAAM,OACJ,iBAAiB,QAAQ,IAAI,wBAAwB,QAAQ,KAAK;AAEpE,OAAI,OAAO,UAAU,WAAW;IAC9B,MAAM,KAAK,kBAAkB,OAAO,OAAO,kBAAkB;AAC7D,QAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,OAAI,MAAM,QAAQ,MAAM,EAAE;AACxB,QAAI,MAAM,WAAW,EAAG;AAExB,QAAI,OAAO,MAAM,OAAO,UAAU;KAChC,MAAM,KAAM,MAAmB,KAAK,IAAI;AACxC,SAAI,GAAI,QAAO,GAAG;AAClB;;AAGF,SAAK,MAAM,SAAS,OAAgC;KAClD,MAAM,eAAe,MAAM,WAAW;AACtC,gBACE,OACA,OAAO,mBACP,gBAAgB,SAChB,KACD;;AAEH;;AAGF,cAAW,OAAO,OAAO,mBAAmB,SAAS,KAAK;;EAG5D,sBAAsB,SAAkC;AACtD,OAAI,aAAa,WAAW,EAAG;GAE/B,MAAM,cAAc,YAAY,UAAU,QAAQ;AAElD,QAAK,MAAM,EAAE,OAAO,SAAS,UAAU,aACrC,KAAI,MAAM,SAAS,aAAa;IAC9B,MAAM,KAAK,kBACT,MAAM,UAAU,MAChB,OAAO,kBACR;AACD,QAAI,GAAI,QAAO,GAAG;AAClB,QAAI,QAAS,qBAAoB,SAAS,KAAK;;AAInD,kBAAe,EAAE;;EAGnB,sBAA4B;AAC1B,kBAAe,EAAE;;EAEpB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Debugger } from "obug";
|
|
2
|
+
export declare const DEBUG_LOG_DIR = "tmp/debug";
|
|
3
|
+
export declare const DEBUG_LOG_FILENAME = "analog.log";
|
|
4
|
+
export declare function wrapInstancesForFileLog(instances: Debugger[], filePath: string): void;
|
|
5
|
+
export declare function wrapInstancesForScopedFileLog(instances: Debugger[], dirPath: string): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { format } from "node:util";
|
|
4
|
+
//#region packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts
|
|
5
|
+
/**
|
|
6
|
+
* Duplicates of this file (keep in sync):
|
|
7
|
+
* packages/platform/src/lib/utils/debug-log-file.ts
|
|
8
|
+
* packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts
|
|
9
|
+
*/
|
|
10
|
+
var TRUNCATED_KEY = "__analogDebugLogTruncated";
|
|
11
|
+
var WRAPPED_KEY = "__analogFileLogWrapped";
|
|
12
|
+
var ANSI_RE = /\x1B\[[0-9;]*[A-Za-z]|\x1B\].*?\x07/g;
|
|
13
|
+
var DEBUG_LOG_DIR = "tmp/debug";
|
|
14
|
+
var DEBUG_LOG_FILENAME = "analog.log";
|
|
15
|
+
function ensureTruncated(filePath) {
|
|
16
|
+
const g = globalThis;
|
|
17
|
+
const truncated = g[TRUNCATED_KEY] ?? /* @__PURE__ */ new Set();
|
|
18
|
+
g[TRUNCATED_KEY] = truncated;
|
|
19
|
+
if (truncated.has(filePath)) return;
|
|
20
|
+
try {
|
|
21
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
22
|
+
writeFileSync(filePath, "", "utf-8");
|
|
23
|
+
} catch {}
|
|
24
|
+
truncated.add(filePath);
|
|
25
|
+
}
|
|
26
|
+
function wrapLog(dbg, filePath) {
|
|
27
|
+
const rec = dbg;
|
|
28
|
+
if (rec[WRAPPED_KEY] === filePath) return;
|
|
29
|
+
const originalLog = rec[WRAPPED_KEY] && rec["__analogOriginalLog"] ? rec["__analogOriginalLog"] : dbg.log;
|
|
30
|
+
rec["__analogOriginalLog"] = originalLog;
|
|
31
|
+
dbg.log = function(...args) {
|
|
32
|
+
originalLog.apply(this, args);
|
|
33
|
+
try {
|
|
34
|
+
appendFileSync(filePath, format(...args).replace(ANSI_RE, "") + "\n", "utf-8");
|
|
35
|
+
} catch {}
|
|
36
|
+
};
|
|
37
|
+
rec[WRAPPED_KEY] = filePath;
|
|
38
|
+
}
|
|
39
|
+
function wrapInstancesForFileLog(instances, filePath) {
|
|
40
|
+
ensureTruncated(filePath);
|
|
41
|
+
for (const dbg of instances) wrapLog(dbg, filePath);
|
|
42
|
+
}
|
|
43
|
+
function scopeToFilename(namespace) {
|
|
44
|
+
return namespace.replace(/:/g, ".") + ".log";
|
|
45
|
+
}
|
|
46
|
+
function wrapInstancesForScopedFileLog(instances, dirPath) {
|
|
47
|
+
for (const dbg of instances) {
|
|
48
|
+
const scopedPath = join(dirPath, scopeToFilename(dbg.namespace));
|
|
49
|
+
ensureTruncated(scopedPath);
|
|
50
|
+
wrapLog(dbg, scopedPath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { DEBUG_LOG_DIR, DEBUG_LOG_FILENAME, wrapInstancesForFileLog, wrapInstancesForScopedFileLog };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=debug-log-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug-log-file.js","names":[],"sources":["../../../../src/lib/utils/debug-log-file.ts"],"sourcesContent":["/**\n * Duplicates of this file (keep in sync):\n * packages/platform/src/lib/utils/debug-log-file.ts\n * packages/vite-plugin-angular/src/lib/utils/debug-log-file.ts\n */\nimport { mkdirSync, writeFileSync, appendFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { format } from 'node:util';\nimport type { Debugger } from 'obug';\n\nconst TRUNCATED_KEY = '__analogDebugLogTruncated';\nconst WRAPPED_KEY = '__analogFileLogWrapped';\n// eslint-disable-next-line no-control-regex\nconst ANSI_RE = /\\x1B\\[[0-9;]*[A-Za-z]|\\x1B\\].*?\\x07/g;\n\nexport const DEBUG_LOG_DIR = 'tmp/debug';\nexport const DEBUG_LOG_FILENAME = 'analog.log';\n\nfunction ensureTruncated(filePath: string): void {\n const g = globalThis as Record<string, unknown>;\n const truncated = (g[TRUNCATED_KEY] as Set<string>) ?? new Set<string>();\n g[TRUNCATED_KEY] = truncated;\n if (truncated.has(filePath)) return;\n try {\n mkdirSync(dirname(filePath), { recursive: true });\n writeFileSync(filePath, '', 'utf-8');\n } catch {\n // best-effort: fall through to append mode if truncation fails\n }\n truncated.add(filePath);\n}\n\nfunction wrapLog(dbg: Debugger, filePath: string): void {\n const rec = dbg as Record<string, unknown>;\n if (rec[WRAPPED_KEY] === filePath) return;\n\n const originalLog =\n rec[WRAPPED_KEY] && rec['__analogOriginalLog']\n ? (rec['__analogOriginalLog'] as Debugger['log'])\n : dbg.log;\n\n rec['__analogOriginalLog'] = originalLog;\n dbg.log = function (this: Debugger, ...args: unknown[]) {\n originalLog.apply(this, args);\n try {\n const line = format(...args).replace(ANSI_RE, '') + '\\n';\n appendFileSync(filePath, line, 'utf-8');\n } catch {\n // debug logging must never crash the build\n }\n };\n rec[WRAPPED_KEY] = filePath;\n}\n\nexport function wrapInstancesForFileLog(\n instances: Debugger[],\n filePath: string,\n): void {\n ensureTruncated(filePath);\n for (const dbg of instances) {\n wrapLog(dbg, filePath);\n }\n}\n\nfunction scopeToFilename(namespace: string): string {\n return namespace.replace(/:/g, '.') + '.log';\n}\n\nexport function wrapInstancesForScopedFileLog(\n instances: Debugger[],\n dirPath: string,\n): void {\n for (const dbg of instances) {\n const scopedPath = join(dirPath, scopeToFilename(dbg.namespace));\n ensureTruncated(scopedPath);\n wrapLog(dbg, scopedPath);\n }\n}\n"],"mappings":";;;;;;;;;AAUA,IAAM,gBAAgB;AACtB,IAAM,cAAc;AAEpB,IAAM,UAAU;AAEhB,IAAa,gBAAgB;AAC7B,IAAa,qBAAqB;AAElC,SAAS,gBAAgB,UAAwB;CAC/C,MAAM,IAAI;CACV,MAAM,YAAa,EAAE,kCAAkC,IAAI,KAAa;AACxE,GAAE,iBAAiB;AACnB,KAAI,UAAU,IAAI,SAAS,CAAE;AAC7B,KAAI;AACF,YAAU,QAAQ,SAAS,EAAE,EAAE,WAAW,MAAM,CAAC;AACjD,gBAAc,UAAU,IAAI,QAAQ;SAC9B;AAGR,WAAU,IAAI,SAAS;;AAGzB,SAAS,QAAQ,KAAe,UAAwB;CACtD,MAAM,MAAM;AACZ,KAAI,IAAI,iBAAiB,SAAU;CAEnC,MAAM,cACJ,IAAI,gBAAgB,IAAI,yBACnB,IAAI,yBACL,IAAI;AAEV,KAAI,yBAAyB;AAC7B,KAAI,MAAM,SAA0B,GAAG,MAAiB;AACtD,cAAY,MAAM,MAAM,KAAK;AAC7B,MAAI;AAEF,kBAAe,UADF,OAAO,GAAG,KAAK,CAAC,QAAQ,SAAS,GAAG,GAAG,MACrB,QAAQ;UACjC;;AAIV,KAAI,eAAe;;AAGrB,SAAgB,wBACd,WACA,UACM;AACN,iBAAgB,SAAS;AACzB,MAAK,MAAM,OAAO,UAChB,SAAQ,KAAK,SAAS;;AAI1B,SAAS,gBAAgB,WAA2B;AAClD,QAAO,UAAU,QAAQ,MAAM,IAAI,GAAG;;AAGxC,SAAgB,8BACd,WACA,SACM;AACN,MAAK,MAAM,OAAO,WAAW;EAC3B,MAAM,aAAa,KAAK,SAAS,gBAAgB,IAAI,UAAU,CAAC;AAChE,kBAAgB,WAAW;AAC3B,UAAQ,KAAK,WAAW"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const debugTailwind: unknown;
|
|
2
|
+
export declare const debugHmr: unknown;
|
|
3
|
+
export declare const debugStyles: unknown;
|
|
4
|
+
export declare const debugCompiler: unknown;
|
|
5
|
+
export declare const debugCompilationApi: unknown;
|
|
6
|
+
export declare const debugEmit: unknown;
|
|
7
|
+
export declare const debugStylePipeline: unknown;
|
|
8
|
+
export declare const debugTailwindV: unknown;
|
|
9
|
+
export declare const debugHmrV: unknown;
|
|
10
|
+
export declare const debugStylesV: unknown;
|
|
11
|
+
export declare const debugCompilerV: unknown;
|
|
12
|
+
export declare const debugEmitV: unknown;
|
|
13
|
+
export type DebugScope = "analog:angular:*" | "analog:angular:hmr" | "analog:angular:hmr:v" | "analog:angular:styles" | "analog:angular:styles:v" | "analog:angular:compiler" | "analog:angular:compiler:v" | "analog:angular:compilation-api" | "analog:angular:emit" | "analog:angular:emit:v" | "analog:angular:style-pipeline" | "analog:angular:tailwind" | "analog:angular:tailwind:v" | (string & {});
|
|
14
|
+
export type DebugMode = "build" | "dev";
|
|
15
|
+
export interface DebugModeOptions {
|
|
16
|
+
scopes?: boolean | DebugScope[];
|
|
17
|
+
mode?: DebugMode;
|
|
18
|
+
/**
|
|
19
|
+
* Write debug output to log files under `tmp/debug/` in the workspace root.
|
|
20
|
+
* - `true` or `'single'` — all output to `tmp/debug/analog.log`
|
|
21
|
+
* - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`
|
|
22
|
+
*/
|
|
23
|
+
logFile?: boolean | "single" | "scoped";
|
|
24
|
+
}
|
|
25
|
+
export type DebugOption = boolean | DebugScope[] | DebugModeOptions | DebugModeOptions[];
|
|
26
|
+
export declare const applyDebugOption: (debug: DebugOption | undefined, workspaceRoot?: string) => void;
|
|
27
|
+
export declare const activateDeferredDebug: (command: "build" | "serve") => void;
|
|
28
|
+
export declare const _resetDeferredDebug: () => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createDebugHarness } from "./debug-harness.js";
|
|
2
|
+
import { createDebug } from "obug";
|
|
3
|
+
//#region packages/vite-plugin-angular/src/lib/utils/debug.ts
|
|
4
|
+
var debugTailwind = createDebug("analog:angular:tailwind");
|
|
5
|
+
var debugHmr = createDebug("analog:angular:hmr");
|
|
6
|
+
var debugStyles = createDebug("analog:angular:styles");
|
|
7
|
+
var debugCompiler = createDebug("analog:angular:compiler");
|
|
8
|
+
var debugCompilationApi = createDebug("analog:angular:compilation-api");
|
|
9
|
+
var debugEmit = createDebug("analog:angular:emit");
|
|
10
|
+
var debugStylePipeline = createDebug("analog:angular:style-pipeline");
|
|
11
|
+
var debugTailwindV = createDebug("analog:angular:tailwind:v");
|
|
12
|
+
var debugHmrV = createDebug("analog:angular:hmr:v");
|
|
13
|
+
var debugStylesV = createDebug("analog:angular:styles:v");
|
|
14
|
+
var debugCompilerV = createDebug("analog:angular:compiler:v");
|
|
15
|
+
var debugEmitV = createDebug("analog:angular:emit:v");
|
|
16
|
+
var harness = createDebugHarness({
|
|
17
|
+
fallbackNamespace: "analog:angular:*",
|
|
18
|
+
instanceGroups: [[
|
|
19
|
+
debugTailwind,
|
|
20
|
+
debugHmr,
|
|
21
|
+
debugStyles,
|
|
22
|
+
debugCompiler,
|
|
23
|
+
debugCompilationApi,
|
|
24
|
+
debugEmit,
|
|
25
|
+
debugStylePipeline,
|
|
26
|
+
debugTailwindV,
|
|
27
|
+
debugHmrV,
|
|
28
|
+
debugStylesV,
|
|
29
|
+
debugCompilerV,
|
|
30
|
+
debugEmitV
|
|
31
|
+
]]
|
|
32
|
+
});
|
|
33
|
+
var applyDebugOption = harness.applyDebugOption;
|
|
34
|
+
var activateDeferredDebug = harness.activateDeferredDebug;
|
|
35
|
+
harness._resetDeferredDebug;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { activateDeferredDebug, applyDebugOption, debugCompilationApi, debugCompiler, debugCompilerV, debugEmit, debugEmitV, debugHmr, debugHmrV, debugStylePipeline, debugStyles, debugStylesV, debugTailwind, debugTailwindV };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","names":[],"sources":["../../../../src/lib/utils/debug.ts"],"sourcesContent":["import { createDebug } from 'obug';\nimport { createDebugHarness } from './debug-harness.js';\n\n// Normal — key decisions, once per startup or per component\nexport const debugTailwind = createDebug('analog:angular:tailwind');\nexport const debugHmr = createDebug('analog:angular:hmr');\nexport const debugStyles = createDebug('analog:angular:styles');\nexport const debugCompiler = createDebug('analog:angular:compiler');\nexport const debugCompilationApi = createDebug(\n 'analog:angular:compilation-api',\n);\nexport const debugEmit = createDebug('analog:angular:emit');\nexport const debugStylePipeline = createDebug('analog:angular:style-pipeline');\n\n// Verbose — per-file detail, enable with :v suffix or parent:*\nexport const debugTailwindV = createDebug('analog:angular:tailwind:v');\nexport const debugHmrV = createDebug('analog:angular:hmr:v');\nexport const debugStylesV = createDebug('analog:angular:styles:v');\nexport const debugCompilerV = createDebug('analog:angular:compiler:v');\nexport const debugEmitV = createDebug('analog:angular:emit:v');\n\nconst angularDebugInstances = [\n debugTailwind,\n debugHmr,\n debugStyles,\n debugCompiler,\n debugCompilationApi,\n debugEmit,\n debugStylePipeline,\n debugTailwindV,\n debugHmrV,\n debugStylesV,\n debugCompilerV,\n debugEmitV,\n];\n\nexport type DebugScope =\n | 'analog:angular:*'\n | 'analog:angular:hmr'\n | 'analog:angular:hmr:v'\n | 'analog:angular:styles'\n | 'analog:angular:styles:v'\n | 'analog:angular:compiler'\n | 'analog:angular:compiler:v'\n | 'analog:angular:compilation-api'\n | 'analog:angular:emit'\n | 'analog:angular:emit:v'\n | 'analog:angular:style-pipeline'\n | 'analog:angular:tailwind'\n | 'analog:angular:tailwind:v'\n | (string & {});\n\nexport type DebugMode = 'build' | 'dev';\n\nexport interface DebugModeOptions {\n scopes?: boolean | DebugScope[];\n mode?: DebugMode;\n /**\n * Write debug output to log files under `tmp/debug/` in the workspace root.\n * - `true` or `'single'` — all output to `tmp/debug/analog.log`\n * - `'scoped'` — one file per scope, e.g. `tmp/debug/analog.angular.hmr.log`\n */\n logFile?: boolean | 'single' | 'scoped';\n}\n\nexport type DebugOption =\n | boolean\n | DebugScope[]\n | DebugModeOptions\n | DebugModeOptions[];\n\nconst harness = createDebugHarness({\n fallbackNamespace: 'analog:angular:*',\n instanceGroups: [angularDebugInstances],\n});\n\nexport const applyDebugOption: (\n debug: DebugOption | undefined,\n workspaceRoot?: string,\n) => void = harness.applyDebugOption;\nexport const activateDeferredDebug: (command: 'build' | 'serve') => void =\n harness.activateDeferredDebug;\nexport const _resetDeferredDebug: () => void = harness._resetDeferredDebug;\n"],"mappings":";;;AAIA,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,WAAW,YAAY,qBAAqB;AACzD,IAAa,cAAc,YAAY,wBAAwB;AAC/D,IAAa,gBAAgB,YAAY,0BAA0B;AACnE,IAAa,sBAAsB,YACjC,iCACD;AACD,IAAa,YAAY,YAAY,sBAAsB;AAC3D,IAAa,qBAAqB,YAAY,gCAAgC;AAG9E,IAAa,iBAAiB,YAAY,4BAA4B;AACtE,IAAa,YAAY,YAAY,uBAAuB;AAC5D,IAAa,eAAe,YAAY,0BAA0B;AAClE,IAAa,iBAAiB,YAAY,4BAA4B;AACtE,IAAa,aAAa,YAAY,wBAAwB;AAoD9D,IAAM,UAAU,mBAAmB;CACjC,mBAAmB;CACnB,gBAAgB,CApDY;EAC5B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAuCwC;CACxC,CAAC;AAEF,IAAa,mBAGD,QAAQ;AACpB,IAAa,wBACX,QAAQ;AACqC,QAAQ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { CompilerPluginOptions } from
|
|
2
|
-
declare const angularMajor:
|
|
3
|
-
declare const angularMinor:
|
|
4
|
-
declare const angularPatch:
|
|
5
|
-
declare const angularFullVersion:
|
|
1
|
+
import type { CompilerPluginOptions } from "./compiler-plugin-options.js";
|
|
2
|
+
declare const angularMajor: unknown;
|
|
3
|
+
declare const angularMinor: unknown;
|
|
4
|
+
declare const angularPatch: unknown;
|
|
5
|
+
declare const angularFullVersion: unknown;
|
|
6
6
|
declare let sourceFileCache: any;
|
|
7
7
|
declare let cjt: (...args: any[]) => any;
|
|
8
8
|
declare let jt: any;
|
|
9
9
|
declare let createAngularCompilation: (...args: any[]) => any;
|
|
10
|
-
export { cjt as createJitResourceTransformer, jt as JavaScriptTransformer, sourceFileCache as SourceFileCache, CompilerPluginOptions, angularMajor, angularMinor, angularPatch, createAngularCompilation, angularFullVersion
|
|
10
|
+
export { cjt as createJitResourceTransformer, jt as JavaScriptTransformer, sourceFileCache as SourceFileCache, CompilerPluginOptions, angularMajor, angularMinor, angularPatch, createAngularCompilation, angularFullVersion };
|
package/src/lib/utils/devkit.js
CHANGED
|
@@ -1,41 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
1
|
+
import { SourceFileCache } from "./source-file-cache.js";
|
|
2
|
+
import { VERSION } from "@angular/compiler-cli";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
//#region packages/vite-plugin-angular/src/lib/utils/devkit.ts
|
|
5
|
+
var require = createRequire(import.meta.url);
|
|
6
|
+
var angularMajor = Number(VERSION.major);
|
|
7
|
+
var angularMinor = Number(VERSION.minor);
|
|
8
|
+
var angularPatch = Number(VERSION.patch);
|
|
9
|
+
var padVersion = (version) => String(version).padStart(2, "0");
|
|
10
|
+
var angularFullVersion = Number(`${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`);
|
|
11
|
+
var sourceFileCache;
|
|
12
|
+
var cjt;
|
|
13
|
+
var jt;
|
|
14
|
+
var createAngularCompilation;
|
|
15
|
+
if (angularMajor < 17) throw new Error("AnalogJS is not compatible with Angular v16 and lower");
|
|
17
16
|
else if (angularMajor >= 17 && angularMajor < 18) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const { createJitResourceTransformer, JavaScriptTransformer, SourceFileCache, createAngularCompilation: createAngularCompilationFn, } = require('@angular/build/private');
|
|
35
|
-
sourceFileCache = SourceFileCache;
|
|
36
|
-
cjt = createJitResourceTransformer;
|
|
37
|
-
jt = JavaScriptTransformer;
|
|
38
|
-
createAngularCompilation = createAngularCompilationFn;
|
|
17
|
+
const cp = require("@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js");
|
|
18
|
+
const { createJitResourceTransformer } = require("@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js");
|
|
19
|
+
const { JavaScriptTransformer } = require("@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js");
|
|
20
|
+
/**
|
|
21
|
+
* Workaround for compatibility with Angular 17.0+
|
|
22
|
+
*/
|
|
23
|
+
if (typeof cp["SourceFileCache"] !== "undefined") sourceFileCache = cp.SourceFileCache;
|
|
24
|
+
else sourceFileCache = SourceFileCache;
|
|
25
|
+
cjt = createJitResourceTransformer;
|
|
26
|
+
jt = JavaScriptTransformer;
|
|
27
|
+
} else {
|
|
28
|
+
const { createJitResourceTransformer, JavaScriptTransformer, SourceFileCache, createAngularCompilation: createAngularCompilationFn } = require("@angular/build/private");
|
|
29
|
+
sourceFileCache = SourceFileCache;
|
|
30
|
+
cjt = createJitResourceTransformer;
|
|
31
|
+
jt = JavaScriptTransformer;
|
|
32
|
+
createAngularCompilation = createAngularCompilationFn;
|
|
39
33
|
}
|
|
40
|
-
|
|
34
|
+
//#endregion
|
|
35
|
+
export { angularFullVersion, cjt, createAngularCompilation, jt, sourceFileCache };
|
|
36
|
+
|
|
41
37
|
//# sourceMappingURL=devkit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devkit.js","
|
|
1
|
+
{"version":3,"file":"devkit.js","names":[],"sources":["../../../../src/lib/utils/devkit.ts"],"sourcesContent":["import { VERSION } from '@angular/compiler-cli';\nimport { createRequire } from 'node:module';\nimport type { CompilerPluginOptions } from './compiler-plugin-options.js';\nimport * as sfc from './source-file-cache.js';\n\nconst require = createRequire(import.meta.url);\n\nconst angularMajor = Number(VERSION.major);\nconst angularMinor = Number(VERSION.minor);\nconst angularPatch = Number(VERSION.patch);\nconst padVersion = (version: number) => String(version).padStart(2, '0');\nconst angularFullVersion = Number(\n `${angularMajor}${padVersion(angularMinor)}${padVersion(angularPatch)}`,\n);\nlet sourceFileCache: any;\nlet cjt: (...args: any[]) => any;\nlet jt: any;\nlet createAngularCompilation: (...args: any[]) => any;\n\nif (angularMajor < 17) {\n throw new Error('AnalogJS is not compatible with Angular v16 and lower');\n} else if (angularMajor >= 17 && angularMajor < 18) {\n const cp = require('@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js');\n const {\n createJitResourceTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/angular/jit-resource-transformer.js');\n const {\n JavaScriptTransformer,\n } = require('@angular-devkit/build-angular/src/tools/esbuild/javascript-transformer.js');\n\n /**\n * Workaround for compatibility with Angular 17.0+\n */\n if (typeof cp['SourceFileCache'] !== 'undefined') {\n sourceFileCache = cp.SourceFileCache;\n } else {\n sourceFileCache = sfc.SourceFileCache;\n }\n\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n} else {\n const {\n createJitResourceTransformer,\n JavaScriptTransformer,\n SourceFileCache,\n createAngularCompilation: createAngularCompilationFn,\n } = require('@angular/build/private');\n\n sourceFileCache = SourceFileCache;\n cjt = createJitResourceTransformer;\n jt = JavaScriptTransformer;\n createAngularCompilation = createAngularCompilationFn;\n}\n\nexport {\n cjt as createJitResourceTransformer,\n jt as JavaScriptTransformer,\n sourceFileCache as SourceFileCache,\n CompilerPluginOptions,\n angularMajor,\n angularMinor,\n angularPatch,\n createAngularCompilation,\n angularFullVersion,\n};\n"],"mappings":";;;;AAKA,IAAM,UAAU,cAAc,OAAO,KAAK,IAAI;AAE9C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,eAAe,OAAO,QAAQ,MAAM;AAC1C,IAAM,cAAc,YAAoB,OAAO,QAAQ,CAAC,SAAS,GAAG,IAAI;AACxE,IAAM,qBAAqB,OACzB,GAAG,eAAe,WAAW,aAAa,GAAG,WAAW,aAAa,GACtE;AACD,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAEJ,IAAI,eAAe,GACjB,OAAM,IAAI,MAAM,wDAAwD;SAC/D,gBAAgB,MAAM,eAAe,IAAI;CAClD,MAAM,KAAK,QAAQ,6EAA6E;CAChG,MAAM,EACJ,iCACE,QAAQ,sFAAsF;CAClG,MAAM,EACJ,0BACE,QAAQ,4EAA4E;;;;AAKxF,KAAI,OAAO,GAAG,uBAAuB,YACnC,mBAAkB,GAAG;KAErB,mBAAkB;AAGpB,OAAM;AACN,MAAK;OACA;CACL,MAAM,EACJ,8BACA,uBACA,iBACA,0BAA0B,+BACxB,QAAQ,yBAAyB;AAErC,mBAAkB;AAClB,OAAM;AACN,MAAK;AACL,4BAA2B"}
|