vite-plugin-rebundle 2.0.3 → 2.0.5
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/package.json +2 -3
- package/readme.md +17 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-rebundle",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "imkost",
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
".": "./dist/rebundle.js"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
-
"dist"
|
|
28
|
-
"readme.md"
|
|
27
|
+
"dist"
|
|
29
28
|
],
|
|
30
29
|
"dependencies": {
|
|
31
30
|
"@eposlabs/utils": "^1.26.0",
|
package/readme.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# vite-plugin-rebundle
|
|
2
2
|
|
|
3
|
-
A Vite plugin that guarantees **one standalone file per entry point**.
|
|
3
|
+
A Vite plugin that guarantees **one standalone file per entry point**. It rebundles each entry into a single file with no shared chunks or dynamic imports. Requires **Vite 8+**.
|
|
4
4
|
|
|
5
5
|
## Why?
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Vite does not provide single-file output for multi-entry builds. When code splitting is needed, each entry can produce extra chunks and dynamic imports.
|
|
8
|
+
|
|
9
|
+
`vite-plugin-rebundle` solves that by taking Vite's build output and rebundling each entry with [`rolldown`](https://rolldown.rs/). It runs only during `vite build` and does not affect the dev server.
|
|
8
10
|
|
|
9
11
|
## Installation
|
|
10
12
|
|
|
@@ -14,6 +16,8 @@ npm install -D vite-plugin-rebundle
|
|
|
14
16
|
|
|
15
17
|
## Usage
|
|
16
18
|
|
|
19
|
+
Add the plugin to your Vite config:
|
|
20
|
+
|
|
17
21
|
```javascript
|
|
18
22
|
import { defineConfig } from 'vite'
|
|
19
23
|
import { rebundle } from 'vite-plugin-rebundle'
|
|
@@ -36,7 +40,10 @@ export default defineConfig({
|
|
|
36
40
|
|
|
37
41
|
## Configuration
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
`rebundle()` accepts up to two arguments:
|
|
44
|
+
|
|
45
|
+
- The first argument contains global `rolldown` input and output options applied to every entry.
|
|
46
|
+
- The second argument contains per-entry options that are deep-merged with the global ones.
|
|
40
47
|
|
|
41
48
|
```javascript
|
|
42
49
|
export default defineConfig({
|
|
@@ -76,16 +83,15 @@ export default defineConfig({
|
|
|
76
83
|
|
|
77
84
|
## How it works
|
|
78
85
|
|
|
79
|
-
When you run `vite build`,
|
|
80
|
-
`vite-plugin-rebundle` hooks into the build process and **rebundles each entry’s output with rolldown**, forcing a single self-contained file per entry.
|
|
86
|
+
When you run `vite build`, `vite-plugin-rebundle`:
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
1. Lets Vite perform the normal build.
|
|
89
|
+
2. Rebundles each entry with rolldown.
|
|
90
|
+
3. Writes back a single self-contained JavaScript file per entry.
|
|
85
91
|
|
|
86
|
-
##
|
|
92
|
+
## Watch Mode
|
|
87
93
|
|
|
88
|
-
|
|
94
|
+
When running in build watch mode, the plugin exposes `import.meta.env.REBUNDLE_PORT`. You can use it to listen for rebundle events over WebSocket:
|
|
89
95
|
|
|
90
96
|
```javascript
|
|
91
97
|
const ws = new WebSocket(`ws://localhost:${import.meta.env.REBUNDLE_PORT}`)
|
|
@@ -94,4 +100,4 @@ ws.addEventListener('message', e => console.log('Rebundle event:', e.data))
|
|
|
94
100
|
|
|
95
101
|
## Notes
|
|
96
102
|
|
|
97
|
-
Source maps are not currently supported. If you pass `sourcemap` option, it will be ignored.
|
|
103
|
+
Source maps are not currently supported. If you pass `sourcemap` option, it will be ignored.
|