Commit a5ac2cc
Resolve <package>/package.json self-import in shared vitest aliases (#39280)
### Packages impacted by this PR
All packages that consume the repository-root `vitest.shared.config.ts`,
including Node and browser test targets.
### Issues associated with this PR
N/A
### Describe the problem that is addressed by this PR
Clients generated by `@azure-tools/typespec-ts` now import their own
`<packageName>/package.json` self-export to read the user-agent version
at runtime. Under Vitest, the existing bare package-name alias also
matches that subpath, redirects it toward the source or dist entry
point, and prevents normal package JSON resolution.
### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?
Prepend a specific `<packageName>/package.json` alias that resolves to
the package-root `package.json`. This preserves the existing
package-name and `$internal` alias behavior while relying on
first-match-wins ordering to prevent the broader package alias from
shadowing the JSON subpath. Both Node and browser configurations inherit
the fix through `makeAliases`.
### Are there test cases added in this PR? _(If not, why?)_
No committed fixture was added because the repository-root shared config
has no existing unit-test harness. The failure and fix were verified
with a minimal Vitest package in both source (`./src/index.ts`) and
built (`./dist/esm/index.js`) alias modes. The existing
`@azure/core-util` Node Vitest suite also passed all 37 tests.
### Provide a list of related PRs _(if any)_
- Azure/typespec-azure#4859
### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_
N/A
### Checklists
- [x] Added impacted package name to the issue description (N/A: no
associated issue; impact is repository-wide)
- [x] Does this PR need any fixes in the SDK Generator? No; the related
upstream emitter change is Azure/typespec-azure#4859.
- [x] Added a changelog (not necessary for shared test infrastructure)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>1 parent 7d63571 commit a5ac2cc
1 file changed
Lines changed: 9 additions & 0 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
55 | 64 | | |
56 | 65 | | |
57 | 66 | | |
| |||
0 commit comments