Skip to content

Commit 5e07262

Browse files
committed
feat: add @pivanov vite plugin to the repo
1 parent c8b2b1d commit 5e07262

File tree

7 files changed

+779
-21
lines changed

7 files changed

+779
-21
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2024 Aiden Bai, Million Software, Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# @react-scan/vite-plugin-react-scan
2+
3+
A Vite plugin that integrates React Scan into your Vite application, automatically detecting performance issues in your React components.
4+
5+
## Installation
6+
7+
```bash
8+
# npm
9+
npm install -D @react-scan/vite-plugin-react-scan react-scan
10+
11+
# pnpm
12+
pnpm add -D @react-scan/vite-plugin-react-scan react-scan
13+
14+
# yarn
15+
yarn add -D @react-scan/vite-plugin-react-scan react-scan
16+
```
17+
18+
## Usage
19+
20+
Add the plugin to your `vite.config.ts`:
21+
22+
```ts
23+
import { defineConfig } from 'vite';
24+
import react from '@vitejs/plugin-react';
25+
import reactScan from '@react-scan/vite-plugin-react-scan';
26+
27+
export default defineConfig({
28+
plugins: [
29+
react(),
30+
reactScan({
31+
// options (optional)
32+
}),
33+
],
34+
});
35+
```
36+
37+
## Options
38+
39+
| Option | Type | Default | Description |
40+
|--------|------|---------|-------------|
41+
| `enable` | `boolean` | `process.env.NODE_ENV === 'development'` | Enable/disable scanning |
42+
| `scanOptions` | `object` | `{ ... }` | Custom React Scan options |
43+
| `autoDisplayNames` | `boolean` | `true` | Automatically add display names to React components |
44+
| `debug` | `boolean` | `false` | Enable debug logging |
45+
46+
## Example Configuration
47+
48+
```ts
49+
import { defineConfig } from 'vite';
50+
import react from '@vitejs/plugin-react';
51+
import reactScan from '@react-scan/vite-plugin-react-scan';
52+
53+
export default defineConfig({
54+
plugins: [
55+
react(),
56+
reactScan({
57+
enable: true,
58+
autoDisplayNames: true,
59+
scanOptions: {} // React Scan specific options
60+
}),
61+
],
62+
});
63+
```
64+
65+
## Development vs Production
66+
67+
- In development: The plugin injects React Scan directly into your application for real-time analysis
68+
- In production: The plugin can be disabled/enabled by default with specific options
69+
70+
## Contributing
71+
72+
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
73+
74+
## License
75+
76+
React Scan Vite Plugin is [MIT-licensed](LICENSE) open-source software by Aiden Bai, [Million Software, Inc.](https://million.dev), and [contributors](https://github.com/aidenybai/react-scan/graphs/contributors):
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "@react-scan/vite-plugin-react-scan",
3+
"version": "0.1.0",
4+
"description": "A Vite plugin for React Scan - detects performance issues in your React app.",
5+
"type": "module",
6+
"main": "dist/index.js",
7+
"module": "dist/index.js",
8+
"types": "dist/index.d.ts",
9+
"scripts": {
10+
"build": "rm -rf dist && tsc",
11+
"postbuild": "node ../../scripts/version-warning.mjs",
12+
"lint": "biome lint .",
13+
"format": "biome format . --write",
14+
"check": "biome check . --write",
15+
"prepublishOnly": "rm -rf dist && npm run build"
16+
},
17+
"peerDependenciesMeta": {
18+
"react-scan": {
19+
"optional": false
20+
},
21+
"vite": {
22+
"optional": false
23+
}
24+
},
25+
"keywords": [
26+
"react",
27+
"react-scan",
28+
"react scan",
29+
"render",
30+
"performance",
31+
"vite",
32+
"vite plugin"
33+
],
34+
"author": {
35+
"name": "Team React Scan",
36+
"url": "https://github.com/aidenybai/react-scan"
37+
},
38+
"maintainers": [
39+
{
40+
"name": "Pavel Ivanov",
41+
"email": "pafelka@gmail.com",
42+
"url": "https://github.com/pivanov"
43+
}
44+
],
45+
"license": "MIT",
46+
"homepage": "https://github.com/aidenybai/react-scan",
47+
"bugs": {
48+
"url": "https://github.com/aidenybai/react-scan/issues"
49+
},
50+
"repository": {
51+
"type": "git",
52+
"url": "https://github.com/aidenybai/react-scan.git"
53+
},
54+
"peerDependencies": {
55+
"react-scan": "^0.1.0",
56+
"vite": "^2 || ^3 || ^4 || ^5 || ^6"
57+
},
58+
"devDependencies": {
59+
"@babel/core": "^7.26.0",
60+
"@babel/plugin-transform-react-jsx": "^7.25.9",
61+
"@biomejs/biome": "^1.9.4",
62+
"@types/babel__core": "^7.20.5",
63+
"@types/cheerio": "^0.22.35",
64+
"@types/node": "^22.10.7",
65+
"babel-plugin-add-react-displayname": "^0.0.5",
66+
"cheerio": "^1.0.0",
67+
"typescript": "latest",
68+
"vite": "^6.0.7"
69+
},
70+
"publishConfig": {
71+
"access": "public"
72+
}
73+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'babel-plugin-add-react-displayname/index.js';

0 commit comments

Comments
 (0)