Vitest: keep `@defer` dependencies as static imports, so class metadata stays synchronous
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 54/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- angular, typescript, vite
- Domain
- build-system, testing
Research direction
Start in ngp/preprocessor/src/processor.js and trace how canDeferDeps and deferredOnlyNames are set, then read the related JIT compatibility work in #27 for the intended test mode or shared option. Done means Vitest test mode keeps @defer dependencies eagerly loaded without relying on process.env.VITEST, and the relevant tests cover synchronous class metadata for TestBed and MockComponent().
Written by the indexing model from the issue text.
Description
Part of #27.
Problem
A deferrable dependency becomes a dynamic import, so the component's class metadata is set asynchronously (ɵsetClassMetadataAsync). TestBed only resolves it in compileComponents(), and ng-mocks reads metadata synchronously. Specs that never call compileComponents(), and every MockComponent() of such a component, fail.
Proposed change
Under Vitest, canDeferDeps is false and nothing is added to deferredOnlyNames (ngp/preprocessor/src/processor.js). This matches JIT, where @defer dependencies are also loaded eagerly in tests.
Our patch gates this on process.env.VITEST, which is the wrong switch for a library. In ngp it belongs in its test mode, or behind one option shared by the JIT-compatibility changes in #27 (for example test: { jitCompat: true }).
Setup: ngp 0.3.0, @angular/compiler/compiler-cli 22.3.0-next.4, Vite 8, Vitest 5.1.0 (pool: 'forks'), a Nx monorepo with 1,035 Angular projects, one Vitest config each, specs written for TestBed under JIT (Analog).
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 1
- Avg merge
- 12h 24m
- Merged PRs (30d)
- 13
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from push-based/vite-plugin-ngp
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
push-based/vite-plugin-ngp#33 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
push-based/vite-plugin-ngp#42 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 4/5 3-5 days Newbie friendliness 52/100
push-based/vite-plugin-ngp#41 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 4/5 3-5 days Newbie friendliness 50/100
push-based/vite-plugin-ngp#40 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 3/5 1-2 days Newbie friendliness 55/100
push-based/vite-plugin-ngp#39 ·
Maintainers usually reply within 1 day
All issues in push-based/vite-plugin-ngp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
vercel-labs/ui#540 ·
Maintainers usually reply within 1 day
-
accepted ai-dev ai-implementing
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
livesport/homer#218 · 1 comment ·
Maintainers usually reply within 1 day
-
normalizePropName strips `#` characters from Figma property names instead of only the `#id` suffixOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
figma/code-connect#419 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Negative values skip k/M abbreviation and medium decimal format on line, stacked-area, and tooltipOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
britecharts/britecharts#1255 ·
Maintainers usually reply within 1 day