@visulima/vite-overlay 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE.md +27 -0
- package/README.md +235 -0
- package/dist/index.js +1014 -0
- package/package.json +67 -0
package/CHANGELOG.md
ADDED
package/LICENSE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 visulima
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
<!-- DEPENDENCIES -->
|
|
24
|
+
<!-- /DEPENDENCIES -->
|
|
25
|
+
|
|
26
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
27
|
+
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h3>Enhanced Error Overlay for Vite</h3>
|
|
3
|
+
<p>
|
|
4
|
+
A powerful development tool that provides rich error displays with source mapping, cause chain navigation, and intelligent solutions for Vite applications.
|
|
5
|
+
</p>
|
|
6
|
+
</div>
|
|
7
|
+
|
|
8
|
+
<br />
|
|
9
|
+
|
|
10
|
+
<div align="center">
|
|
11
|
+
|
|
12
|
+
[![typescript-image]][typescript-url] [![npm-image]][npm-url] [![license-image]][license-url]
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
<p>
|
|
20
|
+
<sup>
|
|
21
|
+
Daniel Bannert's open source work is supported by the community on <a href="https://github.com/sponsors/prisis">GitHub Sponsors</a>
|
|
22
|
+
</sup>
|
|
23
|
+
</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
| Light Mode | Dark Mode | Solution Mode |
|
|
29
|
+
| -------------------------------- | ------------------------------ | --------------------------------
|
|
30
|
+
|  |  |  |
|
|
31
|
+
|
|
32
|
+
## Features
|
|
33
|
+
|
|
34
|
+
- **Enhanced Error Display** - Rich, interactive error overlays with syntax highlighting
|
|
35
|
+
- **Source Map Integration** - Shows original `.tsx`/`.ts` files instead of compiled paths
|
|
36
|
+
- **Cause Chain Navigation** - Navigate through multi-level error chains with original source locations
|
|
37
|
+
- **Cross-browser Support** - Works seamlessly in Chromium, Firefox, and WebKit
|
|
38
|
+
- **Beautiful UI** - Modern, accessible interface with light/dark theme support
|
|
39
|
+
- **Intelligent Solutions** - AI-powered error analysis and suggested fixes
|
|
40
|
+
- **Real-time Updates** - Hot Module Replacement (HMR) integration for instant error feedback
|
|
41
|
+
- **Comprehensive Testing** - Extensive e2e test coverage for reliability
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
npm install @visulima/vite-overlay
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
yarn add @visulima/vite-overlay
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
pnpm add @visulima/vite-overlay
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
Add the plugin to your Vite configuration:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { defineConfig } from "vite";
|
|
63
|
+
import { errorOverlay } from "@visulima/vite-overlay";
|
|
64
|
+
|
|
65
|
+
export default defineConfig({
|
|
66
|
+
plugins: [errorOverlay()],
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Configuration Options
|
|
71
|
+
|
|
72
|
+
The plugin accepts an optional configuration object:
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { defineConfig } from "vite";
|
|
76
|
+
import { errorOverlay } from "@visulima/vite-overlay";
|
|
77
|
+
|
|
78
|
+
export default defineConfig({
|
|
79
|
+
plugins: [
|
|
80
|
+
errorOverlay({
|
|
81
|
+
// Whether to log/display client-side runtime errors (default: true)
|
|
82
|
+
logClientRuntimeError: true,
|
|
83
|
+
|
|
84
|
+
// Custom React plugin name for detection (optional)
|
|
85
|
+
reactPluginName: "@vitejs/plugin-react",
|
|
86
|
+
|
|
87
|
+
// Custom solution finder functions (optional)
|
|
88
|
+
solutionFinders: [],
|
|
89
|
+
}),
|
|
90
|
+
],
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### Options
|
|
95
|
+
|
|
96
|
+
| Option | Type | Default | Description |
|
|
97
|
+
|--------|------|---------|-------------|
|
|
98
|
+
| `logClientRuntimeError` | `boolean` | `true` | Enable/disable client-side runtime error logging and overlay display |
|
|
99
|
+
| `reactPluginName` | `string` | `undefined` | Custom React plugin name for detection (useful for custom React plugins) |
|
|
100
|
+
| `solutionFinders` | `SolutionFinder[]` | `[]` | Array of custom solution finder functions for enhanced error analysis |
|
|
101
|
+
|
|
102
|
+
## Error Handling
|
|
103
|
+
|
|
104
|
+
The plugin automatically handles various types of errors:
|
|
105
|
+
|
|
106
|
+
### Client-Side Errors
|
|
107
|
+
- Runtime JavaScript errors
|
|
108
|
+
- Unhandled promise rejections
|
|
109
|
+
- React component errors (when React plugin is detected)
|
|
110
|
+
- Async context errors
|
|
111
|
+
|
|
112
|
+
### Server-Side Errors (SSR)
|
|
113
|
+
- Build-time errors during SSR
|
|
114
|
+
- Import resolution failures
|
|
115
|
+
- Module loading errors
|
|
116
|
+
- Plugin-specific errors
|
|
117
|
+
|
|
118
|
+
### Special Cases
|
|
119
|
+
- **Vue SFC Compilation Errors** - Enhanced parsing for `.vue` files
|
|
120
|
+
- **Import Resolution Errors** - Smart suggestions for missing modules
|
|
121
|
+
- **TypeScript Errors** - Source map integration for `.tsx`/`.ts` files
|
|
122
|
+
- **Framework-Specific Issues** - Detection and handling for React, Vue, Svelte, and Astro
|
|
123
|
+
|
|
124
|
+
## User Interface
|
|
125
|
+
|
|
126
|
+
### Keyboard Shortcuts
|
|
127
|
+
|
|
128
|
+
- `ESC` - Close error overlay (client-side errors only)
|
|
129
|
+
- `←` / `→` - Navigate between multiple errors
|
|
130
|
+
- `Tab` - Switch between original/compiled code views
|
|
131
|
+
|
|
132
|
+
## Advanced Configuration
|
|
133
|
+
|
|
134
|
+
### Custom Solution Finders
|
|
135
|
+
|
|
136
|
+
You can extend the plugin with custom solution finders:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { defineConfig } from "vite";
|
|
140
|
+
import { errorOverlay } from "@visulima/vite-overlay";
|
|
141
|
+
import type { SolutionFinder } from "@visulima/error/solution";
|
|
142
|
+
|
|
143
|
+
const customSolutionFinder: SolutionFinder = {
|
|
144
|
+
name: "custom-finder",
|
|
145
|
+
priority: 10,
|
|
146
|
+
async handle(error, context) {
|
|
147
|
+
// Your custom error analysis logic
|
|
148
|
+
if (error.message.includes("custom error pattern")) {
|
|
149
|
+
return {
|
|
150
|
+
header: "Custom Error Detected",
|
|
151
|
+
body: "This is a custom error solution...",
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export default defineConfig({
|
|
159
|
+
plugins: [
|
|
160
|
+
errorOverlay({
|
|
161
|
+
solutionFinders: [customSolutionFinder],
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### React Plugin Detection
|
|
168
|
+
|
|
169
|
+
The plugin automatically detects React plugins, but you can specify a custom plugin name:
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
export default defineConfig({
|
|
173
|
+
plugins: [
|
|
174
|
+
errorOverlay({
|
|
175
|
+
reactPluginName: "my-custom-react-plugin",
|
|
176
|
+
}),
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Theming
|
|
182
|
+
|
|
183
|
+
The error overlay uses a custom design system with CSS custom properties:
|
|
184
|
+
|
|
185
|
+
```css
|
|
186
|
+
/* Light theme (default) */
|
|
187
|
+
--ono-v-bg: #f5f5f5;
|
|
188
|
+
--ono-v-surface: #ffffff;
|
|
189
|
+
--ono-v-text: #111827;
|
|
190
|
+
--ono-v-red-orange: #ff4628;
|
|
191
|
+
|
|
192
|
+
/* Dark theme */
|
|
193
|
+
--ono-v-bg: #161b22;
|
|
194
|
+
--ono-v-surface: #0d1117;
|
|
195
|
+
--ono-v-text: #c9d1d9;
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
## Supported Node.js Versions
|
|
200
|
+
|
|
201
|
+
Libraries in this ecosystem make the best effort to track [Node.js’ release schedule](https://github.com/nodejs/release#release-schedule).
|
|
202
|
+
Here’s [a post on why we think this is important](https://medium.com/the-node-js-collection/maintainers-should-consider-following-node-js-release-schedule-ab08ed4de71a).
|
|
203
|
+
|
|
204
|
+
## Contributing
|
|
205
|
+
|
|
206
|
+
If you would like to help take a look at the [list of issues](https://github.com/visulima/visulima/issues) and check our [Contributing](.github/CONTRIBUTING.md) guidelines.
|
|
207
|
+
|
|
208
|
+
> **Note:** please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
|
|
209
|
+
|
|
210
|
+
### Development Setup
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Clone the repository
|
|
214
|
+
git clone https://github.com/visulima/visulima.git
|
|
215
|
+
cd visulima
|
|
216
|
+
|
|
217
|
+
# Install dependencies
|
|
218
|
+
pnpm install
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Credits
|
|
222
|
+
|
|
223
|
+
- [Daniel Bannert](https://github.com/prisis)
|
|
224
|
+
- [All Contributors](https://github.com/visulima/visulima/graphs/contributors)
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
This project is licensed under the MIT License - see the [MIT][license-url] file for details.
|
|
229
|
+
|
|
230
|
+
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
|
|
231
|
+
[typescript-url]: https://www.typescriptlang.org/ "TypeScript"
|
|
232
|
+
[license-image]: https://img.shields.io/npm/l/@visulima/vite-overlay?color=blueviolet&style=for-the-badge
|
|
233
|
+
[license-url]: LICENSE.md "license"
|
|
234
|
+
[npm-image]: https://img.shields.io/npm/v/@visulima/vite-overlay/latest.svg?style=for-the-badge&logo=npm
|
|
235
|
+
[npm-url]: https://www.npmjs.com/package/@visulima/vite-overlay/v/latest "npm"
|