@analogjs/vite-plugin-angular 3.0.0-alpha.99 → 3.0.0-beta.2
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/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/migrations/update-3-0-0/migrate-setup-vitest.js +3 -2
- package/migrations/update-3-0-0/migrate-setup-vitest.js.map +1 -1
- package/package.json +1 -1
- 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 +20 -7
- 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 +22 -19
- 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.js +1 -1
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.js +9 -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.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 +3 -2
- 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 +2 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/migrate-setup-vitest/migrate-setup-vitest.ts"],"sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\n\nfunction addVitestAngularDependency(\n tree: Tree,\n context: SchematicContext,\n): void {\n const pkgPath = '/package.json';\n const content = tree.read(pkgPath);\n if (!content) {\n return;\n }\n\n const pkg = JSON.parse(content.toString('utf-8'));\n const devDeps = pkg['devDependencies'] || {};\n const deps = pkg['dependencies'] || {};\n\n if (\n !devDeps['@analogjs/vitest-angular'] &&\n !deps['@analogjs/vitest-angular']\n ) {\n const analogVersion =\n devDeps['@analogjs/vite-plugin-angular'] ||\n deps['@analogjs/vite-plugin-angular'] ||\n '*';\n\n pkg['devDependencies'] = {\n ...devDeps,\n '@analogjs/vitest-angular': analogVersion,\n };\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\\n');\n context.addTask(new NodePackageInstallTask());\n context.logger.info(\n `Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`,\n );\n }\n}\n\nexport default function migrateSetupVitest(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const filesToUpdate: string[] = [];\n\n tree.visit((filePath) => {\n if (\n !filePath.endsWith('.ts') &&\n !filePath.endsWith('.mts') &&\n !filePath.endsWith('.js') &&\n !filePath.endsWith('.mjs')\n ) {\n return;\n }\n if (filePath.includes('/node_modules/')) {\n return;\n }\n\n const content = tree.read(filePath);\n if (!content) {\n return;\n }\n\n const text = content.toString('utf-8');\n if (text.includes(OLD_IMPORT)) {\n const updated = text.replace(\n new RegExp(OLD_IMPORT.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n NEW_IMPORT,\n );\n tree.overwrite(filePath, updated);\n filesToUpdate.push(filePath);\n }\n });\n\n if (filesToUpdate.length > 0) {\n context.logger.info(\n `Migrated ${filesToUpdate.length} file(s) from '${OLD_IMPORT}' to '${NEW_IMPORT}':`,\n );\n for (const file of filesToUpdate) {\n context.logger.info(` - ${file}`);\n }\n }\n\n if (filesToUpdate.length > 0) {\n addVitestAngularDependency(tree, context);\n }\n\n return tree;\n };\n}\n"],"mappings":";;AAGA,IAAM,aAAa;AACnB,IAAM,aAAa;AAEnB,SAAS,2BACP,MACA,SACM;CACN,MAAM,UAAU;CAChB,MAAM,UAAU,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"migrate-setup-vitest.js","names":[],"sources":["../../../migrations/migrate-setup-vitest/migrate-setup-vitest.ts"],"sourcesContent":["import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\n\nconst OLD_IMPORT = '@analogjs/vite-plugin-angular/setup-vitest';\nconst NEW_IMPORT = '@analogjs/vitest-angular/setup-zone';\n\nfunction addVitestAngularDependency(\n tree: Tree,\n context: SchematicContext,\n): void {\n const pkgPath = '/package.json';\n const content = tree.read(pkgPath);\n if (!content) {\n return;\n }\n\n const pkg = JSON.parse(content.toString('utf-8'));\n const devDeps = pkg['devDependencies'] || {};\n const deps = pkg['dependencies'] || {};\n\n if (\n !devDeps['@analogjs/vitest-angular'] &&\n !deps['@analogjs/vitest-angular']\n ) {\n const analogVersion =\n devDeps['@analogjs/vite-plugin-angular'] ||\n deps['@analogjs/vite-plugin-angular'] ||\n '*';\n\n pkg['devDependencies'] = {\n ...devDeps,\n '@analogjs/vitest-angular': analogVersion,\n };\n\n tree.overwrite(pkgPath, JSON.stringify(pkg, null, 2) + '\\n');\n context.addTask(new NodePackageInstallTask());\n context.logger.info(\n `Added '@analogjs/vitest-angular': '${analogVersion}' to devDependencies.`,\n );\n }\n}\n\nexport default function migrateSetupVitest(): Rule {\n return (tree: Tree, context: SchematicContext) => {\n const filesToUpdate: string[] = [];\n\n tree.visit((filePath) => {\n if (\n !filePath.endsWith('.ts') &&\n !filePath.endsWith('.mts') &&\n !filePath.endsWith('.js') &&\n !filePath.endsWith('.mjs')\n ) {\n return;\n }\n if (filePath.includes('/node_modules/')) {\n return;\n }\n\n const content = tree.read(filePath);\n if (!content) {\n return;\n }\n\n const text = content.toString('utf-8');\n if (text.includes(OLD_IMPORT)) {\n const updated = text.replace(\n new RegExp(OLD_IMPORT.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'), 'g'),\n NEW_IMPORT,\n );\n tree.overwrite(filePath, updated);\n filesToUpdate.push(filePath);\n }\n });\n\n if (filesToUpdate.length > 0) {\n context.logger.info(\n `Migrated ${filesToUpdate.length} file(s) from '${OLD_IMPORT}' to '${NEW_IMPORT}':`,\n );\n for (const file of filesToUpdate) {\n context.logger.info(` - ${file}`);\n }\n }\n\n if (filesToUpdate.length > 0) {\n addVitestAngularDependency(tree, context);\n }\n\n return tree;\n };\n}\n"],"mappings":";;AAGA,IAAM,aAAa;AACnB,IAAM,aAAa;AAEnB,SAAS,2BACP,MACA,SACM;CACN,MAAM,UAAU;CAChB,MAAM,UAAU,KAAK,KAAK,OAAO;CACjC,IAAI,CAAC,SACH;CAGF,MAAM,MAAM,KAAK,MAAM,QAAQ,SAAS,OAAO,CAAC;CAChD,MAAM,UAAU,IAAI,sBAAsB,CAAC;CAC3C,MAAM,OAAO,IAAI,mBAAmB,CAAC;CAErC,IACE,CAAC,QAAQ,+BACT,CAAC,KAAK,6BACN;EACA,MAAM,gBACJ,QAAQ,oCACR,KAAK,oCACL;EAEF,IAAI,qBAAqB;GACvB,GAAG;GACH,4BAA4B;EAC9B;EAEA,KAAK,UAAU,SAAS,KAAK,UAAU,KAAK,MAAM,CAAC,IAAI,IAAI;EAC3D,QAAQ,QAAQ,IAAI,uBAAuB,CAAC;EAC5C,QAAQ,OAAO,KACb,sCAAsC,cAAc,sBACtD;CACF;AACF;AAEA,SAAwB,qBAA2B;CACjD,QAAQ,MAAY,YAA8B;EAChD,MAAM,gBAA0B,CAAC;EAEjC,KAAK,OAAO,aAAa;GACvB,IACE,CAAC,SAAS,SAAS,KAAK,KACxB,CAAC,SAAS,SAAS,MAAM,KACzB,CAAC,SAAS,SAAS,KAAK,KACxB,CAAC,SAAS,SAAS,MAAM,GAEzB;GAEF,IAAI,SAAS,SAAS,gBAAgB,GACpC;GAGF,MAAM,UAAU,KAAK,KAAK,QAAQ;GAClC,IAAI,CAAC,SACH;GAGF,MAAM,OAAO,QAAQ,SAAS,OAAO;GACrC,IAAI,KAAK,SAAS,UAAU,GAAG;IAC7B,MAAM,UAAU,KAAK,QACnB,IAAI,OAAO,WAAW,QAAQ,uBAAuB,MAAM,GAAG,GAAG,GACjE,UACF;IACA,KAAK,UAAU,UAAU,OAAO;IAChC,cAAc,KAAK,QAAQ;GAC7B;EACF,CAAC;EAED,IAAI,cAAc,SAAS,GAAG;GAC5B,QAAQ,OAAO,KACb,YAAY,cAAc,OAAO,iBAAiB,WAAW,QAAQ,WAAW,GAClF;GACA,KAAK,MAAM,QAAQ,eACjB,QAAQ,OAAO,KAAK,OAAO,MAAM;EAErC;EAEA,IAAI,cAAc,SAAS,GACzB,2BAA2B,MAAM,OAAO;EAG1C,OAAO;CACT;AACF"}
|
|
@@ -2,7 +2,7 @@ import { addDependenciesToPackageJson, readJson, runTasksInSerial, visitNotIgnor
|
|
|
2
2
|
//#region packages/vite-plugin-angular/migrations/update-3-0-0/migrate-setup-vitest.ts
|
|
3
3
|
var OLD_IMPORT = "@analogjs/vite-plugin-angular/setup-vitest";
|
|
4
4
|
var NEW_IMPORT = "@analogjs/vitest-angular/setup-zone";
|
|
5
|
-
var SUPPORTED_EXTENSIONS = new Set([
|
|
5
|
+
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6
6
|
".cjs",
|
|
7
7
|
".cts",
|
|
8
8
|
".js",
|
|
@@ -28,7 +28,8 @@ async function migrateSetupVitest(tree) {
|
|
|
28
28
|
filesToUpdate.push(filePath);
|
|
29
29
|
});
|
|
30
30
|
if (filesToUpdate.length === 0) return;
|
|
31
|
-
|
|
31
|
+
const installTask = addDependenciesToPackageJson(tree, {}, { "@analogjs/vitest-angular": getAnalogVersion(tree) }, "package.json", true);
|
|
32
|
+
return runTasksInSerial(installTask);
|
|
32
33
|
}
|
|
33
34
|
//#endregion
|
|
34
35
|
export { migrateSetupVitest as default };
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,uCAAuB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,iBAAiB,MAAoB;CAC5C,IAAI,CAAC,KAAK,OAAO,cAAc,GAC7B,OAAO;CAGT,MAAM,cAAc,SAGjB,MAAM,cAAc;CAEvB,OACE,YAAY,kBAAkB,oCAC9B,YAAY,eAAe,oCAC3B;AAEJ;AAEA,eAA8B,mBAAmB,MAAY;CAC3D,MAAM,gBAA0B,CAAC;CAEjC,qBAAqB,MAAM,KAAK,aAAa;EAC3C,MAAM,YAAY,SAAS,MAAM,SAAS,YAAY,GAAG,CAAC;EAC1D,IAAI,CAAC,qBAAqB,IAAI,SAAS,GACrC;EAGF,MAAM,UAAU,KAAK,KAAK,UAAU,OAAO;EAC3C,IAAI,CAAC,SAAS,SAAS,UAAU,GAC/B;EAGF,KAAK,MAAM,UAAU,QAAQ,WAAW,YAAY,UAAU,CAAC;EAC/D,cAAc,KAAK,QAAQ;CAC7B,CAAC;CAED,IAAI,cAAc,WAAW,GAC3B;CAGF,MAAM,cAAc,6BAClB,MACA,CAAC,GACD,EACE,4BAA4B,iBAAiB,IAAI,EACnD,GACA,gBACA,IACF;CAEA,OAAO,iBAAiB,WAAW;AACrC"}
|
package/package.json
CHANGED
|
@@ -92,6 +92,6 @@ function describeError(error) {
|
|
|
92
92
|
return error instanceof Error ? error.message : String(error);
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
|
-
export { discoverAnalogIntegrations };
|
|
95
|
+
export { discoverAnalogIntegrations, runAnalogSetupHooks };
|
|
96
96
|
|
|
97
97
|
//# sourceMappingURL=analog-plugin-interop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analog-plugin-interop.js","names":[],"sources":["../../../src/lib/analog-plugin-interop.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from 'vite';\nimport {\n composeStylePreprocessors,\n type StylePreprocessor,\n type StylesheetRegistryReader,\n} from './style-preprocessor.js';\nimport type { RegistryEntry } from './compiler/registry.js';\nimport { debugStylePipeline } from './utils/debug.js';\n\nexport type TransformFilter = (code: string, id: string) => boolean;\n\nexport type ComponentRegistryEntries = ReadonlyMap<string, RegistryEntry>;\n\nexport interface StylesheetRegistryContext {\n workspaceRoot: string;\n}\n\nexport type StylesheetRegistryConfigurator = (\n registry: StylesheetRegistryReader,\n context: StylesheetRegistryContext,\n) => void;\n\n/**\n * Narrow framework context handed to a Vite plugin's `analog.setup()` hook.\n * Only grows when a concrete integration needs another seam.\n */\nexport interface AnalogPluginContext {\n /**\n * Registers a pre-transform that runs on every Angular component stylesheet\n * before it enters Vite's `preprocessCSS` pipeline.\n */\n registerStylePreprocessor(preprocessor: StylePreprocessor): void;\n /**\n * Requests that component styles are externalized in dev and watch mode so\n * they run through Vite's CSS plugin pipeline (for example\n * `@tailwindcss/vite`) instead of being inlined through `preprocessCSS`,\n * which only runs PostCSS and CSS preprocessors. Production builds keep\n * inlining component styles.\n */\n externalizeComponentStyles(): void;\n /**\n * Receives the live stylesheet registry for externalized component styles\n * each time a compilation creates one, so the plugin can map component\n * stylesheet sources to their served ids, dependencies, and diagnostics.\n */\n configureStylesheetRegistry(configure: StylesheetRegistryConfigurator): void;\n /**\n * Restricts which modules Angular compiles. A module is transformed only\n * when every registered filter returns `true` for it.\n */\n registerTransformFilter(filter: TransformFilter): void;\n /**\n * Contributes directive, component, pipe, and NgModule metadata keyed by\n * class name for classes the fast compiler cannot reach through its own\n * tsconfig-driven scan (for example components compiled from another\n * source format). The map is read on every compile, so a plugin may keep\n * filling it after setup.\n */\n registerComponentRegistry(entries: ComponentRegistryEntries): void;\n /**\n * Adds TypeScript include globs to the Angular compilation. Globs resolve\n * against the same workspace root as `angular({ include })`, so a leading\n * `/` means workspace-relative.\n */\n addInclude(globs: string[]): void;\n}\n\nexport interface AnalogPluginHooks {\n setup?(context: AnalogPluginContext): void | Promise<void>;\n}\n\n/**\n * A normal Vite plugin that optionally exposes an `analog` setup hook.\n * Discovery is structural (`plugin.analog?.setup`), so this type is a DX aid\n * rather than a requirement.\n */\nexport type AnalogIntegrationPlugin = Plugin & { analog?: AnalogPluginHooks };\n\nexport interface AnalogIntegrations {\n stylePreprocessor?: StylePreprocessor;\n configureStylesheetRegistry?: StylesheetRegistryConfigurator;\n transformFilter?: TransformFilter;\n componentRegistries: ComponentRegistryEntries[];\n include: string[];\n externalizeStyles: boolean;\n}\n\nconst integrationsByConfig = new WeakMap<\n ResolvedConfig,\n Promise<AnalogIntegrations>\n>();\n\n/**\n * Runs every `analog.setup()` hook found in the resolved Vite plugin list,\n * once per resolved config, and composes the registrations in plugin order.\n */\nexport function discoverAnalogIntegrations(\n config: ResolvedConfig,\n): Promise<AnalogIntegrations> {\n let pending = integrationsByConfig.get(config);\n if (!pending) {\n pending = runAnalogSetupHooks(config.plugins ?? []);\n integrationsByConfig.set(config, pending);\n }\n return pending;\n}\n\nexport async function runAnalogSetupHooks(\n plugins: readonly Plugin[],\n): Promise<AnalogIntegrations> {\n const preprocessors: StylePreprocessor[] = [];\n const registryConfigurators: StylesheetRegistryConfigurator[] = [];\n const transformFilters: TransformFilter[] = [];\n const componentRegistries: ComponentRegistryEntries[] = [];\n const include: string[] = [];\n let externalizeStyles = false;\n\n for (const plugin of plugins as readonly AnalogIntegrationPlugin[]) {\n if (typeof plugin.analog?.setup !== 'function') {\n continue;\n }\n\n const registeredBefore = preprocessors.length;\n const context: AnalogPluginContext = {\n registerStylePreprocessor(preprocessor) {\n preprocessors.push(wrapStylePreprocessor(plugin.name, preprocessor));\n },\n externalizeComponentStyles() {\n externalizeStyles = true;\n },\n configureStylesheetRegistry(configure) {\n registryConfigurators.push(\n wrapRegistryConfigurator(plugin.name, configure),\n );\n },\n registerTransformFilter(filter) {\n transformFilters.push(filter);\n },\n registerComponentRegistry(entries) {\n componentRegistries.push(entries);\n },\n addInclude(globs) {\n include.push(...globs);\n },\n };\n\n try {\n await plugin.analog.setup(context);\n } catch (error) {\n throw new Error(\n `[analog] analog.setup() from plugin \"${plugin.name}\" failed: ${describeError(error)}`,\n );\n }\n\n debugStylePipeline('analog.setup() completed', {\n plugin: plugin.name,\n stylePreprocessors: preprocessors.length - registeredBefore,\n registryConfigurators: registryConfigurators.length,\n transformFilters: transformFilters.length,\n componentRegistries: componentRegistries.length,\n include: include.length,\n externalizeStyles,\n });\n }\n\n return {\n stylePreprocessor: composeStylePreprocessors(preprocessors),\n configureStylesheetRegistry: registryConfigurators.length\n ? (registry, context) => {\n for (const configure of registryConfigurators) {\n configure(registry, context);\n }\n }\n : undefined,\n transformFilter: transformFilters.length\n ? (code, id) => transformFilters.every((filter) => filter(code, id))\n : undefined,\n componentRegistries,\n include,\n externalizeStyles,\n };\n}\n\nfunction wrapStylePreprocessor(\n pluginName: string,\n preprocessor: StylePreprocessor,\n): StylePreprocessor {\n return (code, filename, context) => {\n try {\n return preprocessor(code, filename, context);\n } catch (error) {\n throw new Error(\n `[analog] Style preprocessor from plugin \"${pluginName}\" failed for \"${filename}\": ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction wrapRegistryConfigurator(\n pluginName: string,\n configure: StylesheetRegistryConfigurator,\n): StylesheetRegistryConfigurator {\n return (registry, context) => {\n try {\n configure(registry, context);\n } catch (error) {\n throw new Error(\n `[analog] Stylesheet registry configurator from plugin \"${pluginName}\" failed: ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;AAuFA,IAAM,uCAAuB,IAAI,
|
|
1
|
+
{"version":3,"file":"analog-plugin-interop.js","names":[],"sources":["../../../src/lib/analog-plugin-interop.ts"],"sourcesContent":["import type { Plugin, ResolvedConfig } from 'vite';\nimport {\n composeStylePreprocessors,\n type StylePreprocessor,\n type StylesheetRegistryReader,\n} from './style-preprocessor.js';\nimport type { RegistryEntry } from './compiler/registry.js';\nimport { debugStylePipeline } from './utils/debug.js';\n\nexport type TransformFilter = (code: string, id: string) => boolean;\n\nexport type ComponentRegistryEntries = ReadonlyMap<string, RegistryEntry>;\n\nexport interface StylesheetRegistryContext {\n workspaceRoot: string;\n}\n\nexport type StylesheetRegistryConfigurator = (\n registry: StylesheetRegistryReader,\n context: StylesheetRegistryContext,\n) => void;\n\n/**\n * Narrow framework context handed to a Vite plugin's `analog.setup()` hook.\n * Only grows when a concrete integration needs another seam.\n */\nexport interface AnalogPluginContext {\n /**\n * Registers a pre-transform that runs on every Angular component stylesheet\n * before it enters Vite's `preprocessCSS` pipeline.\n */\n registerStylePreprocessor(preprocessor: StylePreprocessor): void;\n /**\n * Requests that component styles are externalized in dev and watch mode so\n * they run through Vite's CSS plugin pipeline (for example\n * `@tailwindcss/vite`) instead of being inlined through `preprocessCSS`,\n * which only runs PostCSS and CSS preprocessors. Production builds keep\n * inlining component styles.\n */\n externalizeComponentStyles(): void;\n /**\n * Receives the live stylesheet registry for externalized component styles\n * each time a compilation creates one, so the plugin can map component\n * stylesheet sources to their served ids, dependencies, and diagnostics.\n */\n configureStylesheetRegistry(configure: StylesheetRegistryConfigurator): void;\n /**\n * Restricts which modules Angular compiles. A module is transformed only\n * when every registered filter returns `true` for it.\n */\n registerTransformFilter(filter: TransformFilter): void;\n /**\n * Contributes directive, component, pipe, and NgModule metadata keyed by\n * class name for classes the fast compiler cannot reach through its own\n * tsconfig-driven scan (for example components compiled from another\n * source format). The map is read on every compile, so a plugin may keep\n * filling it after setup.\n */\n registerComponentRegistry(entries: ComponentRegistryEntries): void;\n /**\n * Adds TypeScript include globs to the Angular compilation. Globs resolve\n * against the same workspace root as `angular({ include })`, so a leading\n * `/` means workspace-relative.\n */\n addInclude(globs: string[]): void;\n}\n\nexport interface AnalogPluginHooks {\n setup?(context: AnalogPluginContext): void | Promise<void>;\n}\n\n/**\n * A normal Vite plugin that optionally exposes an `analog` setup hook.\n * Discovery is structural (`plugin.analog?.setup`), so this type is a DX aid\n * rather than a requirement.\n */\nexport type AnalogIntegrationPlugin = Plugin & { analog?: AnalogPluginHooks };\n\nexport interface AnalogIntegrations {\n stylePreprocessor?: StylePreprocessor;\n configureStylesheetRegistry?: StylesheetRegistryConfigurator;\n transformFilter?: TransformFilter;\n componentRegistries: ComponentRegistryEntries[];\n include: string[];\n externalizeStyles: boolean;\n}\n\nconst integrationsByConfig = new WeakMap<\n ResolvedConfig,\n Promise<AnalogIntegrations>\n>();\n\n/**\n * Runs every `analog.setup()` hook found in the resolved Vite plugin list,\n * once per resolved config, and composes the registrations in plugin order.\n */\nexport function discoverAnalogIntegrations(\n config: ResolvedConfig,\n): Promise<AnalogIntegrations> {\n let pending = integrationsByConfig.get(config);\n if (!pending) {\n pending = runAnalogSetupHooks(config.plugins ?? []);\n integrationsByConfig.set(config, pending);\n }\n return pending;\n}\n\nexport async function runAnalogSetupHooks(\n plugins: readonly Plugin[],\n): Promise<AnalogIntegrations> {\n const preprocessors: StylePreprocessor[] = [];\n const registryConfigurators: StylesheetRegistryConfigurator[] = [];\n const transformFilters: TransformFilter[] = [];\n const componentRegistries: ComponentRegistryEntries[] = [];\n const include: string[] = [];\n let externalizeStyles = false;\n\n for (const plugin of plugins as readonly AnalogIntegrationPlugin[]) {\n if (typeof plugin.analog?.setup !== 'function') {\n continue;\n }\n\n const registeredBefore = preprocessors.length;\n const context: AnalogPluginContext = {\n registerStylePreprocessor(preprocessor) {\n preprocessors.push(wrapStylePreprocessor(plugin.name, preprocessor));\n },\n externalizeComponentStyles() {\n externalizeStyles = true;\n },\n configureStylesheetRegistry(configure) {\n registryConfigurators.push(\n wrapRegistryConfigurator(plugin.name, configure),\n );\n },\n registerTransformFilter(filter) {\n transformFilters.push(filter);\n },\n registerComponentRegistry(entries) {\n componentRegistries.push(entries);\n },\n addInclude(globs) {\n include.push(...globs);\n },\n };\n\n try {\n await plugin.analog.setup(context);\n } catch (error) {\n throw new Error(\n `[analog] analog.setup() from plugin \"${plugin.name}\" failed: ${describeError(error)}`,\n );\n }\n\n debugStylePipeline('analog.setup() completed', {\n plugin: plugin.name,\n stylePreprocessors: preprocessors.length - registeredBefore,\n registryConfigurators: registryConfigurators.length,\n transformFilters: transformFilters.length,\n componentRegistries: componentRegistries.length,\n include: include.length,\n externalizeStyles,\n });\n }\n\n return {\n stylePreprocessor: composeStylePreprocessors(preprocessors),\n configureStylesheetRegistry: registryConfigurators.length\n ? (registry, context) => {\n for (const configure of registryConfigurators) {\n configure(registry, context);\n }\n }\n : undefined,\n transformFilter: transformFilters.length\n ? (code, id) => transformFilters.every((filter) => filter(code, id))\n : undefined,\n componentRegistries,\n include,\n externalizeStyles,\n };\n}\n\nfunction wrapStylePreprocessor(\n pluginName: string,\n preprocessor: StylePreprocessor,\n): StylePreprocessor {\n return (code, filename, context) => {\n try {\n return preprocessor(code, filename, context);\n } catch (error) {\n throw new Error(\n `[analog] Style preprocessor from plugin \"${pluginName}\" failed for \"${filename}\": ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction wrapRegistryConfigurator(\n pluginName: string,\n configure: StylesheetRegistryConfigurator,\n): StylesheetRegistryConfigurator {\n return (registry, context) => {\n try {\n configure(registry, context);\n } catch (error) {\n throw new Error(\n `[analog] Stylesheet registry configurator from plugin \"${pluginName}\" failed: ${describeError(error)}`,\n );\n }\n };\n}\n\nfunction describeError(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;;AAuFA,IAAM,uCAAuB,IAAI,QAG/B;;;;;AAMF,SAAgB,2BACd,QAC6B;CAC7B,IAAI,UAAU,qBAAqB,IAAI,MAAM;CAC7C,IAAI,CAAC,SAAS;EACZ,UAAU,oBAAoB,OAAO,WAAW,CAAC,CAAC;EAClD,qBAAqB,IAAI,QAAQ,OAAO;CAC1C;CACA,OAAO;AACT;AAEA,eAAsB,oBACpB,SAC6B;CAC7B,MAAM,gBAAqC,CAAC;CAC5C,MAAM,wBAA0D,CAAC;CACjE,MAAM,mBAAsC,CAAC;CAC7C,MAAM,sBAAkD,CAAC;CACzD,MAAM,UAAoB,CAAC;CAC3B,IAAI,oBAAoB;CAExB,KAAK,MAAM,UAAU,SAA+C;EAClE,IAAI,OAAO,OAAO,QAAQ,UAAU,YAClC;EAGF,MAAM,mBAAmB,cAAc;EACvC,MAAM,UAA+B;GACnC,0BAA0B,cAAc;IACtC,cAAc,KAAK,sBAAsB,OAAO,MAAM,YAAY,CAAC;GACrE;GACA,6BAA6B;IAC3B,oBAAoB;GACtB;GACA,4BAA4B,WAAW;IACrC,sBAAsB,KACpB,yBAAyB,OAAO,MAAM,SAAS,CACjD;GACF;GACA,wBAAwB,QAAQ;IAC9B,iBAAiB,KAAK,MAAM;GAC9B;GACA,0BAA0B,SAAS;IACjC,oBAAoB,KAAK,OAAO;GAClC;GACA,WAAW,OAAO;IAChB,QAAQ,KAAK,GAAG,KAAK;GACvB;EACF;EAEA,IAAI;GACF,MAAM,OAAO,OAAO,MAAM,OAAO;EACnC,SAAS,OAAO;GACd,MAAM,IAAI,MACR,wCAAwC,OAAO,KAAK,YAAY,cAAc,KAAK,GACrF;EACF;EAEA,mBAAmB,4BAA4B;GAC7C,QAAQ,OAAO;GACf,oBAAoB,cAAc,SAAS;GAC3C,uBAAuB,sBAAsB;GAC7C,kBAAkB,iBAAiB;GACnC,qBAAqB,oBAAoB;GACzC,SAAS,QAAQ;GACjB;EACF,CAAC;CACH;CAEA,OAAO;EACL,mBAAmB,0BAA0B,aAAa;EAC1D,6BAA6B,sBAAsB,UAC9C,UAAU,YAAY;GACrB,KAAK,MAAM,aAAa,uBACtB,UAAU,UAAU,OAAO;EAE/B,IACA,KAAA;EACJ,iBAAiB,iBAAiB,UAC7B,MAAM,OAAO,iBAAiB,OAAO,WAAW,OAAO,MAAM,EAAE,CAAC,IACjE,KAAA;EACJ;EACA;EACA;CACF;AACF;AAEA,SAAS,sBACP,YACA,cACmB;CACnB,QAAQ,MAAM,UAAU,YAAY;EAClC,IAAI;GACF,OAAO,aAAa,MAAM,UAAU,OAAO;EAC7C,SAAS,OAAO;GACd,MAAM,IAAI,MACR,4CAA4C,WAAW,gBAAgB,SAAS,KAAK,cAAc,KAAK,GAC1G;EACF;CACF;AACF;AAEA,SAAS,yBACP,YACA,WACgC;CAChC,QAAQ,UAAU,YAAY;EAC5B,IAAI;GACF,UAAU,UAAU,OAAO;EAC7B,SAAS,OAAO;GACd,MAAM,IAAI,MACR,0DAA0D,WAAW,YAAY,cAAc,KAAK,GACtG;EACF;CACF;AACF;AAEA,SAAS,cAAc,OAAwB;CAC7C,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode } from './utils/plugin-config.js';\n\nexport function buildOptimizerPlugin({ jit }: { jit: boolean }): Plugin {\n const transformers = new Map<\n string,\n InstanceType<typeof JavaScriptTransformer>\n >();\n let isProd = false;\n let isWatch = false;\n let preserveVendorMaps = false;\n\n function getTransformer(envName = 'default') {\n let transformer = transformers.get(envName);\n if (!transformer) {\n transformer = new JavaScriptTransformer(\n {\n sourcemap: preserveVendorMaps,\n thirdPartySourcemaps: preserveVendorMaps,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\n transformers.set(envName, transformer);\n }\n return transformer;\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n // Normally build-only. Astro's Cloudflare integration (`@astrojs/cloudflare`)\n // transforms SSR modules through a serve-style `workerd` runner *during*\n // `astro build`; an `apply: 'build'` plugin is excluded from that pipeline,\n // so the Angular linker never runs on the worker's partially-compiled\n // packages and they fall back to the JIT compiler. Also apply under a\n // production `NODE_ENV` (which `astro build` sets) so the linker runs in\n // that runner too. Regular Analog dev servers run with a development\n // `NODE_ENV`, so their behavior is unchanged.\n apply(_config, env) {\n return (\n env.command === 'build' || process.env['NODE_ENV'] === 'production'\n );\n },\n config(userConfig) {\n isProd = isProdMode(userConfig.mode);\n // Advanced optimizations paired with dev-mode defines would strip\n // dev-only code the debug API needs, so both key off `isProd`.\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n } as UserConfig;\n },\n // The top-level define keys `ngServerMode` off the legacy `build.ssr`\n // flag. Environment API builds run the server through an environment\n // with `consumer: 'server'` while `build.ssr` stays unset, so give that\n // environment its own value; otherwise the guard compiles to `false`\n // and browser-only hydration features run during SSR.\n configEnvironment(_name, config) {\n if (isProd && config.consumer === 'server') {\n return { define: { ngServerMode: 'true' } };\n }\n return undefined;\n },\n configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\n isWatch = config.command === 'serve' || !!config.build?.watch;\n },\n transform: {\n filter: {\n // Allow an optional `?query` after the extension. Some environments\n // (e.g. Cloudflare's `workerd`, used by Astro's Cloudflare integration)\n // reference optimized deps with a `?v=<hash>` suffix, e.g.\n // `.../fesm2022/_platform_location-chunk.mjs?v=a786a9ff`. A `$`-anchored\n // extension match skips those, so the Angular linker never runs and the\n // partially-compiled package falls back to the JIT compiler at runtime.\n id: /\\.[cm]?js(?:\\?|$)/,\n },\n async handler(code, id) {\n // Strip the `?query` so the fesm check and the transformer see a real\n // filename rather than `foo.mjs?v=<hash>`.\n const cleanId = id.split('?')[0];\n const angularPackage = /fesm20/.test(cleanId);\n\n if (!angularPackage) {\n // `{ mappings: '' }` declares zero segments, dropping the module's own\n // map from the chain; `null` keeps it. Removing `sourceMappingURL` is\n // what makes that map unreachable, so it only runs when discarding.\n return {\n code:\n isProd && !preserveVendorMaps\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: preserveVendorMaps ? null : { mappings: '' },\n };\n }\n\n const sideEffects =\n jit && cleanId.includes('@angular/compiler') ? true : false;\n const envName = this.environment?.name ?? 'default';\n const transformer = getTransformer(envName);\n const result: Uint8Array = await transformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n const transformed = Buffer.from(result).toString();\n return preserveVendorMaps\n ? extractInlineSourceMap(transformed, cleanId)\n : { code: transformed, map: { mappings: '' } };\n },\n },\n async closeBundle() {\n if (isWatch) {\n return;\n }\n const envName = this.environment?.name ?? 'default';\n const transformer = transformers.get(envName);\n if (transformer) {\n transformers.delete(envName);\n await transformer.close();\n }\n },\n };\n}\n\nexport function extractInlineSourceMap(\n code: string,\n id: string,\n): { code: string; map: string | null } {\n const sourceMapMatch = code.match(\n /\\n?\\/\\/# sourceMappingURL=data:application\\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\\s*$/,\n );\n if (!sourceMapMatch || sourceMapMatch.index === undefined) {\n return {\n code,\n map: null,\n };\n }\n return {\n code: code.slice(0, sourceMapMatch.index),\n map: Buffer.from(sourceMapMatch[1]!, 'base64').toString(),\n };\n}\n"],"mappings":";;;AAIA,SAAgB,qBAAqB,EAAE,OAAiC;CACtE,MAAM,+BAAe,IAAI,
|
|
1
|
+
{"version":3,"file":"angular-build-optimizer-plugin.js","names":[],"sources":["../../../src/lib/angular-build-optimizer-plugin.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { JavaScriptTransformer } from './utils/devkit.js';\nimport { isProdMode } from './utils/plugin-config.js';\n\nexport function buildOptimizerPlugin({ jit }: { jit: boolean }): Plugin {\n const transformers = new Map<\n string,\n InstanceType<typeof JavaScriptTransformer>\n >();\n let isProd = false;\n let isWatch = false;\n let preserveVendorMaps = false;\n\n function getTransformer(envName = 'default') {\n let transformer = transformers.get(envName);\n if (!transformer) {\n transformer = new JavaScriptTransformer(\n {\n sourcemap: preserveVendorMaps,\n thirdPartySourcemaps: preserveVendorMaps,\n advancedOptimizations: isProd,\n jit: true,\n },\n 1,\n );\n transformers.set(envName, transformer);\n }\n return transformer;\n }\n\n return {\n name: '@analogjs/vite-plugin-angular-optimizer',\n // Normally build-only. Astro's Cloudflare integration (`@astrojs/cloudflare`)\n // transforms SSR modules through a serve-style `workerd` runner *during*\n // `astro build`; an `apply: 'build'` plugin is excluded from that pipeline,\n // so the Angular linker never runs on the worker's partially-compiled\n // packages and they fall back to the JIT compiler. Also apply under a\n // production `NODE_ENV` (which `astro build` sets) so the linker runs in\n // that runner too. Regular Analog dev servers run with a development\n // `NODE_ENV`, so their behavior is unchanged.\n apply(_config, env) {\n return (\n env.command === 'build' || process.env['NODE_ENV'] === 'production'\n );\n },\n config(userConfig) {\n isProd = isProdMode(userConfig.mode);\n // Advanced optimizations paired with dev-mode defines would strip\n // dev-only code the debug API needs, so both key off `isProd`.\n return {\n define: isProd\n ? {\n ngJitMode: 'false',\n ngI18nClosureMode: 'false',\n ngDevMode: 'false',\n ngServerMode: `${!!userConfig.build?.ssr}`,\n }\n : {},\n } as UserConfig;\n },\n // The top-level define keys `ngServerMode` off the legacy `build.ssr`\n // flag. Environment API builds run the server through an environment\n // with `consumer: 'server'` while `build.ssr` stays unset, so give that\n // environment its own value; otherwise the guard compiles to `false`\n // and browser-only hydration features run during SSR.\n configEnvironment(_name, config) {\n if (isProd && config.consumer === 'server') {\n return { define: { ngServerMode: 'true' } };\n }\n return undefined;\n },\n configResolved(config) {\n preserveVendorMaps = !!config.build.sourcemap;\n isWatch = config.command === 'serve' || !!config.build?.watch;\n },\n transform: {\n filter: {\n // Allow an optional `?query` after the extension. Some environments\n // (e.g. Cloudflare's `workerd`, used by Astro's Cloudflare integration)\n // reference optimized deps with a `?v=<hash>` suffix, e.g.\n // `.../fesm2022/_platform_location-chunk.mjs?v=a786a9ff`. A `$`-anchored\n // extension match skips those, so the Angular linker never runs and the\n // partially-compiled package falls back to the JIT compiler at runtime.\n id: /\\.[cm]?js(?:\\?|$)/,\n },\n async handler(code, id) {\n // Strip the `?query` so the fesm check and the transformer see a real\n // filename rather than `foo.mjs?v=<hash>`.\n const cleanId = id.split('?')[0];\n const angularPackage = /fesm20/.test(cleanId);\n\n if (!angularPackage) {\n // `{ mappings: '' }` declares zero segments, dropping the module's own\n // map from the chain; `null` keeps it. Removing `sourceMappingURL` is\n // what makes that map unreachable, so it only runs when discarding.\n return {\n code:\n isProd && !preserveVendorMaps\n ? code.replace(/^\\/\\/# sourceMappingURL=[^\\r\\n]*/gm, '')\n : code,\n map: preserveVendorMaps ? null : { mappings: '' },\n };\n }\n\n const sideEffects =\n jit && cleanId.includes('@angular/compiler') ? true : false;\n const envName = this.environment?.name ?? 'default';\n const transformer = getTransformer(envName);\n const result: Uint8Array = await transformer.transformData(\n cleanId,\n code,\n false,\n sideEffects,\n );\n\n const transformed = Buffer.from(result).toString();\n return preserveVendorMaps\n ? extractInlineSourceMap(transformed, cleanId)\n : { code: transformed, map: { mappings: '' } };\n },\n },\n async closeBundle() {\n if (isWatch) {\n return;\n }\n const envName = this.environment?.name ?? 'default';\n const transformer = transformers.get(envName);\n if (transformer) {\n transformers.delete(envName);\n await transformer.close();\n }\n },\n };\n}\n\nexport function extractInlineSourceMap(\n code: string,\n id: string,\n): { code: string; map: string | null } {\n const sourceMapMatch = code.match(\n /\\n?\\/\\/# sourceMappingURL=data:application\\/json(?:;charset=[^;,]+)?;base64,([A-Za-z0-9+/=]+)\\s*$/,\n );\n if (!sourceMapMatch || sourceMapMatch.index === undefined) {\n return {\n code,\n map: null,\n };\n }\n return {\n code: code.slice(0, sourceMapMatch.index),\n map: Buffer.from(sourceMapMatch[1]!, 'base64').toString(),\n };\n}\n"],"mappings":";;;AAIA,SAAgB,qBAAqB,EAAE,OAAiC;CACtE,MAAM,+BAAe,IAAI,IAGvB;CACF,IAAI,SAAS;CACb,IAAI,UAAU;CACd,IAAI,qBAAqB;CAEzB,SAAS,eAAe,UAAU,WAAW;EAC3C,IAAI,cAAc,aAAa,IAAI,OAAO;EAC1C,IAAI,CAAC,aAAa;GAChB,cAAc,IAAI,sBAChB;IACE,WAAW;IACX,sBAAsB;IACtB,uBAAuB;IACvB,KAAK;GACP,GACA,CACF;GACA,aAAa,IAAI,SAAS,WAAW;EACvC;EACA,OAAO;CACT;CAEA,OAAO;EACL,MAAM;EASN,MAAM,SAAS,KAAK;GAClB,OACE,IAAI,YAAY,WAAA,QAAA,IAAA,aAAuC;EAE3D;EACA,OAAO,YAAY;GACjB,SAAS,WAAW,WAAW,IAAI;GAGnC,OAAO,EACL,QAAQ,SACJ;IACE,WAAW;IACX,mBAAmB;IACnB,WAAW;IACX,cAAc,GAAG,CAAC,CAAC,WAAW,OAAO;GACvC,IACA,CAAC,EACP;EACF;EAMA,kBAAkB,OAAO,QAAQ;GAC/B,IAAI,UAAU,OAAO,aAAa,UAChC,OAAO,EAAE,QAAQ,EAAE,cAAc,OAAO,EAAE;EAG9C;EACA,eAAe,QAAQ;GACrB,qBAAqB,CAAC,CAAC,OAAO,MAAM;GACpC,UAAU,OAAO,YAAY,WAAW,CAAC,CAAC,OAAO,OAAO;EAC1D;EACA,WAAW;GACT,QAAQ,EAON,IAAI,oBACN;GACA,MAAM,QAAQ,MAAM,IAAI;IAGtB,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,CAAC;IAG9B,IAAI,CAFmB,SAAS,KAAK,OAEhC,GAIH,OAAO;KACL,MACE,UAAU,CAAC,qBACP,KAAK,QAAQ,sCAAsC,EAAE,IACrD;KACN,KAAK,qBAAqB,OAAO,EAAE,UAAU,GAAG;IAClD;IAGF,MAAM,cACJ,OAAO,QAAQ,SAAS,mBAAmB,IAAI,OAAO;IAGxD,MAAM,SAAqB,MADP,eADJ,KAAK,aAAa,QAAQ,SAET,CAAA,CAAY,cAC3C,SACA,MACA,OACA,WACF;IAEA,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,CAAC,SAAS;IACjD,OAAO,qBACH,uBAAuB,aAAa,OAAO,IAC3C;KAAE,MAAM;KAAa,KAAK,EAAE,UAAU,GAAG;IAAE;GACjD;EACF;EACA,MAAM,cAAc;GAClB,IAAI,SACF;GAEF,MAAM,UAAU,KAAK,aAAa,QAAQ;GAC1C,MAAM,cAAc,aAAa,IAAI,OAAO;GAC5C,IAAI,aAAa;IACf,aAAa,OAAO,OAAO;IAC3B,MAAM,YAAY,MAAM;GAC1B;EACF;CACF;AACF;AAEA,SAAgB,uBACd,MACA,IACsC;CACtC,MAAM,iBAAiB,KAAK,MAC1B,mGACF;CACA,IAAI,CAAC,kBAAkB,eAAe,UAAU,KAAA,GAC9C,OAAO;EACL;EACA,KAAK;CACP;CAEF,OAAO;EACL,MAAM,KAAK,MAAM,GAAG,eAAe,KAAK;EACxC,KAAK,OAAO,KAAK,eAAe,IAAK,QAAQ,CAAC,CAAC,SAAS;CAC1D;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n hashJitInlineStyles,\n} from './utils/jit-inline-styles.js';\nimport { debugStyles } from './utils/debug.js';\nimport { discoverAnalogIntegrations } from './analog-plugin-interop.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n let stylePreprocessor: StylePreprocessor | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n async buildStart() {\n stylePreprocessor = (await discoverAnalogIntegrations(config))\n .stylePreprocessor;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes(JIT_INLINE_STYLE_PREFIX)) {\n const encodedStyles = getJitInlineStyles(id.split('style:inline;')[1]);\n const styleIdHash = hashJitInlineStyles(encodedStyles);\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n const filename = `${styleIdHash}.${inlineStylesExtension}`;\n const preprocessed = preprocessStylesheet(\n decodedStyles,\n filename,\n stylePreprocessor,\n { filename, inline: true },\n );\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n preprocessed,\n `${filename}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n debugStyles('jit css compilation error', {\n styleIdHash,\n error: errorMessage,\n });\n console.warn(\n '[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s',\n styleIdHash,\n errorMessage,\n );\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n closeBundle() {\n if (!this.meta?.watchMode) {\n releaseCssPreprocessorWorkers();\n }\n },\n };\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;CACJ,IAAI;
|
|
1
|
+
{"version":3,"file":"angular-jit-plugin.js","names":[],"sources":["../../../src/lib/angular-jit-plugin.ts"],"sourcesContent":["import { Plugin, ResolvedConfig, preprocessCSS } from 'vite';\nimport {\n JIT_INLINE_STYLE_PREFIX,\n getJitInlineStyles,\n hashJitInlineStyles,\n} from './utils/jit-inline-styles.js';\nimport { debugStyles } from './utils/debug.js';\nimport { discoverAnalogIntegrations } from './analog-plugin-interop.js';\nimport { preprocessStylesheet } from './stylesheet-registry.js';\nimport type { StylePreprocessor } from './style-preprocessor.js';\nimport { releaseCssPreprocessorWorkers } from './utils/css-preprocessor-workers.js';\n\nexport function jitPlugin({\n inlineStylesExtension,\n}: {\n inlineStylesExtension: string;\n}): Plugin {\n let config: ResolvedConfig;\n let stylePreprocessor: StylePreprocessor | undefined;\n\n return {\n name: '@analogjs/vite-plugin-angular-jit',\n configResolved(_config) {\n config = _config;\n },\n async buildStart() {\n stylePreprocessor = (await discoverAnalogIntegrations(config))\n .stylePreprocessor;\n },\n resolveId(id: string) {\n if (id.startsWith('virtual:angular')) {\n return `\\0${id}`;\n }\n\n return;\n },\n async load(id: string) {\n if (id.includes(JIT_INLINE_STYLE_PREFIX)) {\n const encodedStyles = getJitInlineStyles(id.split('style:inline;')[1]);\n const styleIdHash = hashJitInlineStyles(encodedStyles);\n const decodedStyles = Buffer.from(\n decodeURIComponent(encodedStyles),\n 'base64',\n ).toString();\n const filename = `${styleIdHash}.${inlineStylesExtension}`;\n const preprocessed = preprocessStylesheet(\n decodedStyles,\n filename,\n stylePreprocessor,\n { filename, inline: true },\n );\n\n let styles: string | undefined = '';\n\n try {\n const compiled = await preprocessCSS(\n preprocessed,\n `${filename}?direct`,\n config,\n );\n styles = compiled?.code;\n } catch (e) {\n const errorMessage = e instanceof Error ? e.message : String(e);\n debugStyles('jit css compilation error', {\n styleIdHash,\n error: errorMessage,\n });\n console.warn(\n '[@analogjs/vite-plugin-angular]: Failed to preprocess inline JIT stylesheet %s. Returning an empty stylesheet instead. %s',\n styleIdHash,\n errorMessage,\n );\n }\n\n return `export default \\`${styles}\\``;\n }\n\n return;\n },\n closeBundle() {\n if (!this.meta?.watchMode) {\n releaseCssPreprocessorWorkers();\n }\n },\n };\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,UAAU,EACxB,yBAGS;CACT,IAAI;CACJ,IAAI;CAEJ,OAAO;EACL,MAAM;EACN,eAAe,SAAS;GACtB,SAAS;EACX;EACA,MAAM,aAAa;GACjB,qBAAqB,MAAM,2BAA2B,MAAM,EAAA,CACzD;EACL;EACA,UAAU,IAAY;GACpB,IAAI,GAAG,WAAW,iBAAiB,GACjC,OAAO,KAAK;EAIhB;EACA,MAAM,KAAK,IAAY;GACrB,IAAI,GAAG,SAAA,mCAAgC,GAAG;IACxC,MAAM,gBAAgB,mBAAmB,GAAG,MAAM,eAAe,CAAC,CAAC,EAAE;IACrE,MAAM,cAAc,oBAAoB,aAAa;IACrD,MAAM,gBAAgB,OAAO,KAC3B,mBAAmB,aAAa,GAChC,QACF,CAAC,CAAC,SAAS;IACX,MAAM,WAAW,GAAG,YAAY,GAAG;IACnC,MAAM,eAAe,qBACnB,eACA,UACA,mBACA;KAAE;KAAU,QAAQ;IAAK,CAC3B;IAEA,IAAI,SAA6B;IAEjC,IAAI;KAMF,UAAS,MALc,cACrB,cACA,GAAG,SAAS,UACZ,MACF,EAAA,EACmB;IACrB,SAAS,GAAG;KACV,MAAM,eAAe,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC;KAC9D,YAAY,6BAA6B;MACvC;MACA,OAAO;KACT,CAAC;KACD,QAAQ,KACN,6HACA,aACA,YACF;IACF;IAEA,OAAO,oBAAoB,OAAO;GACpC;EAGF;EACA,cAAc;GACZ,IAAI,CAAC,KAAK,MAAM,WACd,8BAA8B;EAElC;CACF;AACF"}
|
|
@@ -133,7 +133,8 @@ function angular(options) {
|
|
|
133
133
|
const normalizeEmitterLookupId = (file) => {
|
|
134
134
|
const normalizedFile = normalizePath(file);
|
|
135
135
|
if (!normalizedFile.startsWith("/@fs/")) return normalizedFile;
|
|
136
|
-
|
|
136
|
+
const fsPath = normalizedFile.slice(4).replace(/^\/([A-Za-z]:\/)/, "$1");
|
|
137
|
+
return normalizePath(fsPath);
|
|
137
138
|
};
|
|
138
139
|
const describeEmitMarkers = (content) => ({
|
|
139
140
|
contentLength: content.length,
|
|
@@ -251,14 +252,14 @@ function angular(options) {
|
|
|
251
252
|
hotUpdates.configureServer(server);
|
|
252
253
|
const invalidateCompilationOnFsChange = createFsWatcherCacheInvalidator(invalidateFsCaches, invalidateTsconfigCaches, () => performCompilation(resolvedConfig));
|
|
253
254
|
server.watcher.on("add", (file) => {
|
|
254
|
-
if (EXCLUDED_TS_EXT_REGEX.test(file)) invalidateSourceFiles(new Set([normalizePath(file)]));
|
|
255
|
+
if (EXCLUDED_TS_EXT_REGEX.test(file)) invalidateSourceFiles(/* @__PURE__ */ new Set([normalizePath(file)]));
|
|
255
256
|
return invalidateCompilationOnFsChange();
|
|
256
257
|
});
|
|
257
258
|
server.watcher.on("unlink", (file) => {
|
|
258
259
|
const id = normalizePath(file);
|
|
259
260
|
outputFiles.delete(id);
|
|
260
261
|
tsSourceFileCache.delete(id);
|
|
261
|
-
sourceFileCache.invalidate(new Set([id]));
|
|
262
|
+
sourceFileCache.invalidate(/* @__PURE__ */ new Set([id]));
|
|
262
263
|
evictDeletedFileMetadata(file, {
|
|
263
264
|
classNamesMap: classNames,
|
|
264
265
|
fileTransformMap
|
|
@@ -756,6 +757,7 @@ function angular(options) {
|
|
|
756
757
|
...isTest && !isStackBlitz ? angularVitestPlugins((id) => outputFiles.get(normalizePath(id))?.map) : [],
|
|
757
758
|
jit && jitPlugin({ inlineStylesExtension: pluginOptions.inlineStylesExtension }),
|
|
758
759
|
buildOptimizerPlugin({ jit }),
|
|
760
|
+
!isTest && devServerModePlugin(),
|
|
759
761
|
routerPlugin(),
|
|
760
762
|
nxFolderPlugin(),
|
|
761
763
|
encapsulationPlugin()
|
|
@@ -872,7 +874,8 @@ function angular(options) {
|
|
|
872
874
|
}
|
|
873
875
|
if (!watchMode) builder = ts.createAbstractBuilder(typeScriptProgram, host, oldBuilder);
|
|
874
876
|
if (angularCompiler) await angularCompiler.analyzeAsync();
|
|
875
|
-
const
|
|
877
|
+
const beforeTransformers = jit ? [compilerCli.constructorParametersDownlevelTransform(builder.getProgram()), createJitResourceTransformer(() => builder.getProgram().getTypeChecker())] : [];
|
|
878
|
+
const transformers = mergeTransformers({ before: beforeTransformers }, jit ? {} : angularCompiler.prepareEmit().transformers);
|
|
876
879
|
const fileMetadata = getFileMetadata(builder, angularCompiler, pluginOptions.liveReload, pluginOptions.disableTypeChecking);
|
|
877
880
|
const writeFileCallback = (_filename, content, _a, _b, sourceFiles) => {
|
|
878
881
|
if (!sourceFiles?.length) return;
|
|
@@ -998,7 +1001,17 @@ function isModuleForChangedResource(mod, changedFile, stylesheetRegistry) {
|
|
|
998
1001
|
if (normalizePath((mod.file ?? "").split("?")[0]) === normalizedChangedFile) return true;
|
|
999
1002
|
if (!mod.id) return false;
|
|
1000
1003
|
const requestPath = getFilenameFromPath(mod.id);
|
|
1001
|
-
|
|
1004
|
+
const sourcePath = stylesheetRegistry?.resolveExternalSource(requestPath) ?? stylesheetRegistry?.resolveExternalSource(requestPath.replace(/^\//, "")) ?? stylesheetRegistry?.getServedSourcePath(requestPath) ?? stylesheetRegistry?.getServedSourcePath(requestPath.replace(/^\//, ""));
|
|
1005
|
+
return normalizePath((sourcePath ?? "").split("?")[0]) === normalizedChangedFile;
|
|
1006
|
+
}
|
|
1007
|
+
function devServerModePlugin() {
|
|
1008
|
+
return {
|
|
1009
|
+
name: "@analogjs/vite-plugin-angular-dev-server-mode",
|
|
1010
|
+
apply: "serve",
|
|
1011
|
+
configEnvironment(_name, config) {
|
|
1012
|
+
if (config.consumer === "server") return { define: { ngServerMode: "true" } };
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1002
1015
|
}
|
|
1003
1016
|
function diagnoseComponentStylesheetPipeline(changedFile, directModule, stylesheetRegistry, wrapperModules, stylePreprocessor) {
|
|
1004
1017
|
const normalizedFile = normalizePath(changedFile.split("?")[0]);
|
|
@@ -1156,7 +1169,7 @@ function logComponentStylesheetHmrOutcome(details) {
|
|
|
1156
1169
|
rejectedPreferredPaths: [...new Set(rejectedPreferredPaths)],
|
|
1157
1170
|
pitfalls: [...new Set(pitfalls)],
|
|
1158
1171
|
anomalies: details.diagnosis.anomalies,
|
|
1159
|
-
hints: [
|
|
1172
|
+
hints: [.../* @__PURE__ */ new Set([...details.diagnosis.hints, ...hints])]
|
|
1160
1173
|
});
|
|
1161
1174
|
}
|
|
1162
1175
|
function findTemplateOwnerModules(server, resourceFile) {
|
|
@@ -1234,6 +1247,6 @@ function getFilenameFromPath(id) {
|
|
|
1234
1247
|
}
|
|
1235
1248
|
}
|
|
1236
1249
|
//#endregion
|
|
1237
|
-
export { angular };
|
|
1250
|
+
export { angular, createFsWatcherCacheInvalidator, evictDeletedFileMetadata, findComponentStylesheetWrapperModules, findTemplateOwnerModules, getFileMetadata, getModulesForChangedFile, isModuleForChangedResource };
|
|
1238
1251
|
|
|
1239
1252
|
//# sourceMappingURL=angular-vite-plugin.js.map
|