diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 26b8f5995..e91ad58fa 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -75,10 +75,6 @@ reviews: instructions: >- Review as the vite-plugin-angular package scope. Prioritize Angular and Vite integration behavior, build compatibility, backward compatibility, stability, and targeted coverage for regressions. - - path: 'packages/angular-compiler/**' - instructions: >- - Review as the angular-compiler package scope. Prioritize Angular Compiler. integration behavior, - build compatibility, backward compatibility, stability, and targeted coverage for regressions. - path: 'packages/vite-plugin-angular-tools/**' instructions: >- Treat changes here as part of the vite-plugin-angular scope and review them together with test fixtures diff --git a/.github/ISSUE_TEMPLATE/01-bug-report.yml b/.github/ISSUE_TEMPLATE/01-bug-report.yml index c9d1d841f..b23f31558 100644 --- a/.github/ISSUE_TEMPLATE/01-bug-report.yml +++ b/.github/ISSUE_TEMPLATE/01-bug-report.yml @@ -32,7 +32,6 @@ body: - platform - astro-angular - storybook-angular - - angular-compiler - Docs - Don't know / other validations: diff --git a/.github/ISSUE_TEMPLATE/02-feature-request.yml b/.github/ISSUE_TEMPLATE/02-feature-request.yml index a59583246..0ae2e0646 100644 --- a/.github/ISSUE_TEMPLATE/02-feature-request.yml +++ b/.github/ISSUE_TEMPLATE/02-feature-request.yml @@ -23,7 +23,6 @@ body: - platform - astro-angular - storybook-angular - - angular-compiler - Docs - Don't know / other validations: diff --git a/.github/pr-scope-map.json b/.github/pr-scope-map.json index 762146c56..c9229c553 100644 --- a/.github/pr-scope-map.json +++ b/.github/pr-scope-map.json @@ -1,13 +1,5 @@ { "areas": [ - { - "scope": "angular-compiler", - "label": "scope:angular-compiler", - "kind": "package", - "color": "0e8a16", - "description": "Changes in @analogjs/angular-compiler", - "prefixes": ["packages/angular-compiler/"] - }, { "scope": "astro-angular", "label": "scope:astro-angular", diff --git a/.github/workflows/angular-compiler-compat.yml b/.github/workflows/compiler-compat.yml similarity index 78% rename from .github/workflows/angular-compiler-compat.yml rename to .github/workflows/compiler-compat.yml index 7ed320acf..75966f7a8 100644 --- a/.github/workflows/angular-compiler-compat.yml +++ b/.github/workflows/compiler-compat.yml @@ -1,8 +1,8 @@ -name: Angular Compiler Compatibility Tests +name: Compiler Compatibility Tests -# Verifies that @analogjs/angular-compiler runs against every Angular major -# version it claims to support (peerDependencies in -# packages/angular-compiler/package.json declare ">=19.0.0"). +# Verifies that the compiler inside @analogjs/vite-plugin-angular runs +# against every Angular major version it claims to support +# (peerDependencies in packages/vite-plugin-angular/package.json). # # Why this exists separately from conformance.yml: # - conformance.yml downloads Angular's reference test fixtures at a @@ -11,9 +11,9 @@ name: Angular Compiler Compatibility Tests # output match the reference fixtures?" — not "does our compiler run # against this Angular version's API surface?". # - This workflow swaps @angular/compiler (and @angular/compiler-cli) -# to the matrix version via pnpm.overrides, then runs the regular -# angular-compiler unit/integration suite. Failures here mean the -# compiler crashes against a peer dep version it claims to support. +# to the matrix version via pnpm.overrides, then runs the compiler +# unit/integration suite. Failures here mean the compiler crashes +# against a peer dep version it claims to support. # # Matrix policy: # - Each numeric slot pins the FLOOR of a supported major (e.g. 19.0.0). @@ -24,9 +24,9 @@ name: Angular Compiler Compatibility Tests # - The `next` slot installs `@angular/compiler@next` (Angular's prerelease # dist-tag) and is allowed to fail — it gives early warning when the # next major drops a breaking change without blocking the workflow. -# - When packages/angular-compiler/package.json bumps the peerDependencies -# floor, drop the lowest matrix slot. When a new Angular major ships, -# add a new floor slot. +# - When packages/vite-plugin-angular/package.json bumps the +# peerDependencies floor, drop the lowest matrix slot. When a new +# Angular major ships, add a new floor slot. # # Regression-issue policy: # - On `push` to beta, a failure auto-opens (or comments on an existing) @@ -37,15 +37,15 @@ on: workflow_dispatch: pull_request: paths: - - 'packages/angular-compiler/**' + - 'packages/vite-plugin-angular/src/lib/compiler/**' - 'package.json' - - '.github/workflows/angular-compiler-compat.yml' + - '.github/workflows/compiler-compat.yml' push: branches: [beta] paths: - - 'packages/angular-compiler/**' + - 'packages/vite-plugin-angular/src/lib/compiler/**' - 'package.json' - - '.github/workflows/angular-compiler-compat.yml' + - '.github/workflows/compiler-compat.yml' env: NODE_OPTIONS: --max-old-space-size=16384 @@ -121,13 +121,13 @@ jobs: fi fi - - name: Run angular-compiler test suite + - name: Run compiler test suite # Surfaces compiler-vs-Angular API mismatches via DEBUG output so # silently-caught errors (like the LiteralMapPropertyAssignment # constructor regression on 20.3.x) appear in CI logs. env: - DEBUG: 'analog-compiler*' - run: pnpm exec vitest run packages/angular-compiler/src/lib/ + DEBUG: 'analog-fast-compile*' + run: pnpm exec vitest run packages/vite-plugin-angular/src/lib/compiler/ - name: Open or update regression issue (push to beta only) # PRs already surface failures via the check status — auto-opening @@ -139,7 +139,7 @@ jobs: run: | set -e MATRIX_VERSION='${{ matrix.angular-version }}' - TITLE="CI: angular-compiler compatibility regression against @angular/compiler@${MATRIX_VERSION}" + TITLE="CI: compiler compatibility regression against @angular/compiler@${MATRIX_VERSION}" RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" COMMIT_URL="${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}" @@ -147,7 +147,7 @@ jobs: # so a maintainer reading the issue gets the same shape they'd get # from a manually-filed report. BODY=$(cat < 🤖 Auto-opened by \`.github/workflows/angular-compiler-compat.yml\`. Once the regression is fixed, please close this issue with a reference to the fixing commit. + > 🤖 Auto-opened by \`.github/workflows/compiler-compat.yml\`. Once the regression is fixed, please close this issue with a reference to the fixing commit. ## Please provide the environment you discovered this bug in. @@ -156,21 +156,21 @@ jobs: - **Failing workflow run**: $RUN_URL - **Matrix slot**: \`@angular/compiler@${MATRIX_VERSION}\` - **Workspace pin**: see \`package.json\` for the version that the workspace currently builds against - - **Reproduction**: \`pnpm install\` with \`pnpm.overrides\` setting \`@angular/compiler\` and \`@angular/compiler-cli\` to \`${MATRIX_VERSION}\`, then \`DEBUG=analog-compiler* pnpm exec vitest run packages/angular-compiler/src/lib/\` + - **Reproduction**: \`pnpm install\` with \`pnpm.overrides\` setting \`@angular/compiler\` and \`@angular/compiler-cli\` to \`${MATRIX_VERSION}\`, then \`DEBUG=analog-fast-compile* pnpm exec vitest run packages/vite-plugin-angular/src/lib/compiler/\` ## Which area/package is the issue in? - \`angular-compiler\` + \`vite-plugin-angular\` ## Description - The \`packages/angular-compiler/src/lib/\` test suite failed when run against \`@angular/compiler@${MATRIX_VERSION}\` after passing against the workspace-pinned version. This indicates an API-surface regression — a class export, method signature, or behavior in this Angular version differs from what the workspace pin provides, and the compiler depends on the difference. + The \`packages/vite-plugin-angular/src/lib/compiler/\` test suite failed when run against \`@angular/compiler@${MATRIX_VERSION}\` after passing against the workspace-pinned version. This indicates an API-surface regression — a class export, method signature, or behavior in this Angular version differs from what the workspace pin provides, and the compiler depends on the difference. - The compatibility matrix exists precisely to catch this class of failure ahead of user reports — see \`packages/angular-compiler/COMPILER.md\` § Compatibility Testing for the design rationale. + The compatibility matrix exists precisely to catch this class of failure ahead of user reports — see \`packages/vite-plugin-angular/src/lib/compiler/COMPILER.md\` § Compatibility Testing for the design rationale. ## Please provide the exception or error you saw - See the [failing workflow run]($RUN_URL) for full output. The \`Run angular-compiler test suite\` step has \`DEBUG=analog-compiler*\` enabled, so silently-caught compiler errors should appear in the log alongside any thrown exceptions. + See the [failing workflow run]($RUN_URL) for full output. The \`Run compiler test suite\` step has \`DEBUG=analog-fast-compile*\` enabled, so silently-caught compiler errors should appear in the log alongside any thrown exceptions. ## Other information @@ -200,6 +200,6 @@ jobs: gh issue create \ --repo "${{ github.repository }}" \ --title "$TITLE" \ - --label "bug,angular-compiler" \ + --label "bug,vite-plugin-angular" \ --body "$BODY" fi diff --git a/.github/workflows/conformance.yml b/.github/workflows/conformance.yml index 7bf066d53..3e9d37bc5 100644 --- a/.github/workflows/conformance.yml +++ b/.github/workflows/conformance.yml @@ -2,7 +2,17 @@ name: Angular Compiler Conformance Tests on: workflow_dispatch: - pull_request: {} + pull_request: + paths: + - 'packages/vite-plugin-angular/src/lib/compiler/**' + - 'package.json' + - '.github/workflows/conformance.yml' + push: + branches: [beta] + paths: + - 'packages/vite-plugin-angular/src/lib/compiler/**' + - 'package.json' + - '.github/workflows/conformance.yml' env: NODE_OPTIONS: --max-old-space-size=16384 @@ -31,11 +41,9 @@ jobs: cache-dependency-path: '**/pnpm-lock.yaml' - name: Install run: pnpm install --frozen-lockfile --prefer-offline - - name: Build angular-compiler - run: pnpm exec nx build angular-compiler - name: Download Angular ${{ matrix.angular-major }} compliance fixtures - run: bash packages/angular-compiler/scripts/setup-conformance.sh ${{ matrix.angular-major }} + run: bash packages/vite-plugin-angular/scripts/setup-conformance.sh ${{ matrix.angular-major }} - name: Run conformance tests env: ANGULAR_SOURCE_DIR: .angular-conformance - run: pnpm exec vitest run packages/angular-compiler/src/lib/conformance.spec.ts + run: pnpm exec vitest run packages/vite-plugin-angular/src/lib/compiler/conformance.spec.ts diff --git a/AGENTS.md b/AGENTS.md index e5092f0a3..69723e2d4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -65,7 +65,6 @@ This is the monorepo that contains all the code and infrastructure for AnalogJS. | `packages/storybook-angular` | `@analogjs/storybook-angular` | `storybook-angular` | | `packages/trpc` | `@analogjs/trpc` | `trpc` | | `packages/astro-angular` | `@analogjs/astro-angular` | `astro-angular` | -| `packages/angular-compiler` | `@analogjs/angular-compiler` | `angular-compiler` | ## Contribution Policy diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d8641ef38..f48daad4b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -172,7 +172,6 @@ The following is the list of currently supported scopes: - **vite-plugin-angular** - **vite-plugin-nitro** - **vitest-angular** -- **angular-compiler** ### Breaking Changes diff --git a/apps/analog-app/vite.config.ts b/apps/analog-app/vite.config.ts index 011b81b96..ab1b7f7c0 100644 --- a/apps/analog-app/vite.config.ts +++ b/apps/analog-app/vite.config.ts @@ -72,9 +72,9 @@ export default defineConfig(({ mode }) => { }, vite: { inlineStylesExtension: 'scss', + fastCompile: true, experimental: { useAngularCompilationAPI: false, - useAnalogCompiler: true, }, }, liveReload: true, diff --git a/apps/docs-app/docs/packages/angular-compiler/overview.md b/apps/docs-app/docs/packages/angular-compiler/overview.md deleted file mode 100644 index fdbb0d14d..000000000 --- a/apps/docs-app/docs/packages/angular-compiler/overview.md +++ /dev/null @@ -1,152 +0,0 @@ ---- -title: 'Analog Compiler' -description: 'Single-pass, experimental Analog compiler for Angular components, directives, pipes, and modules.' ---- - -# Analog Compiler - -The Analog Compiler (`@analogjs/angular-compiler`) is an experimental, single-pass compiler for Angular components, directives, pipes, modules, and services. It runs as a Vite plugin and replaces the default `ngc` + Angular Vite plugin emit pipeline with a single transform that emits Ivy instructions directly. Compilation happens once per file as Vite serves or builds it — no separate compiler invocation, no two-stage emit. - -:::warning Experimental - -The Analog Compiler is opt-in via `experimental.useAnalogCompiler: true` and is **continually being improved**. It currently passes ~91% of Angular's official conformance suite. Output, flag names, and behavior may change between minor releases. - -**The Analog Compiler does not type-check your code.** Run `ngc -p tsconfig.app.json --noEmit` as part of your build script (see below) to keep TypeScript and template type safety. Without this step, type errors will reach runtime. - -Library publishing via `analogCompilationMode: 'partial'` is newer than full mode and has had less production exposure. Bug reports welcome at [github.com/analogjs/analog/issues](https://github.com/analogjs/analog/issues). - -::: - -## Compatibility - -| Angular version | Status | -| --------------- | ------------------------------------------------------------------------------------------------------------- | -| **17.3.12** | Supported (LTS patch). Components that use `@defer` at runtime are **not** supported on v17 — see note below. | -| **18.2.14** | Supported (LTS patch). | -| **19.0.0+** | Supported. | -| **20.0.0+** | Supported. | -| **21.0.0+** | Supported. | -| **22 (`next`)** | Tracked, allowed-to-fail. Used as early warning when the next major lands a breaking change. | - -The compatibility matrix in [`.github/workflows/angular-compiler-compat.yml`](https://github.com/analogjs/analog/blob/beta/.github/workflows/angular-compiler-compat.yml) installs each version above via `pnpm.overrides` and runs the full `@analogjs/angular-compiler` test suite against it on every relevant pull request. Failures auto-open or comment on a tracking issue when they happen on `beta`. - -**Angular 17 `@defer` caveat:** Angular 17's `@defer` runtime ABI requires populated `meta.deferBlocks` and `meta.deferrableTypes` Maps that the Analog Compiler currently sets to empty (sufficient for components that don't use `@defer`). Components that use `@defer` blocks at runtime should upgrade to Angular 18+ — the v18+ ABI is compatible. - -## Enabling it (apps) - -Enable the compiler in `vite.config.ts` by setting `useAnalogCompiler: true` inside the `analog()` plugin's `vite.experimental` block: - -```ts -// vite.config.ts -import { defineConfig } from 'vite'; -import analog from '@analogjs/platform'; - -export default defineConfig({ - plugins: [ - analog({ - vite: { - experimental: { - useAnalogCompiler: true, - }, - }, - }), - ], -}); -``` - -The flag is forwarded by `@analogjs/platform` to `@analogjs/vite-plugin-angular`, where it is defined. - -Then add a type-check step to your `build` script. Because the Analog Compiler does not type-check, this step is required to keep TypeScript and template safety: - -```json -// package.json -{ - "scripts": { - "build": "ngc -p tsconfig.app.json --noEmit && vite build" - } -} -``` - -Use `ngc` (not `tsc --noEmit`) because it validates Angular template bindings, signal inputs, and host bindings — the parts of an Angular app that plain TypeScript cannot see. - -The reference implementation lives in [`apps/analog-app/vite.config.ts`](https://github.com/analogjs/analog/blob/beta/apps/analog-app/vite.config.ts) — the example app uses the Analog Compiler in production builds. - -## Library publishing (`partial` mode) - -For libraries that need to publish reusable Angular packages (FESM bundles consumed by other Angular projects), set `analogCompilationMode: 'partial'`: - -```ts -// vite.config.ts -import { defineConfig } from 'vite'; -import angular from '@analogjs/vite-plugin-angular'; - -export default defineConfig({ - plugins: [ - angular({ - experimental: { - useAnalogCompiler: true, - analogCompilationMode: 'partial', - }, - }), - ], -}); -``` - -Partial mode emits `ɵɵngDeclareComponent` / `ɵɵngDeclareDirective` / `ɵɵngDeclarePipe` / `ɵɵngDeclareNgModule` / `ɵɵngDeclareInjectable` calls instead of final Ivy definitions. The downstream consumer's Angular linker resolves these declarations at consumer-build time — the contract Angular libraries use to stay forward-compatible across Angular versions. - -The default is `'full'`, which emits final Ivy definitions for application builds. - -## How it works - -The Analog Compiler is built around three ideas: an OXC-based Rust parser for fast TypeScript AST traversal, a registry-based cross-file resolution layer that scans `.ts` and `.d.ts` files for component / directive / pipe metadata, and a `MagicString`-based emitter that performs surgical edits on the source rather than re-printing the whole file. Compilation runs in a single pass per file with no separate type-checking step — which is why the `ngc` step above is required. - -For the architecture deep-dive — source file inventory, compilation pipeline, conformance test results, and contributor guide — see [`COMPILER.md`](https://github.com/analogjs/analog/blob/beta/packages/angular-compiler/COMPILER.md) in the package source. - -## Limitations - -The Analog Compiler currently passes ~91% of Angular's official conformance suite. The remaining gaps are mostly output formatting differences (named-vs-anonymous template functions, slight differences in `@defer` multi-file dependency emission) rather than functional bugs, but unusual code shapes can hit them. The current per-Angular-version pass rates are: - -| Angular version | Pass rate | Tests | -| ------------------ | --------- | ----- | -| v17 (latest patch) | 93.2% | 120 | -| v18 (latest patch) | 82.9% | 143 | -| v19 (latest patch) | 83.5% | 151 | -| v20 (latest patch) | 91.5% | 155 | -| v21 (latest patch) | 91.8% | 160 | - -For the current list of known issues, see [open issues on GitHub](https://github.com/analogjs/analog/issues). - -## Debugging - -The Analog Compiler emits structured debug output via the [`obug`](https://github.com/sxzz/obug) library, activated by the standard `DEBUG` environment variable: - -```bash -# Top-level compile events (per-file start, end, timing, fatal errors) -DEBUG=analog-compiler npm run build - -# Everything (compile + registry + resolve + emit) -DEBUG='analog-compiler*' npm run build - -# Just the registry-scanning trace -DEBUG=analog-compiler:registry npm run build -``` - -Available namespaces: - -| Namespace | What it traces | -| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `analog-compiler` | Per-file compile start/end with timing, class counts, and resource-dependency counts. Also surfaces fatal errors that would otherwise be silently caught. | -| `analog-compiler:registry` | Source-file and `.d.ts` scanning, barrel re-export resolution, candidate-file failures. Use this when a directive or pipe is not being recognized as a dependency. | -| `analog-compiler:resolve` | Cross-file dependency resolution decisions: how `imports: [...]` entries are resolved to underlying directives, NgModule export expansion, tuple barrel expansion. | -| `analog-compiler:emit` | Code emission and helper hoisting decisions, type-only import elision. | - -When `DEBUG` matches an `analog-compiler` namespace, the compiler also surfaces previously-swallowed errors — failed barrel-export lookups, unparseable workspace files, inline-style preprocessing failures, and `compileClassMetadata` failures. These are silent in normal operation to avoid noise, but turning them on is the fastest way to find out why your component is not being recognized as a directive. - -## Reporting bugs - -Bug reports are welcome at [github.com/analogjs/analog/issues](https://github.com/analogjs/analog/issues). To make a bug actionable, please include: - -- The smallest input file that reproduces the issue -- The Analog Compiler's output (available via `vite-plugin-inspect` or by saving the post-transform code from a debug step) -- The Analog Compiler debug log: `DEBUG='analog-compiler*' npm run build > debug.log 2>&1` -- The diff against `ngc`'s output for the same input, when you can produce one diff --git a/commitlint.config.cjs b/commitlint.config.cjs index 0b118df04..d319f928b 100644 --- a/commitlint.config.cjs +++ b/commitlint.config.cjs @@ -7,7 +7,6 @@ module.exports = { 2, 'always', [ - 'angular-compiler', 'vite-plugin-angular', 'vite-plugin-nitro', 'vitest-angular', diff --git a/packages/angular-compiler/README.md b/packages/angular-compiler/README.md deleted file mode 100644 index f049aafcb..000000000 --- a/packages/angular-compiler/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Analog - -The fullstack meta-framework for Angular - -Learn more at [analogjs.org](https://analogjs.org) diff --git a/packages/angular-compiler/package.json b/packages/angular-compiler/package.json deleted file mode 100644 index 7cd41a57e..000000000 --- a/packages/angular-compiler/package.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "@analogjs/angular-compiler", - "version": "2.5.0-beta.42", - "description": "Lightweight compiler for Angular", - "type": "module", - "license": "MIT", - "keywords": [ - "angular", - "compiler", - "vite", - "ivy", - "signals", - "analogjs" - ], - "author": "Brandon Roberts ", - "bugs": { - "url": "https://github.com/analogjs/analog/issues" - }, - "homepage": "https://github.com/analogjs/analog#readme", - "repository": { - "type": "git", - "url": "https://github.com/analogjs/analog.git" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/brandonroberts" - }, - "peerDependencies": { - "@angular/compiler": ">=17.0.0", - "@angular/compiler-cli": ">=17.0.0" - }, - "dependencies": { - "magic-string": "^0.30.0", - "obug": "^2.1.1", - "oxc-parser": "^0.121.0" - }, - "exports": { - "./package.json": "./package.json", - ".": { - "types": "./src/index.d.ts", - "import": "./src/index.js", - "default": "./src/index.js" - } - }, - "publishConfig": { - "access": "public", - "provenance": true - } -} diff --git a/packages/angular-compiler/project.json b/packages/angular-compiler/project.json deleted file mode 100644 index 04f8d5432..000000000 --- a/packages/angular-compiler/project.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "angular-compiler", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "packages/angular-compiler/src", - "projectType": "library", - "tags": ["type:release"], - "targets": { - "build-package": { - "executor": "@nx/js:tsc", - "options": { - "outputPath": "node_modules/@analogjs/angular-compiler", - "main": "packages/angular-compiler/src/index.ts", - "tsConfig": "packages/angular-compiler/tsconfig.lib.json", - "assets": ["packages/angular-compiler/*.md"], - "updateBuildableProjectDepsInPackageJson": false, - "generateExportsField": false - } - }, - "build": { - "executor": "nx:run-commands", - "outputs": ["{workspaceRoot}/node_modules/@analogjs/angular-compiler"], - "options": { - "commands": ["nx build-package angular-compiler"], - "parallel": false - }, - "dependsOn": ["^build"] - }, - "test": { - "executor": "@nx/vitest:test" - } - } -} diff --git a/packages/angular-compiler/src/index.ts b/packages/angular-compiler/src/index.ts deleted file mode 100644 index f3858f2fa..000000000 --- a/packages/angular-compiler/src/index.ts +++ /dev/null @@ -1,28 +0,0 @@ -export { - compile, - type CompileResult, - type CompileOptions, -} from './lib/compile.js'; -export { - scanFile, - type RegistryEntry, - type ComponentRegistry, -} from './lib/registry.js'; -export { - scanDtsFile, - scanPackageDts, - collectImportedPackages, - collectRelativeReExports, -} from './lib/dts-reader.js'; -export { jitTransform, type JitTransformResult } from './lib/jit-transform.js'; -export { generateHmrCode } from './lib/hmr.js'; -export { - inlineResourceUrls, - extractInlineStyles, -} from './lib/resource-inliner.js'; -export { - debugCompile, - debugRegistry, - debugResolve, - debugEmit, -} from './lib/debug.js'; diff --git a/packages/angular-compiler/src/test-setup.ts b/packages/angular-compiler/src/test-setup.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/angular-compiler/tsconfig.json b/packages/angular-compiler/tsconfig.json deleted file mode 100644 index e49bb45c6..000000000 --- a/packages/angular-compiler/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "preserve", - "strict": false, - "noImplicitOverride": true, - "moduleResolution": "bundler" - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/packages/angular-compiler/tsconfig.lib.json b/packages/angular-compiler/tsconfig.lib.json deleted file mode 100644 index 5fc2539c3..000000000 --- a/packages/angular-compiler/tsconfig.lib.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "preserve", - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"], - "allowSyntheticDefaultImports": true, - "moduleResolution": "bundler", - "skipLibCheck": true - }, - "include": ["**/*.ts"], - "exclude": [ - "**/*.spec.ts", - "**/*.test.ts", - "src/test-setup.ts", - "src/lib/__fixtures__", - "src/lib/test-helpers.ts" - ] -} diff --git a/packages/angular-compiler/tsconfig.spec.json b/packages/angular-compiler/tsconfig.spec.json deleted file mode 100644 index 50bf27c08..000000000 --- a/packages/angular-compiler/tsconfig.spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": ["vitest/globals", "node"] - }, - "include": [ - "vite.config.ts", - "vitest.config.ts", - "**/*.test.ts", - "**/*.spec.ts", - "**/*.d.ts" - ] -} diff --git a/packages/angular-compiler/vite.config.ts b/packages/angular-compiler/vite.config.ts deleted file mode 100644 index 171ff544d..000000000 --- a/packages/angular-compiler/vite.config.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -import { defineConfig } from 'vite'; - -// https://vitejs.dev/config/ -export default defineConfig(({ mode }) => ({ - build: { - target: ['es2020'], - }, - resolve: { - mainFields: ['module'], - }, - test: { - globals: true, - environment: 'jsdom', - setupFiles: ['src/test-setup.ts'], - include: ['**/*.spec.ts'], - reporters: ['default'], - }, -})); diff --git a/packages/astro-angular/package.json b/packages/astro-angular/package.json index b6eb57f66..0a6e2dba6 100644 --- a/packages/astro-angular/package.json +++ b/packages/astro-angular/package.json @@ -58,8 +58,7 @@ "@analogjs/storybook-angular", "@analogjs/vite-plugin-angular", "@analogjs/vite-plugin-nitro", - "@analogjs/vitest-angular", - "@analogjs/angular-compiler" + "@analogjs/vitest-angular" ], "migrations": "./migrations/migration.json" }, diff --git a/packages/content/package.json b/packages/content/package.json index d300b3b5f..471869054 100644 --- a/packages/content/package.json +++ b/packages/content/package.json @@ -64,8 +64,7 @@ "@analogjs/storybook-angular", "@analogjs/vite-plugin-angular", "@analogjs/vite-plugin-nitro", - "@analogjs/vitest-angular", - "@analogjs/angular-compiler" + "@analogjs/vitest-angular" ], "migrations": "./plugin/migrations.json" }, diff --git a/packages/platform/package.json b/packages/platform/package.json index 3f19c4e08..7ab15b267 100644 --- a/packages/platform/package.json +++ b/packages/platform/package.json @@ -85,8 +85,7 @@ "@analogjs/storybook-angular", "@analogjs/vite-plugin-angular", "@analogjs/vite-plugin-nitro", - "@analogjs/vitest-angular", - "@analogjs/angular-compiler" + "@analogjs/vitest-angular" ], "migrations": "./migrations/migration.json" }, diff --git a/packages/platform/src/lib/deps-plugin.ts b/packages/platform/src/lib/deps-plugin.ts index d115292e8..5311f5084 100644 --- a/packages/platform/src/lib/deps-plugin.ts +++ b/packages/platform/src/lib/deps-plugin.ts @@ -15,17 +15,17 @@ export function depsPlugin(options?: Options): Plugin[] { const useCompilationAPI = options?.vite === false || options?.vite?.experimental?.useAngularCompilationAPI; - const useAnalogCompiler = - options?.vite !== false && - options?.vite?.experimental?.useAnalogCompiler; + const fastCompile = + options?.fastCompile || + (options?.vite !== false && options?.vite?.fastCompile); const esbuild = - useCompilationAPI || useAnalogCompiler + useCompilationAPI || fastCompile ? {} : { exclude: ['**/*.ts', '**/*.js'] }; const oxc = - useCompilationAPI || useAnalogCompiler + useCompilationAPI || fastCompile ? {} : { exclude: ['**/*.ts', '**/*.js'] }; diff --git a/packages/platform/src/lib/options.ts b/packages/platform/src/lib/options.ts index fc920f99d..44d5c28b1 100644 --- a/packages/platform/src/lib/options.ts +++ b/packages/platform/src/lib/options.ts @@ -123,6 +123,17 @@ export interface Options { * Disable type checking diagnostics by the Angular compiler */ disableTypeChecking?: boolean; + /** + * Opt into the fast compile path. Skips Angular's template type-checking + * and routes compilation through an internal single-pass transform. + */ + fastCompile?: boolean; + /** + * Compilation output mode used when `fastCompile` is enabled. + * - `'full'` (default): Emit final Ivy definitions for application builds. + * - `'partial'`: Emit partial declarations for library publishing. + */ + fastCompileMode?: 'full' | 'partial'; /** * File replacements */ diff --git a/packages/platform/src/lib/platform-plugin.ts b/packages/platform/src/lib/platform-plugin.ts index 7d9fc690b..89aa99732 100644 --- a/packages/platform/src/lib/platform-plugin.ts +++ b/packages/platform/src/lib/platform-plugin.ts @@ -67,6 +67,8 @@ export function platformPlugin(opts: Options = {}): Plugin[] { liveReload: platformOptions.liveReload, inlineStylesExtension: platformOptions.inlineStylesExtension, fileReplacements: platformOptions.fileReplacements, + fastCompile: platformOptions.fastCompile, + fastCompileMode: platformOptions.fastCompileMode, ...(opts?.vite ?? {}), })) as any), serverModePlugin(), diff --git a/packages/router/package.json b/packages/router/package.json index 000d2a01b..595710d3c 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -39,8 +39,7 @@ "@analogjs/storybook-angular", "@analogjs/vite-plugin-angular", "@analogjs/vite-plugin-nitro", - "@analogjs/vitest-angular", - "@analogjs/angular-compiler" + "@analogjs/vitest-angular" ], "migrations": "./migrations/migration.json" }, diff --git a/packages/vite-plugin-angular/README.md b/packages/vite-plugin-angular/README.md index fe506e091..5bb798434 100644 --- a/packages/vite-plugin-angular/README.md +++ b/packages/vite-plugin-angular/README.md @@ -48,6 +48,28 @@ export default defineConfig({ > The `angular` plugin should be listed **first** in the plugins array. +## Fast Compile Mode + +`fastCompile` opts the plugin into a single-pass compilation path that emits Ivy instructions directly and skips Angular's template type-checking. It's intended for content-focused apps and faster dev iteration where build throughput matters more than inline type-safety feedback. + +```ts +export default defineConfig({ + plugins: [angular({ fastCompile: true })], +}); +``` + +When `fastCompile` is enabled, template and input type errors will not surface during compilation — run `ngc -p tsconfig.app.json --noEmit` as a separate step in your build script to keep full type safety: + +```json +{ + "scripts": { + "build": "ngc -p tsconfig.app.json --noEmit && vite build" + } +} +``` + +The fast compile path currently passes ~91% of Angular's conformance suite. Behavior and output may change between minor releases. + ## Setting up the TypeScript config The integration needs a `tsconfig.app.json` at the root of the project for compilation. diff --git a/packages/vite-plugin-angular/package.json b/packages/vite-plugin-angular/package.json index 01f03e370..5382c672c 100644 --- a/packages/vite-plugin-angular/package.json +++ b/packages/vite-plugin-angular/package.json @@ -36,7 +36,9 @@ } }, "dependencies": { - "@analogjs/angular-compiler": "^2.5.0-beta.42", + "magic-string": "^0.30.21", + "obug": "^2.1.1", + "oxc-parser": "^0.121.0", "tinyglobby": "^0.2.14", "ts-morph": "^21.0.0" }, @@ -49,8 +51,7 @@ "@analogjs/storybook-angular", "@analogjs/vite-plugin-angular", "@analogjs/vite-plugin-nitro", - "@analogjs/vitest-angular", - "@analogjs/angular-compiler" + "@analogjs/vitest-angular" ], "migrations": "./migrations/migration.json" }, diff --git a/packages/angular-compiler/scripts/setup-conformance.sh b/packages/vite-plugin-angular/scripts/setup-conformance.sh similarity index 91% rename from packages/angular-compiler/scripts/setup-conformance.sh rename to packages/vite-plugin-angular/scripts/setup-conformance.sh index 296bf9f72..5a490f348 100755 --- a/packages/angular-compiler/scripts/setup-conformance.sh +++ b/packages/vite-plugin-angular/scripts/setup-conformance.sh @@ -1,6 +1,6 @@ #!/bin/bash # Sparse-clone Angular's compliance test fixtures at a specific version. -# Usage: bash packages/angular-compiler/scripts/setup-conformance.sh [version] +# Usage: bash packages/vite-plugin-angular/scripts/setup-conformance.sh [version] # Default: latest release from GitHub set -e @@ -63,4 +63,4 @@ cd "$TARGET" git sparse-checkout set packages/compiler-cli/test/compliance/test_cases echo "Done. $(find packages/compiler-cli/test/compliance/test_cases -name '*.ts' | wc -l | tr -d ' ') test files downloaded." -echo "Run: ANGULAR_SOURCE_DIR=$TARGET npx vitest run packages/angular-compiler/src/lib/conformance.spec.ts" +echo "Run: ANGULAR_SOURCE_DIR=$TARGET npx vitest run packages/vite-plugin-angular/src/lib/compiler/conformance.spec.ts" diff --git a/packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts b/packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts index 9dd52d5c9..a25e90cee 100644 --- a/packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts +++ b/packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts @@ -62,7 +62,7 @@ import { } from './plugins/file-replacements.plugin.js'; import { routerPlugin } from './router-plugin.js'; import { createHash } from 'node:crypto'; -import { analogCompilerPlugin } from './analog-compiler-plugin.js'; +import { fastCompilePlugin } from './fast-compile-plugin.js'; import { TS_EXT_REGEX, createTsConfigGetter, @@ -113,15 +113,20 @@ export interface PluginOptions { liveReload?: boolean; disableTypeChecking?: boolean; fileReplacements?: FileReplacement[]; + /** + * Opt into the fast compile path. Skips Angular's template type-checking + * and routes compilation through an internal single-pass transform. + * Defaults to `false`. + */ + fastCompile?: boolean; + /** + * Compilation output mode used when `fastCompile` is enabled. + * - `'full'` (default): Emit final Ivy definitions for application builds. + * - `'partial'`: Emit partial declarations for library publishing. + */ + fastCompileMode?: 'full' | 'partial'; experimental?: { useAngularCompilationAPI?: boolean; - useAnalogCompiler?: boolean; - /** - * Compilation output mode for the Analog compiler. - * - `'full'` (default): Emit final Ivy definitions for application builds. - * - `'partial'`: Emit partial declarations for library publishing. - */ - analogCompilationMode?: 'full' | 'partial'; }; } @@ -159,9 +164,8 @@ export function angular(options?: PluginOptions): Plugin[] { fileReplacements: options?.fileReplacements ?? [], useAngularCompilationAPI: options?.experimental?.useAngularCompilationAPI ?? false, - useAnalogCompiler: options?.experimental?.useAnalogCompiler ?? false, - analogCompilationMode: - options?.experimental?.analogCompilationMode ?? 'full', + fastCompile: options?.fastCompile ?? false, + fastCompileMode: options?.fastCompileMode ?? 'full', }; let resolvedConfig: ResolvedConfig; @@ -786,8 +790,8 @@ export function angular(options?: PluginOptions): Plugin[] { }; } - const compilationPlugin = pluginOptions.useAnalogCompiler - ? analogCompilerPlugin({ + const compilationPlugin = pluginOptions.fastCompile + ? fastCompilePlugin({ tsconfigGetter: pluginOptions.tsconfigGetter, workspaceRoot: pluginOptions.workspaceRoot, inlineStylesExtension: pluginOptions.inlineStylesExtension, @@ -797,14 +801,14 @@ export function angular(options?: PluginOptions): Plugin[] { transformFilter: options?.transformFilter, isTest, isAstroIntegration, - analogCompilationMode: pluginOptions.analogCompilationMode, + fastCompileMode: pluginOptions.fastCompileMode, }) : angularPlugin(); return [ replaceFiles(pluginOptions.fileReplacements, pluginOptions.workspaceRoot), compilationPlugin, - !pluginOptions.useAnalogCompiler && + !pluginOptions.fastCompile && pluginOptions.liveReload && liveReloadPlugin({ classNames, fileEmitter }), ...(isTest && !isStackBlitz ? angularVitestPlugins() : []), diff --git a/packages/angular-compiler/COMPILER.md b/packages/vite-plugin-angular/src/lib/compiler/COMPILER.md similarity index 93% rename from packages/angular-compiler/COMPILER.md rename to packages/vite-plugin-angular/src/lib/compiler/COMPILER.md index 95193f37b..8638b4f53 100644 --- a/packages/angular-compiler/COMPILER.md +++ b/packages/vite-plugin-angular/src/lib/compiler/COMPILER.md @@ -1,98 +1,25 @@ -# Analog Angular Compiler +# Analog Angular Compiler (internal) A lightweight Angular compiler that transforms decorators and signal-based reactive APIs into Ivy static definitions. Designed for fast dev server compilation via Vite, without requiring a full TypeScript program. -## Installation - -```bash -npm install @analogjs/angular-compiler -``` - -Peer dependencies: `@angular/compiler` >=17, `@angular/compiler-cli` >=17, `@angular/build` >=17, `vite` >=6. Compatibility validated against `17.3.12`, `18.2.14`, `19.0.0`, `20.0.0`, `21.0.0`, and `next` on every PR via the matrix in `.github/workflows/angular-compiler-compat.yml` (see § Compatibility Testing). Components that use `@defer` at runtime require Angular 18+. - -## Entry Point - -| Import | Exports | Use case | -| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -| `@analogjs/angular-compiler` | `compile()`, `scanFile()`, `scanDtsFile()`, `scanPackageDts()`, `collectImportedPackages()`, `collectRelativeReExports()`, `jitTransform()`, `inlineResourceUrls()`, `extractInlineStyles()`, `generateHmrCode()` | Programmatic compiler API | - -The compiler is integrated into `@analogjs/vite-plugin-angular` via the `experimental.useAnalogCompiler` flag — there is no separate Vite plugin entry point. - -## Usage - -### Via Analog Platform (recommended) +This is an **internal** component of `@analogjs/vite-plugin-angular`. It is not published as a standalone package. Use the `fastCompile` flag on the vite plugin to opt into it: ```ts -import analog from '@analogjs/platform'; +import angular from '@analogjs/vite-plugin-angular'; export default defineConfig({ - plugins: [ - analog({ - vite: { - experimental: { - useAnalogCompiler: true, - }, - }, - }), - ], + plugins: [angular({ fastCompile: true })], }); ``` -### Programmatic API - -```ts -import { - compile, - scanFile, - scanDtsFile, - scanPackageDts, - collectImportedPackages, - jitTransform, - inlineResourceUrls, - extractInlineStyles, -} from '@analogjs/angular-compiler'; - -// Compile a single file -const result = compile(sourceCode, fileName, { registry }); -// result.code — compiled JavaScript -// result.map — V3 source map -// result.resourceDependencies — external template/style paths read - -// Compile in partial (library) mode -const libResult = compile(sourceCode, fileName, { - registry, - compilationMode: 'partial', -}); -// Emits ɵɵngDeclareComponent/ɵɵngDeclareDirective/etc. for library publishing - -// Scan a source file for Angular metadata (uses OXC Rust parser) -const entries = scanFile(code, fileName); -// entries: [{ selector, kind, className, fileName, inputs, outputs, ... }] - -// Scan a .d.ts file for pre-compiled Angular declarations -const dtsEntries = scanDtsFile(dtsCode, fileName); -// Reads ɵɵDirectiveDeclaration/ComponentDeclaration/PipeDeclaration type params - -// Scan all .d.ts files in an npm package -const pkgEntries = scanPackageDts('@angular/router', projectRoot); - -// Collect bare-specifier package names from imports -const packages = collectImportedPackages(code, fileName); -// Set { '@angular/router', 'rxjs', ... } - -// Inline templateUrl/styleUrl(s) in source code (OXC AST rewriting) -const inlined = inlineResourceUrls(sourceCode, fileName); - -// Extract inline style strings for preprocessing (OXC parser) -const styles = extractInlineStyles(sourceCode, fileName); -``` +Peer dependencies (inherited from `vite-plugin-angular`): `@angular/compiler` >=17, `@angular/compiler-cli` >=17, `@angular/build` >=17, `vite` >=6. Compatibility validated against `17.3.12`, `18.2.14`, `19.0.0`, `20.0.0`, `21.0.0`, and `next` on every PR via the matrix in `.github/workflows/compiler-compat.yml` (see § Compatibility Testing). Components that use `@defer` at runtime require Angular 18+. ## Architecture ``` Source file (.ts) │ - ├─ vite-plugin-angular (buildStart, when useAnalogCompiler is true) + ├─ vite-plugin-angular (buildStart, when fastCompile is true) │ @angular/compiler-cli readConfiguration() → rootNames │ OXC parser ──▶ scanFile() ──▶ ComponentRegistry │ (selectors, inputs, outputs, pipes, NgModule exports) @@ -122,7 +49,7 @@ Source file (.ts) MagicString (surgical edits on original source → JS + source map) ``` -The compiler is integrated into `@analogjs/vite-plugin-angular` as an alternative compilation path alongside ngtsc and the Angular Compilation API. When `experimental.useAnalogCompiler` is enabled, the vite plugin: +The compiler is integrated into `@analogjs/vite-plugin-angular` as an alternative compilation path alongside ngtsc and the Angular Compilation API. When `fastCompile` is enabled, the vite plugin: 1. Scans all source files with `scanFile()` at build start to populate the `ComponentRegistry` 2. Inlines external resources (`templateUrl`, `styleUrl`) via OXC AST rewriting before compilation @@ -132,7 +59,7 @@ The compiler is integrated into `@analogjs/vite-plugin-angular` as an alternativ 6. Appends HMR code for Angular declarations in dev mode (components via `ɵɵreplaceMetadata`, directives/pipes via field-swap + invalidate) 7. Injects synthetic imports for NgModule-exported classes -The existing vite-plugin-angular plugins (build optimizer, router, vitest, etc.) continue to work alongside the analog compiler. +The existing vite-plugin-angular plugins (build optimizer, router, vitest, etc.) continue to work alongside the fast-compile path. ## Source Files @@ -495,31 +422,31 @@ Remaining soft-failures are output formatting differences (`@defer` multi-file d ```bash # Specific major version (resolves latest patch) -bash packages/angular-compiler/scripts/setup-conformance.sh 19 -ANGULAR_SOURCE_DIR=.angular-conformance npx vitest run packages/angular-compiler/src/lib/conformance.spec.ts +bash packages/vite-plugin-angular/scripts/setup-conformance.sh 19 +ANGULAR_SOURCE_DIR=.angular-conformance npx vitest run packages/vite-plugin-angular/src/lib/compiler/conformance.spec.ts # Exact version -bash packages/angular-compiler/scripts/setup-conformance.sh 21.0.0 +bash packages/vite-plugin-angular/scripts/setup-conformance.sh 21.0.0 # Latest stable release (auto-detected via GitHub API) -bash packages/angular-compiler/scripts/setup-conformance.sh -bash packages/angular-compiler/scripts/setup-conformance.sh latest +bash packages/vite-plugin-angular/scripts/setup-conformance.sh +bash packages/vite-plugin-angular/scripts/setup-conformance.sh latest # Latest prerelease (-next.N) -bash packages/angular-compiler/scripts/setup-conformance.sh next +bash packages/vite-plugin-angular/scripts/setup-conformance.sh next # Local (auto-detects ~/projects/angular/angular if present) -npx vitest run packages/angular-compiler/src/lib/conformance.spec.ts +npx vitest run packages/vite-plugin-angular/src/lib/compiler/conformance.spec.ts ``` -CI runs a matrix of Angular 17, 18, 19, 20, 21, latest, and next on every push to `feat/angular-compiler` via `.github/workflows/conformance.yml`. +CI runs a matrix of Angular 17, 18, 19, 20, 21, latest, and next on every pull request via `.github/workflows/conformance.yml`. ### Compatibility Testing -Conformance testing answers _"does our output match Angular's reference fixtures?"_ but uses the workspace-pinned `@angular/compiler` to do the compilation — so it cannot catch API-surface drift between Angular versions (e.g. a class export disappearing in a patch release). The compatibility matrix in `.github/workflows/angular-compiler-compat.yml` complements it by: +Conformance testing answers _"does our output match Angular's reference fixtures?"_ but uses the workspace-pinned `@angular/compiler` to do the compilation — so it cannot catch API-surface drift between Angular versions (e.g. a class export disappearing in a patch release). The compatibility matrix in `.github/workflows/compiler-compat.yml` complements it by: 1. Overriding `@angular/compiler` and `@angular/compiler-cli` to each supported version (`17.3.12`, `18.2.14`, `19.0.0`, `20.0.0`, `21.0.0`, plus `next`) via `pnpm.overrides`. -2. Running the regular `packages/angular-compiler/src/lib/` test suite against the swapped version with `DEBUG=analog-compiler*` enabled, so silently-caught errors (e.g. constructor regressions) appear in CI logs. +2. Running the regular `packages/vite-plugin-angular/src/lib/compiler/` test suite against the swapped version with `DEBUG=analog-fast-compile*` enabled, so silently-caught errors (e.g. constructor regressions) appear in CI logs. 3. On a `push` to `beta`, auto-opening (or commenting on an existing) GitHub issue using the bug-report template's section structure when a numeric matrix slot fails. PR failures show in the PR check and don't open issues to avoid spam. The matrix mixes two version-pinning strategies: @@ -530,4 +457,4 @@ The matrix mixes two version-pinning strategies: Known v17 limitation: components that use `@defer` at runtime are not supported on Angular 17. The v17 `@defer` ABI requires populated `meta.deferBlocks` and `meta.deferrableTypes` Maps that the compiler currently sets to empty. Non-`@defer` components compile cleanly. See `compile.ts` for the inline rationale. -The workflow runs on `pull_request`, `push` to `beta`, and `workflow_dispatch`. When `packages/angular-compiler/package.json` bumps the `peerDependencies` floor, drop the lowest matrix slot(s). When a new Angular major ships, add a new floor slot. When an LTS patch supersedes the current pinned patch for v17/v18, bump the patch in the matrix. +The workflow runs on `pull_request`, `push` to `beta`, and `workflow_dispatch`. When `packages/vite-plugin-angular/package.json` bumps the `peerDependencies` floor, drop the lowest matrix slot(s). When a new Angular major ships, add a new floor slot. When an LTS patch supersedes the current pinned patch for v17/v18, bump the patch in the matrix. diff --git a/packages/angular-compiler/src/lib/__fixtures__/test.component.css b/packages/vite-plugin-angular/src/lib/compiler/__fixtures__/test.component.css similarity index 100% rename from packages/angular-compiler/src/lib/__fixtures__/test.component.css rename to packages/vite-plugin-angular/src/lib/compiler/__fixtures__/test.component.css diff --git a/packages/angular-compiler/src/lib/__fixtures__/test.component.html b/packages/vite-plugin-angular/src/lib/compiler/__fixtures__/test.component.html similarity index 100% rename from packages/angular-compiler/src/lib/__fixtures__/test.component.html rename to packages/vite-plugin-angular/src/lib/compiler/__fixtures__/test.component.html diff --git a/packages/angular-compiler/src/lib/__fixtures__/test.component.scss b/packages/vite-plugin-angular/src/lib/compiler/__fixtures__/test.component.scss similarity index 100% rename from packages/angular-compiler/src/lib/__fixtures__/test.component.scss rename to packages/vite-plugin-angular/src/lib/compiler/__fixtures__/test.component.scss diff --git a/packages/angular-compiler/src/lib/angular-version.ts b/packages/vite-plugin-angular/src/lib/compiler/angular-version.ts similarity index 95% rename from packages/angular-compiler/src/lib/angular-version.ts rename to packages/vite-plugin-angular/src/lib/compiler/angular-version.ts index 617621f5f..c2b5f019e 100644 --- a/packages/angular-compiler/src/lib/angular-version.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/angular-version.ts @@ -6,7 +6,7 @@ import * as o from '@angular/compiler'; // Why this matters: Angular's compiler API surface (enum members, // metadata shapes, output formats) shifts between major versions in ways // that can't always be papered over with duck typing. The compatibility -// matrix in .github/workflows/angular-compiler-compat.yml runs the test +// matrix in .github/workflows/compiler-compat.yml runs the test // suite against multiple installed versions to catch this drift, and the // version-aware code paths in compile.ts / js-emitter.ts / metadata.ts // gate behavior on `ANGULAR_MAJOR` to keep the compiler working across diff --git a/packages/angular-compiler/src/lib/class-field-lowering.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/class-field-lowering.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/class-field-lowering.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/class-field-lowering.spec.ts diff --git a/packages/angular-compiler/src/lib/class-field-lowering.ts b/packages/vite-plugin-angular/src/lib/compiler/class-field-lowering.ts similarity index 100% rename from packages/angular-compiler/src/lib/class-field-lowering.ts rename to packages/vite-plugin-angular/src/lib/compiler/class-field-lowering.ts diff --git a/packages/angular-compiler/src/lib/compile.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/compile.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/compile.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/compile.spec.ts diff --git a/packages/angular-compiler/src/lib/compile.ts b/packages/vite-plugin-angular/src/lib/compiler/compile.ts similarity index 99% rename from packages/angular-compiler/src/lib/compile.ts rename to packages/vite-plugin-angular/src/lib/compiler/compile.ts index 47995f4d4..6ecc4e765 100644 --- a/packages/angular-compiler/src/lib/compile.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/compile.ts @@ -616,7 +616,7 @@ export function compile( resourceDependencies.push(templatePath); } catch { console.warn( - `[angular-compiler] Could not read template file "${meta.templateUrl}" for ${className}`, + `[fast-compile] Could not read template file "${meta.templateUrl}" for ${className}`, ); } } @@ -632,7 +632,7 @@ export function compile( resourceDependencies.push(stylePath); } catch { console.warn( - `[angular-compiler] Could not read style file "${url}" for ${className}`, + `[fast-compile] Could not read style file "${url}" for ${className}`, ); } } @@ -688,7 +688,7 @@ export function compile( if (templateErrors.length > 0) { const firstError = templateErrors[0]; classCompileError = new Error( - `[angular-compiler] Template parse error in ${fileName} (${className}): ${firstError.msg}`, + `[fast-compile] Template parse error in ${fileName} (${className}): ${firstError.msg}`, ); return; } @@ -1174,7 +1174,7 @@ export function compile( new o.ExpressionStatement(classMetadataExpr), ); } catch (e) { - // Skip if compileClassMetadata fails — surfaced via DEBUG=analog-compiler + // Skip if compileClassMetadata fails — surfaced via DEBUG=analog-fast-compile if (debugCompile.enabled) { debugCompile( 'compileClassMetadata failed for %s in %s: %s', diff --git a/packages/angular-compiler/src/lib/component.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/component.spec.ts similarity index 99% rename from packages/angular-compiler/src/lib/component.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/component.spec.ts index 03ef97c66..9227702d6 100644 --- a/packages/angular-compiler/src/lib/component.spec.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/component.spec.ts @@ -99,7 +99,7 @@ describe('@Component', () => { it('resolves ${...} interpolation against module-level string consts in template', () => { // Components in the wild often hoist long Tailwind class chains into // module-level `const`s and reference them from the inline template via - // JS template-literal interpolation. The Analog compiler must resolve + // JS template-literal interpolation. The fast-compile path must resolve // those references at parse time so Angular sees the fully-expanded // class attribute. const result = compile( @@ -1534,7 +1534,7 @@ describe('setClassMetadata construction shape', () => { // `new o.LiteralMapPropertyAssignment(...)` throws "is not a constructor" // when the export is missing, and the surrounding try/catch in compile.ts // silently disables setClassMetadata emission for every class in the - // project — visible only under DEBUG=analog-compiler*. + // project — visible only under DEBUG=analog-fast-compile*. // // The fix is to construct entries as plain `{ key, value, quoted }` // object literals — both Angular's own emitter and Analog's `JSEmitter` diff --git a/packages/angular-compiler/src/lib/conformance.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/conformance.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/conformance.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/conformance.spec.ts diff --git a/packages/angular-compiler/src/lib/constants.ts b/packages/vite-plugin-angular/src/lib/compiler/constants.ts similarity index 94% rename from packages/angular-compiler/src/lib/constants.ts rename to packages/vite-plugin-angular/src/lib/compiler/constants.ts index 64fea3c4b..953f98044 100644 --- a/packages/angular-compiler/src/lib/constants.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/constants.ts @@ -1,5 +1,5 @@ /** - * Shared Angular name constants for the analog compiler. + * Shared Angular name constants for the fast-compile path. * * Centralised here to prevent drift when decorator sets are referenced * across multiple source files (compile, registry, JIT, metadata). diff --git a/packages/angular-compiler/src/lib/constructor-di.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/constructor-di.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/constructor-di.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/constructor-di.spec.ts diff --git a/packages/angular-compiler/src/lib/cross-file-resolution.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/cross-file-resolution.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/cross-file-resolution.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/cross-file-resolution.spec.ts diff --git a/packages/angular-compiler/src/lib/debug.ts b/packages/vite-plugin-angular/src/lib/compiler/debug.ts similarity index 76% rename from packages/angular-compiler/src/lib/debug.ts rename to packages/vite-plugin-angular/src/lib/compiler/debug.ts index 7249a7b1b..812cb2ba4 100644 --- a/packages/angular-compiler/src/lib/debug.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/debug.ts @@ -1,17 +1,17 @@ import { createDebug } from 'obug'; -// Structured debug output for the Analog compiler. Activated via the +// Structured debug output for the fast-compile path. Activated via the // `DEBUG` environment variable, e.g.: // -// DEBUG=analog-compiler npm run build # top-level events -// DEBUG=analog-compiler:* npm run build # everything -// DEBUG=analog-compiler:registry npm run build # only registry +// DEBUG=analog-fast-compile npm run build # top-level events +// DEBUG=analog-fast-compile:* npm run build # everything +// DEBUG=analog-fast-compile:registry npm run build # only registry // // Each namespace is a `Debugger` from obug — callable like console.log // (with %s/%d/%O formatters), with a `.enabled` boolean for cheap // gating before expensive payload construction. -const root = createDebug('analog-compiler'); +const root = createDebug('analog-fast-compile'); /** * Top-level compile/transform events: per-file start, end, timing, diff --git a/packages/angular-compiler/src/lib/decorator-fields.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/decorator-fields.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/decorator-fields.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/decorator-fields.spec.ts diff --git a/packages/angular-compiler/src/lib/defer.ts b/packages/vite-plugin-angular/src/lib/compiler/defer.ts similarity index 100% rename from packages/angular-compiler/src/lib/defer.ts rename to packages/vite-plugin-angular/src/lib/compiler/defer.ts diff --git a/packages/angular-compiler/src/lib/directive.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/directive.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/directive.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/directive.spec.ts diff --git a/packages/angular-compiler/src/lib/dts-reader.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/dts-reader.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/dts-reader.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/dts-reader.spec.ts diff --git a/packages/angular-compiler/src/lib/dts-reader.ts b/packages/vite-plugin-angular/src/lib/compiler/dts-reader.ts similarity index 100% rename from packages/angular-compiler/src/lib/dts-reader.ts rename to packages/vite-plugin-angular/src/lib/compiler/dts-reader.ts diff --git a/packages/angular-compiler/src/lib/error-handling.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/error-handling.spec.ts similarity index 98% rename from packages/angular-compiler/src/lib/error-handling.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/error-handling.spec.ts index 9bbd47b04..ddcbd0ffb 100644 --- a/packages/angular-compiler/src/lib/error-handling.spec.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/error-handling.spec.ts @@ -120,6 +120,6 @@ describe('Error Handling', () => { `, 'bad.ts', ), - ).toThrow('[angular-compiler] Template parse error'); + ).toThrow('[fast-compile] Template parse error'); }); }); diff --git a/packages/angular-compiler/src/lib/hmr.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/hmr.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/hmr.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/hmr.spec.ts diff --git a/packages/angular-compiler/src/lib/hmr.ts b/packages/vite-plugin-angular/src/lib/compiler/hmr.ts similarity index 100% rename from packages/angular-compiler/src/lib/hmr.ts rename to packages/vite-plugin-angular/src/lib/compiler/hmr.ts diff --git a/packages/angular-compiler/src/lib/i18n.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/i18n.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/i18n.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/i18n.spec.ts diff --git a/packages/angular-compiler/src/lib/index.ts b/packages/vite-plugin-angular/src/lib/compiler/index.ts similarity index 87% rename from packages/angular-compiler/src/lib/index.ts rename to packages/vite-plugin-angular/src/lib/compiler/index.ts index f8d99f7f2..94eebee1b 100644 --- a/packages/angular-compiler/src/lib/index.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/index.ts @@ -8,8 +8,10 @@ export { scanDtsFile, scanPackageDts, collectImportedPackages, + collectRelativeReExports, } from './dts-reader.js'; export { jitTransform, type JitTransformResult } from './jit-transform.js'; +export { generateHmrCode } from './hmr.js'; export { inlineResourceUrls, extractInlineStyles } from './resource-inliner.js'; export { debugCompile, diff --git a/packages/angular-compiler/src/lib/injectable.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/injectable.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/injectable.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/injectable.spec.ts diff --git a/packages/angular-compiler/src/lib/integration.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/integration.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/integration.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/integration.spec.ts diff --git a/packages/angular-compiler/src/lib/jit-integration.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/jit-integration.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/jit-integration.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/jit-integration.spec.ts diff --git a/packages/angular-compiler/src/lib/jit-metadata.ts b/packages/vite-plugin-angular/src/lib/compiler/jit-metadata.ts similarity index 100% rename from packages/angular-compiler/src/lib/jit-metadata.ts rename to packages/vite-plugin-angular/src/lib/compiler/jit-metadata.ts diff --git a/packages/angular-compiler/src/lib/jit-transform.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/jit-transform.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/jit-transform.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/jit-transform.spec.ts diff --git a/packages/angular-compiler/src/lib/jit-transform.ts b/packages/vite-plugin-angular/src/lib/compiler/jit-transform.ts similarity index 100% rename from packages/angular-compiler/src/lib/jit-transform.ts rename to packages/vite-plugin-angular/src/lib/compiler/jit-transform.ts diff --git a/packages/angular-compiler/src/lib/js-emitter.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/js-emitter.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/js-emitter.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/js-emitter.spec.ts diff --git a/packages/angular-compiler/src/lib/js-emitter.ts b/packages/vite-plugin-angular/src/lib/compiler/js-emitter.ts similarity index 99% rename from packages/angular-compiler/src/lib/js-emitter.ts rename to packages/vite-plugin-angular/src/lib/compiler/js-emitter.ts index 6052d8307..c588eedac 100644 --- a/packages/angular-compiler/src/lib/js-emitter.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/js-emitter.ts @@ -285,7 +285,7 @@ class JSEmitter implements o.ExpressionVisitor, o.StatementVisitor { const op = BINARY_OP_STR.get(ast.operator); if (op === undefined) { throw new Error( - `[angular-compiler] Unsupported BinaryOperator value ${ast.operator} ` + + `[fast-compile] Unsupported BinaryOperator value ${ast.operator} ` + `on @angular/compiler ${o.VERSION?.full ?? '(unknown version)'}`, ); } diff --git a/packages/angular-compiler/src/lib/metadata-emit.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/metadata-emit.spec.ts similarity index 99% rename from packages/angular-compiler/src/lib/metadata-emit.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/metadata-emit.spec.ts index 90259823b..4881c9116 100644 --- a/packages/angular-compiler/src/lib/metadata-emit.spec.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/metadata-emit.spec.ts @@ -208,7 +208,7 @@ describe('Module-level string const interpolation in metadata', () => { // const tw = `text-zinc-700 hover:text-zinc-900`; // @Component({ template: `x` }) // - // The Analog compiler must resolve those `${...}` expressions at metadata + // The fast-compile path must resolve those `${...}` expressions at metadata // extraction time so Angular's template parser sees the fully-expanded // class attribute. Otherwise the template ends up empty (silent failure) // or contains the literal `${tw}` token (parse error). diff --git a/packages/angular-compiler/src/lib/metadata.ts b/packages/vite-plugin-angular/src/lib/compiler/metadata.ts similarity index 100% rename from packages/angular-compiler/src/lib/metadata.ts rename to packages/vite-plugin-angular/src/lib/compiler/metadata.ts diff --git a/packages/angular-compiler/src/lib/ngmodule.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/ngmodule.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/ngmodule.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/ngmodule.spec.ts diff --git a/packages/angular-compiler/src/lib/partial.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/partial.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/partial.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/partial.spec.ts diff --git a/packages/angular-compiler/src/lib/pipe.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/pipe.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/pipe.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/pipe.spec.ts diff --git a/packages/angular-compiler/src/lib/registry.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/registry.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/registry.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/registry.spec.ts diff --git a/packages/angular-compiler/src/lib/registry.ts b/packages/vite-plugin-angular/src/lib/compiler/registry.ts similarity index 99% rename from packages/angular-compiler/src/lib/registry.ts rename to packages/vite-plugin-angular/src/lib/compiler/registry.ts index 1ea24b02b..792a8b815 100644 --- a/packages/angular-compiler/src/lib/registry.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/registry.ts @@ -70,7 +70,7 @@ export function scanFile(code: string, fileName: string): RegistryEntry[] { // (with or without `export`/`as const`) where every element is a bare // class identifier. These are how spartan-style libraries expose a // group of directives behind a single import (e.g. `HlmSelectImports`). - // Without registering them, the analog compiler treats the bare + // Without registering them, the fast-compile path treats the bare // identifier as an unknown directive and Angular's runtime never // matches the underlying classes. for (const node of program.body) { diff --git a/packages/angular-compiler/src/lib/resource-inliner.ts b/packages/vite-plugin-angular/src/lib/compiler/resource-inliner.ts similarity index 100% rename from packages/angular-compiler/src/lib/resource-inliner.ts rename to packages/vite-plugin-angular/src/lib/compiler/resource-inliner.ts diff --git a/packages/angular-compiler/src/lib/style-ast.ts b/packages/vite-plugin-angular/src/lib/compiler/style-ast.ts similarity index 100% rename from packages/angular-compiler/src/lib/style-ast.ts rename to packages/vite-plugin-angular/src/lib/compiler/style-ast.ts diff --git a/packages/angular-compiler/src/lib/styles.ts b/packages/vite-plugin-angular/src/lib/compiler/styles.ts similarity index 93% rename from packages/angular-compiler/src/lib/styles.ts rename to packages/vite-plugin-angular/src/lib/compiler/styles.ts index a422c48e3..b6c55f97b 100644 --- a/packages/angular-compiler/src/lib/styles.ts +++ b/packages/vite-plugin-angular/src/lib/compiler/styles.ts @@ -32,7 +32,7 @@ export async function resolveStyleFiles( result.set(filePath, processed.code); } catch (e: any) { console.warn( - `[angular-compiler] Style preprocessing failed for ${filePath}: ${e.message}`, + `[fast-compile] Style preprocessing failed for ${filePath}: ${e.message}`, ); } } @@ -72,7 +72,7 @@ export async function preprocessInlineStyles( result.set(i, processed.code); } catch (e: any) { console.warn( - `[angular-compiler] Inline style preprocessing failed in ${id}: ${e.message}`, + `[fast-compile] Inline style preprocessing failed in ${id}: ${e.message}`, ); } } diff --git a/packages/angular-compiler/src/lib/test-helpers.ts b/packages/vite-plugin-angular/src/lib/compiler/test-helpers.ts similarity index 100% rename from packages/angular-compiler/src/lib/test-helpers.ts rename to packages/vite-plugin-angular/src/lib/compiler/test-helpers.ts diff --git a/packages/angular-compiler/src/lib/type-elision.spec.ts b/packages/vite-plugin-angular/src/lib/compiler/type-elision.spec.ts similarity index 100% rename from packages/angular-compiler/src/lib/type-elision.spec.ts rename to packages/vite-plugin-angular/src/lib/compiler/type-elision.spec.ts diff --git a/packages/angular-compiler/src/lib/type-elision.ts b/packages/vite-plugin-angular/src/lib/compiler/type-elision.ts similarity index 100% rename from packages/angular-compiler/src/lib/type-elision.ts rename to packages/vite-plugin-angular/src/lib/compiler/type-elision.ts diff --git a/packages/angular-compiler/src/lib/utils.ts b/packages/vite-plugin-angular/src/lib/compiler/utils.ts similarity index 100% rename from packages/angular-compiler/src/lib/utils.ts rename to packages/vite-plugin-angular/src/lib/compiler/utils.ts diff --git a/packages/vite-plugin-angular/src/lib/analog-compiler-plugin.ts b/packages/vite-plugin-angular/src/lib/fast-compile-plugin.ts similarity index 90% rename from packages/vite-plugin-angular/src/lib/analog-compiler-plugin.ts rename to packages/vite-plugin-angular/src/lib/fast-compile-plugin.ts index 5498dc852..da9a9d9c7 100644 --- a/packages/vite-plugin-angular/src/lib/analog-compiler-plugin.ts +++ b/packages/vite-plugin-angular/src/lib/fast-compile-plugin.ts @@ -24,7 +24,7 @@ import { debugCompile, debugRegistry, type ComponentRegistry, -} from '@analogjs/angular-compiler'; +} from './compiler/index.js'; import { TS_EXT_REGEX, @@ -46,7 +46,7 @@ import { shouldPreprocessTestCss, } from './utils/virtual-resources.js'; -export interface AnalogCompilerPluginOptions { +export interface FastCompilePluginOptions { tsconfigGetter: () => string; workspaceRoot: string; inlineStylesExtension: string; @@ -56,21 +56,21 @@ export interface AnalogCompilerPluginOptions { transformFilter?: (code: string, id: string) => boolean; isTest: boolean; isAstroIntegration: boolean; - analogCompilationMode?: 'full' | 'partial'; + fastCompileMode?: 'full' | 'partial'; } -export function analogCompilerPlugin( - pluginOptions: AnalogCompilerPluginOptions, +export function fastCompilePlugin( + pluginOptions: FastCompilePluginOptions, ): Plugin { let resolvedConfig: ResolvedConfig; let tsConfigResolutionContext: TsConfigResolutionContext | null = null; let watchMode = false; - // Analog compiler state - const analogRegistry: ComponentRegistry = new Map(); - const analogResourceToSource = new Map(); + // fast-compile plugin state + const registry: ComponentRegistry = new Map(); + const resourceToSource = new Map(); const scannedDtsPackages = new Set(); - let analogProjectRoot = ''; + let projectRoot = ''; let useDefineForClassFields = true; /** @@ -110,8 +110,8 @@ export function analogCompilerPlugin( // At buildStart we want stable registry entries (don't overwrite // an earlier scan with a barrel re-scan); HMR explicitly asks // for overwrite so updated metadata replaces stale entries. - if (overwrite || !analogRegistry.has(entry.className)) { - analogRegistry.set(entry.className, entry); + if (overwrite || !registry.has(entry.className)) { + registry.set(entry.className, entry); } } // Collect every relative re-export specifier via OXC AST so @@ -152,14 +152,14 @@ export function analogCompilerPlugin( } } - async function initAnalogCompiler() { + async function initFastCompile() { if (pluginOptions.jit) return; // JIT: no registry scan needed // Scan all source files to build the registry - analogRegistry.clear(); + registry.clear(); scannedDtsPackages.clear(); const resolvedTsConfigPath = resolveTsConfigPath(); - analogProjectRoot = dirname(resolvedTsConfigPath); + projectRoot = dirname(resolvedTsConfigPath); const config = compilerCli.readConfiguration(resolvedTsConfigPath); useDefineForClassFields = config.options?.useDefineForClassFields ?? true; @@ -174,7 +174,7 @@ export function analogCompilerPlugin( // silently drops it because arrays don't have a directive def. const candidates = new Set(config.rootNames); const tsPaths = config.options?.paths; - const baseUrl = (config.options?.baseUrl ?? analogProjectRoot) as string; + const baseUrl = (config.options?.baseUrl ?? projectRoot) as string; if (tsPaths) { for (const targets of Object.values(tsPaths)) { for (const target of targets as string[]) { @@ -193,7 +193,7 @@ export function analogCompilerPlugin( } catch (e) { if (debugRegistry.enabled) { debugRegistry( - 'initAnalogCompiler: skipping unreadable %s: %s', + 'initFastCompile: skipping unreadable %s: %s', file, (e as Error)?.message, ); @@ -205,7 +205,7 @@ export function analogCompilerPlugin( for (const entries of results) { for (const entry of entries) { - analogRegistry.set(entry.className, entry); + registry.set(entry.className, entry); } } @@ -230,8 +230,8 @@ export function analogCompilerPlugin( ); } debugRegistry( - 'initAnalogCompiler done: %d entries from %d candidate files', - analogRegistry.size, + 'initFastCompile done: %d entries from %d candidate files', + registry.size, candidates.size, ); } @@ -242,10 +242,10 @@ export function analogCompilerPlugin( scannedDtsPackages.add(pkg); try { - const dtsEntries = scanPackageDts(pkg, analogProjectRoot); + const dtsEntries = scanPackageDts(pkg, projectRoot); for (const entry of dtsEntries) { - if (!analogRegistry.has(entry.className)) { - analogRegistry.set(entry.className, entry); + if (!registry.has(entry.className)) { + registry.set(entry.className, entry); } } } catch { @@ -254,7 +254,7 @@ export function analogCompilerPlugin( } } - async function handleAnalogCompilerTransform( + async function handleFastCompileTransform( code: string, id: string, ): Promise<{ code: string; map: any } | undefined> { @@ -319,16 +319,16 @@ export function analogCompilerPlugin( ensureDtsRegistryForSource(code, id); const result = compile(code, id, { - registry: analogRegistry, + registry, resolvedStyles, resolvedInlineStyles, useDefineForClassFields, - compilationMode: pluginOptions.analogCompilationMode, + compilationMode: pluginOptions.fastCompileMode, }); // Track resource dependencies for HMR for (const dep of result.resourceDependencies) { - analogResourceToSource.set(dep, id); + resourceToSource.set(dep, id); } // Strip TypeScript-only syntax @@ -346,7 +346,7 @@ export function analogCompilerPlugin( // Append HMR code in dev mode if (watchMode && pluginOptions.liveReload) { - const fileDeclarations = [...analogRegistry.values()].filter( + const fileDeclarations = [...registry.values()].filter( (e) => e.fileName === id, ); if (fileDeclarations.length > 0) { @@ -370,7 +370,7 @@ export function analogCompilerPlugin( } return { - name: '@analogjs/vite-plugin-angular-compiler', + name: '@analogjs/vite-plugin-angular-fast-compile', enforce: 'pre' as const, async config(config, { command }) { watchMode = command === 'serve'; @@ -425,12 +425,12 @@ export function analogCompilerPlugin( }); }, async buildStart() { - await initAnalogCompiler(); + await initFastCompile(); }, async handleHotUpdate(ctx) { // Resource file changes → invalidate parent .ts module - if (analogResourceToSource.has(ctx.file)) { - const parentSource = analogResourceToSource.get(ctx.file)!; + if (resourceToSource.has(ctx.file)) { + const parentSource = resourceToSource.get(ctx.file)!; const parentModule = ctx.server.moduleGraph.getModuleById(parentSource); if (parentModule) { return [parentModule]; @@ -441,11 +441,11 @@ export function analogCompilerPlugin( const [fileId] = ctx.file.split('?'); // Remove old entries from this file - const oldEntries = [...analogRegistry.entries()] + const oldEntries = [...registry.entries()] .filter(([_, v]) => v.fileName === fileId) .map(([k]) => k); for (const key of oldEntries) { - analogRegistry.delete(key); + registry.delete(key); } // Rescan the changed file via the barrel-aware scanner so an @@ -528,7 +528,7 @@ export function analogCompilerPlugin( if (id.includes('.ts?')) { id = id.replace(/\?(.*)/, ''); } - return handleAnalogCompilerTransform(code, id); + return handleFastCompileTransform(code, id); }, }, }; diff --git a/packages/vite-plugin-angular/src/lib/utils/virtual-resources.ts b/packages/vite-plugin-angular/src/lib/utils/virtual-resources.ts index 69a6191b9..f5fa35e96 100644 --- a/packages/vite-plugin-angular/src/lib/utils/virtual-resources.ts +++ b/packages/vite-plugin-angular/src/lib/utils/virtual-resources.ts @@ -1,6 +1,6 @@ // Shared Vite plugin helpers for routing component resources (templates, // external styles) through virtual module ids. Both angular-vite-plugin and -// analog-compiler-plugin use these so the rewriting + loading behavior stays +// fast-compile-plugin use these so the rewriting + loading behavior stays // in sync between them. import { promises as fsPromises } from 'node:fs'; diff --git a/packages/vite-plugin-nitro/package.json b/packages/vite-plugin-nitro/package.json index 08ab1db2d..1faa6fb2d 100644 --- a/packages/vite-plugin-nitro/package.json +++ b/packages/vite-plugin-nitro/package.json @@ -44,8 +44,7 @@ "@analogjs/storybook-angular", "@analogjs/vite-plugin-angular", "@analogjs/vite-plugin-nitro", - "@analogjs/vitest-angular", - "@analogjs/angular-compiler" + "@analogjs/vitest-angular" ], "migrations": "./migrations/migration.json" }, diff --git a/release.config.cjs b/release.config.cjs index 2a65edf88..9dddd4d65 100644 --- a/release.config.cjs +++ b/release.config.cjs @@ -40,13 +40,6 @@ module.exports = { npmPublish: false, }, ], - [ - '@semantic-release/npm', - { - npmPublish: false, - pkgRoot: './packages/angular-compiler/', - }, - ], [ '@semantic-release/npm', { @@ -144,11 +137,6 @@ module.exports = { from: '"@analogjs/router": ".*"', to: '"@analogjs/router": "^${nextRelease.version}"', }, - { - files: replacementFiles, - from: '"@analogjs/angular-compiler": ".*"', - to: '"@analogjs/angular-compiler": "^${nextRelease.version}"', - }, ], }, ], @@ -212,7 +200,6 @@ module.exports = { assets: [ 'CHANGELOG.md', 'package.json', - 'packages/angular-compiler/package.json', 'packages/astro-angular/package.json', 'packages/content/package.json', 'packages/create-analog/package.json', diff --git a/tools/publish.sh b/tools/publish.sh index af48912a7..e46257eff 100755 --- a/tools/publish.sh +++ b/tools/publish.sh @@ -1,6 +1,5 @@ #!/bin/bash echo "Publishing to $RELEASE_TAG" -npm publish node_modules/@analogjs/angular-compiler --tag $RELEASE_TAG npm publish node_modules/@analogjs/astro-angular --tag $RELEASE_TAG npm publish node_modules/@analogjs/content --tag $RELEASE_TAG npm publish node_modules/@analogjs/platform --tag $RELEASE_TAG diff --git a/tsconfig.base.json b/tsconfig.base.json index eb0256612..7a394469a 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -51,10 +51,6 @@ ], "@analogjs/top-bar": ["libs/top-bar/src/index.ts"], "@analogjs/trpc": ["packages/trpc/src/index.ts"], - "@analogjs/angular-compiler": [ - "./node_modules/@analogjs/angular-compiler", - "packages/angular-compiler/src/index.ts" - ], "@analogjs/vite-plugin-angular": [ "./node_modules/@analogjs/vite-plugin-angular", "packages/vite-plugin-angular/src/index.ts"