Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slow-lamps-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@prefresh/vite': major
---

Add true vite 8 support with native rolldown rather than babel
10 changes: 8 additions & 2 deletions packages/vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,25 @@ export default {
};
```

`@prefresh/vite` configures Vite's Oxc JSX transform for Preact and composes
`@prefresh/rolldown` internally. Babel is only used as a selective fallback when
you pass `parserPlugins`.

## Options

The plugin accepts two options `include` & `exclude` which are used in the [`@rollup/pluginutils.createFilter`](https://github.com/rollup/plugins/tree/master/packages/pluginutils#createfilter) to filter out files or include them.

The plugin also accepts the addition of [`parserPlugins`](https://babeljs.io/docs/en/babel-parser#plugins)
The plugin also accepts the addition of [`parserPlugins`](https://babeljs.io/docs/en/babel-parser#plugins).
Providing `parserPlugins` opts that file transform back into the Babel-based path,
similar to how `@preact/preset-vite` only enables Babel when that path is requested.

## Best practices

### Recognition

We need to be able to recognise your components, this means that components should
start with a capital letter and hook should start with `use` followed by a capital letter.
This allows the Babel plugin to effectively recognise these.
This allows the refresh transform to effectively recognise these.

Do note that a component as seen below is not named.

Expand Down
4 changes: 2 additions & 2 deletions packages/vite/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FilterPattern } from '@rollup/pluginutils';
import { Plugin } from 'vite';
import { PluginOption } from 'vite';

interface Options {
parserPlugins?: readonly string[];
include?: FilterPattern;
exclude?: FilterPattern;
}

declare const prefreshPlugin: (options?: Options) => Plugin;
declare const prefreshPlugin: (options?: Options) => Promise<PluginOption>;

export = prefreshPlugin;
8 changes: 5 additions & 3 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
"homepage": "https://github.com/preactjs/prefresh#readme",
"dependencies": {
"@babel/core": "^7.22.1",
"@prefresh/babel-plugin": "^0.5.2",
"@prefresh/core": "^1.5.0",
"@prefresh/babel-plugin": "^0.5.2",
"@prefresh/rolldown": "workspace:*",
"@prefresh/utils": "^1.2.0",
"@rollup/pluginutils": "^4.2.1"
"@rollup/pluginutils": "^4.2.1",
"rolldown": "^1.0.0-rc.12"
},
"devDependencies": {
"preact": "^10.26.10",
"vite": "^5.4.21"
"vite": "^8.0.0"
},
"peerDependencies": {
"preact": "^10.4.0 || ^11.0.0-0",
Expand Down
Loading
Loading