vite-plugin-rebundle 1.2.8 → 1.2.11
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/dist/index.d.ts +5 -2
- package/dist/index.js +3 -1
- package/dist/rebundle.d.ts +1 -3
- package/dist/rebundle.js +20 -20
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
1
|
+
import { type Options } from './rebundle.js';
|
|
2
|
+
import type { BuildOptions } from 'esbuild';
|
|
3
|
+
export type { BuildOptions };
|
|
4
|
+
export default function rebundle(options?: Options): import("vite").Plugin<any>;
|
|
5
|
+
export { rebundle };
|
package/dist/index.js
CHANGED
package/dist/rebundle.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export declare const _sourcemap_: unique symbol;
|
|
|
7
7
|
export type Options = {
|
|
8
8
|
[chunkName: string]: BuildOptions;
|
|
9
9
|
};
|
|
10
|
-
export type OptionsInput = Options | (() => Options | Promise<Options>);
|
|
11
10
|
export declare class Rebundle extends $utils.Unit {
|
|
12
11
|
private options;
|
|
13
12
|
private config;
|
|
@@ -16,7 +15,7 @@ export declare class Rebundle extends $utils.Unit {
|
|
|
16
15
|
private hasError;
|
|
17
16
|
private port;
|
|
18
17
|
private ws;
|
|
19
|
-
constructor(options:
|
|
18
|
+
constructor(options: Options);
|
|
20
19
|
get vite(): Plugin;
|
|
21
20
|
private onConfig;
|
|
22
21
|
private onConfigResolved;
|
|
@@ -31,6 +30,5 @@ export declare class Rebundle extends $utils.Unit {
|
|
|
31
30
|
private write;
|
|
32
31
|
private remove;
|
|
33
32
|
private ensureWs;
|
|
34
|
-
private getOptions;
|
|
35
33
|
private removeDirectoryIfEmpty;
|
|
36
34
|
}
|
package/dist/rebundle.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as $utils from '@eposlabs/utils';
|
|
2
|
+
import $chalk from 'chalk';
|
|
2
3
|
import * as $esbuild from 'esbuild';
|
|
4
|
+
import { filesize } from 'filesize';
|
|
3
5
|
import * as $fs from 'node:fs/promises';
|
|
4
6
|
import * as $path from 'node:path';
|
|
5
|
-
import * as $utils from '@eposlabs/utils';
|
|
6
|
-
import * as $ws from 'ws';
|
|
7
|
-
import $chalk from 'chalk';
|
|
8
7
|
import $portfinder from 'portfinder';
|
|
8
|
+
import * as $ws from 'ws';
|
|
9
9
|
export const _code_ = Symbol('rebundle:code');
|
|
10
10
|
export const _sourcemap_ = Symbol('rebundle:sourcemap');
|
|
11
11
|
export class Rebundle extends $utils.Unit {
|
|
@@ -91,9 +91,8 @@ export class Rebundle extends $utils.Unit {
|
|
|
91
91
|
// Delete chunk from bundle to hide log for vite-rolldown.
|
|
92
92
|
// Call for rollup as well for consistency.
|
|
93
93
|
delete bundle[chunk.fileName];
|
|
94
|
-
const options = await this.getOptions();
|
|
95
94
|
const chunkPath = this.resolve(chunk.fileName);
|
|
96
|
-
const chunkBuildOptions = options[chunk.name] ?? {};
|
|
95
|
+
const chunkBuildOptions = this.options[chunk.name] ?? {};
|
|
97
96
|
const chunkFiles = await this.readChunkFiles(chunk);
|
|
98
97
|
const chunkFilePaths = Object.keys(chunkFiles);
|
|
99
98
|
const chunkChanged = chunkFilePaths.some(path => chunkFiles[path] !== this.chunkFiles[path]);
|
|
@@ -113,14 +112,20 @@ export class Rebundle extends $utils.Unit {
|
|
|
113
112
|
return false;
|
|
114
113
|
}
|
|
115
114
|
// Build with esbuild
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
let result;
|
|
116
|
+
try {
|
|
117
|
+
result = await $esbuild.build({
|
|
118
|
+
sourcemap: Boolean(this.config.build.sourcemap),
|
|
119
|
+
...chunkBuildOptions,
|
|
120
|
+
outfile: chunkPath,
|
|
121
|
+
entryPoints: [chunkPath],
|
|
122
|
+
bundle: true,
|
|
123
|
+
allowOverwrite: true,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
124
129
|
// Errors? -> Ignore, esbuild will show errors in console
|
|
125
130
|
if (result.errors.length > 0)
|
|
126
131
|
return;
|
|
@@ -161,7 +166,7 @@ export class Rebundle extends $utils.Unit {
|
|
|
161
166
|
await Promise.all(usedPaths.map(async (path) => {
|
|
162
167
|
const content = await this.read(path);
|
|
163
168
|
if (!content)
|
|
164
|
-
|
|
169
|
+
return;
|
|
165
170
|
files[path] = content;
|
|
166
171
|
}));
|
|
167
172
|
return files;
|
|
@@ -195,11 +200,6 @@ export class Rebundle extends $utils.Unit {
|
|
|
195
200
|
this.ws = new $ws.WebSocketServer({ port: this.port });
|
|
196
201
|
return this.ws;
|
|
197
202
|
}
|
|
198
|
-
async getOptions() {
|
|
199
|
-
if (typeof this.options !== 'function')
|
|
200
|
-
return this.options;
|
|
201
|
-
return await this.options();
|
|
202
|
-
}
|
|
203
203
|
async removeDirectoryIfEmpty(dir) {
|
|
204
204
|
const files = await $fs.readdir(dir);
|
|
205
205
|
if (files.length > 0)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-rebundle",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "imkost",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@eposlabs/utils": "^1.0.
|
|
25
|
+
"@eposlabs/utils": "^1.0.13",
|
|
26
26
|
"@types/ws": "^8.18.1",
|
|
27
|
-
"chalk": "^5.6.
|
|
27
|
+
"chalk": "^5.6.2",
|
|
28
28
|
"esbuild": "^0.25.9",
|
|
29
29
|
"filesize": "^11.0.2",
|
|
30
|
-
"portfinder": "^1.0.
|
|
31
|
-
"rollup": "^4.50.
|
|
32
|
-
"vite": "^7.1.
|
|
30
|
+
"portfinder": "^1.0.38",
|
|
31
|
+
"rollup": "^4.50.1",
|
|
32
|
+
"vite": "^7.1.5",
|
|
33
33
|
"ws": "^8.18.3"
|
|
34
34
|
}
|
|
35
35
|
}
|