Skip to content

Commit 026fe44

Browse files
committed
fix(bundler): retain installed parser fallback
1 parent 6e2786d commit 026fe44

6 files changed

Lines changed: 10 additions & 26 deletions

File tree

docs/head/1.guides/build-plugins/0.overview.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ The Vue, React, Svelte, and Solid.js packages each ship a Vite plugin at `@unhea
1010

1111
Install your framework's Unhead package, then add the plugin to your Vite config:
1212

13-
Vite 8 reuses the parser included with Rolldown. If your build does not provide Rolldown, install the optional Oxc fallback:
14-
15-
```bash
16-
pnpm add -D oxc-parser
17-
```
18-
1913
::FrameworkCode
2014

2115
#vue

packages/bundler/README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ yarn add @unhead/bundler
2626
pnpm add @unhead/bundler
2727
```
2828

29-
Vite 8 reuses Rolldown's parser. Other build setups also need the optional Oxc fallback:
30-
31-
```bash
32-
pnpm add -D oxc-parser
33-
```
34-
3529
## Usage
3630

3731
### Vite Plugin

packages/bundler/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"@vitejs/devtools-kit": "^0.4.1",
8484
"esbuild": ">=0.17.0",
8585
"lightningcss": ">=1.20.0",
86-
"oxc-parser": ">=0.98.0",
8786
"rolldown": ">=1.0.0-beta.0",
8887
"unhead": "workspace:^",
8988
"vite": ">=6.4.2",
@@ -102,9 +101,6 @@
102101
"lightningcss": {
103102
"optional": true
104103
},
105-
"oxc-parser": {
106-
"optional": true
107-
},
108104
"rolldown": {
109105
"optional": true
110106
},
@@ -117,13 +113,13 @@
117113
},
118114
"dependencies": {
119115
"magic-string": "catalog:",
116+
"oxc-parser": "catalog:",
120117
"oxc-walker": "catalog:",
121118
"ufo": "catalog:",
122119
"unplugin": "catalog:"
123120
},
124121
"devDependencies": {
125122
"@vitejs/devtools-kit": "catalog:",
126-
"oxc-parser": "catalog:",
127123
"rollup": "catalog:",
128124
"unhead": "workspace:*",
129125
"vite": "catalog:"

packages/bundler/src/unplugin/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function getParser(): ParserResolutionSuccess {
8181
if (resolution._tag === 'missing') {
8282
throw Object.assign(
8383
new Error(
84-
'Unhead build transforms need a parser. Vite 8 provides Rolldown; otherwise install oxc-parser with `pnpm add -D oxc-parser`.',
84+
'Unhead could not load a parser for its build transforms. Reinstall @unhead/bundler to restore its oxc-parser dependency.',
8585
{ cause: new AggregateError(resolution.failures.map(failure => failure.cause), 'Parser resolution failed') },
8686
),
8787
{ _tag: 'MissingParserError' as const },

packages/bundler/test/package.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const packageJson = JSON.parse(
1515
) as PackageJson
1616

1717
describe('@unhead/bundler package', () => {
18-
it('keeps oxc-parser as an optional fallback', () => {
19-
expect(packageJson.dependencies).not.toHaveProperty('oxc-parser')
20-
expect(packageJson.peerDependencies).toHaveProperty('oxc-parser')
21-
expect(packageJson.peerDependenciesMeta?.['oxc-parser']).toEqual({ optional: true })
22-
expect(packageJson.devDependencies).toHaveProperty('oxc-parser')
18+
it('installs oxc-parser as the fallback parser', () => {
19+
expect(packageJson.dependencies).toHaveProperty('oxc-parser')
20+
expect(packageJson.peerDependencies).not.toHaveProperty('oxc-parser')
21+
expect(packageJson.peerDependenciesMeta).not.toHaveProperty('oxc-parser')
22+
expect(packageJson.devDependencies).not.toHaveProperty('oxc-parser')
2323
})
2424

2525
it('keeps Vite DevTools packages optional', () => {

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)