vite-plugin-rebundle 1.6.0 → 1.8.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/package.json +6 -4
- package/readme.md +0 -82
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-rebundle",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "imkost",
|
|
@@ -10,14 +10,16 @@
|
|
|
10
10
|
"vite-plugin"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
|
-
"
|
|
13
|
+
"dev": "tsup --config ../tsup.config.ts --watch",
|
|
14
|
+
"build": "tsup --config ../tsup.config.ts",
|
|
14
15
|
"lint": "tsc --noEmit",
|
|
15
16
|
"release": "sh -c 'npm version ${1:-minor} && npm run build && npm publish' --"
|
|
16
17
|
},
|
|
17
18
|
"exports": {
|
|
18
19
|
".": {
|
|
19
20
|
"source": "./src/rebundle.ts",
|
|
20
|
-
"import": "./dist/rebundle.js"
|
|
21
|
+
"import": "./dist/rebundle.js",
|
|
22
|
+
"types": "./dist/rebundle.d.ts"
|
|
21
23
|
}
|
|
22
24
|
},
|
|
23
25
|
"files": [
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
"dist"
|
|
26
28
|
],
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@eposlabs/utils": "^1.
|
|
30
|
+
"@eposlabs/utils": "^1.8.0",
|
|
29
31
|
"@types/ws": "^8.18.1",
|
|
30
32
|
"chalk": "^5.6.2",
|
|
31
33
|
"filesize": "^11.0.13",
|
package/readme.md
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# vite-plugin-rebundle
|
|
2
|
-
|
|
3
|
-
A Vite plugin that guarantees **one standalone file per entry point**. Each entry is bundled into a single file with no code-splitting or dynamic imports.
|
|
4
|
-
|
|
5
|
-
## Why?
|
|
6
|
-
|
|
7
|
-
Sometimes you need bundles without dynamic imports. Vite/Rollup don’t provide this option when building with multiple entries. `vite-plugin-rebundle` solves this issue by rebundling Vite’s output with rolldown to enforce single-file output. This plugin runs only during `vite build`, and it does not affect the Vite dev server.
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install -D vite-plugin-rebundle
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```javascript
|
|
18
|
-
import { defineConfig } from 'vite'
|
|
19
|
-
import { rebundle } from 'vite-plugin-rebundle'
|
|
20
|
-
|
|
21
|
-
export default defineConfig({
|
|
22
|
-
plugins: [rebundle()],
|
|
23
|
-
build: {
|
|
24
|
-
rollupOptions: {
|
|
25
|
-
input: {
|
|
26
|
-
app: 'src/app.js',
|
|
27
|
-
libs: 'src/libs.js',
|
|
28
|
-
},
|
|
29
|
-
output: {
|
|
30
|
-
entryFileNames: '[name].js',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
})
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Options
|
|
38
|
-
|
|
39
|
-
You can provide rolldown options per entry point. This is useful, for example, to inject custom define variables into specific bundles:
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
export default defineConfig({
|
|
43
|
-
plugins: [
|
|
44
|
-
rebundle({
|
|
45
|
-
app: {
|
|
46
|
-
output: {
|
|
47
|
-
define: { BUNDLE_NAME: JSON.stringify('app') },
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
libs: {
|
|
51
|
-
input: {
|
|
52
|
-
keepNames: true,
|
|
53
|
-
},
|
|
54
|
-
output: {
|
|
55
|
-
define: { BUNDLE_NAME: JSON.stringify('libs') },
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
}),
|
|
59
|
-
],
|
|
60
|
-
build: {
|
|
61
|
-
rollupOptions: {
|
|
62
|
-
input: {
|
|
63
|
-
app: 'src/app.js',
|
|
64
|
-
libs: 'src/libs.js',
|
|
65
|
-
},
|
|
66
|
-
output: {
|
|
67
|
-
entryFileNames: '[name].js',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## How it works
|
|
75
|
-
|
|
76
|
-
When you run `vite build`, Rollup normally outputs multiple chunks per entry if code-splitting is needed.
|
|
77
|
-
`vite-plugin-rebundle` hooks into the build and **rebundles each entry’s output with rolldown**, forcing a single self-contained file per entry.
|
|
78
|
-
|
|
79
|
-
- Vite still handles the initial build (tree-shaking, asset pipeline, etc.).
|
|
80
|
-
- Afterward, each entry is passed through rolldown.
|
|
81
|
-
- The final result is one .js file per entry with no dynamic imports or shared chunks.
|
|
82
|
-
- Sourcemaps are ignored, as they would be inaccurate after rebundling.
|