vite-plugin-rebundle 1.3.2 → 1.3.3
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/rebundle.js +5 -7
- package/package.json +2 -2
- package/src/rebundle.ts +10 -8
package/dist/rebundle.js
CHANGED
|
@@ -87,6 +87,7 @@ var Rebundle = class extends Unit {
|
|
|
87
87
|
const chunkFiles = await this.readChunkFiles(chunk);
|
|
88
88
|
const chunkFilePaths = Object.keys(chunkFiles);
|
|
89
89
|
const chunkModified = chunkFilePaths.some((path) => chunkFiles[path] !== this.originalFiles[path]);
|
|
90
|
+
Object.assign(this.originalFiles, chunkFiles);
|
|
90
91
|
if (!chunkModified) {
|
|
91
92
|
const code2 = this.rebundledFiles[chunk.fileName];
|
|
92
93
|
await this.writeToDist(chunk.fileName, code2);
|
|
@@ -96,13 +97,10 @@ var Rebundle = class extends Unit {
|
|
|
96
97
|
}
|
|
97
98
|
return false;
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
console.error(error);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
100
|
+
const [build] = await safe(rolldown({ ...chunkOptions.input, input: chunkPath }));
|
|
101
|
+
if (!build) return;
|
|
102
|
+
const [_, error] = await safe(build.write({ ...chunkOptions.output, file: chunkPath }));
|
|
103
|
+
if (error) return;
|
|
106
104
|
const { size } = await stat(chunkPath);
|
|
107
105
|
const _dist_ = chalk.dim(`${this.dist}/`);
|
|
108
106
|
const _fileName_ = chalk.cyan(chunk.fileName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-rebundle",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "imkost",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"filesize": "^11.0.13",
|
|
34
34
|
"portfinder": "^1.0.38",
|
|
35
35
|
"rolldown": "^1.0.0-beta.40",
|
|
36
|
-
"rollup": "^4.52.
|
|
36
|
+
"rollup": "^4.52.3",
|
|
37
37
|
"vite": "^7.1.7",
|
|
38
38
|
"ws": "^8.18.3"
|
|
39
39
|
}
|
package/src/rebundle.ts
CHANGED
|
@@ -119,13 +119,16 @@ export class Rebundle extends Unit {
|
|
|
119
119
|
const chunkPath = join(this.dist, chunk.fileName)
|
|
120
120
|
const chunkOptions = this.options[chunk.name] ?? {}
|
|
121
121
|
|
|
122
|
-
// Read chunk files
|
|
122
|
+
// Read chunk files
|
|
123
123
|
const chunkFiles = await this.readChunkFiles(chunk)
|
|
124
124
|
|
|
125
125
|
// Check if chunk was modified
|
|
126
126
|
const chunkFilePaths = Object.keys(chunkFiles)
|
|
127
127
|
const chunkModified = chunkFilePaths.some(path => chunkFiles[path] !== this.originalFiles[path])
|
|
128
128
|
|
|
129
|
+
// Update original files content
|
|
130
|
+
Object.assign(this.originalFiles, chunkFiles)
|
|
131
|
+
|
|
129
132
|
// Chunk was not modified? -> Use previous content
|
|
130
133
|
if (!chunkModified) {
|
|
131
134
|
// Overwrite vite's output with previously rebundled code
|
|
@@ -138,17 +141,15 @@ export class Rebundle extends Unit {
|
|
|
138
141
|
if (sourcemap) await this.writeToDist(chunk.sourcemapFileName, sourcemap)
|
|
139
142
|
}
|
|
140
143
|
|
|
144
|
+
// Return not modified status
|
|
141
145
|
return false
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
// Build with rolldown
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
console.error(error)
|
|
150
|
-
return
|
|
151
|
-
}
|
|
149
|
+
const [build] = await safe(rolldown({ ...chunkOptions.input, input: chunkPath }))
|
|
150
|
+
if (!build) return
|
|
151
|
+
const [_, error] = await safe(build.write({ ...chunkOptions.output, file: chunkPath }))
|
|
152
|
+
if (error) return
|
|
152
153
|
|
|
153
154
|
// Log successful build
|
|
154
155
|
const { size } = await stat(chunkPath)
|
|
@@ -169,6 +170,7 @@ export class Rebundle extends Unit {
|
|
|
169
170
|
if (sourcemap) this.rebundledFiles[chunk.sourcemapFileName] = sourcemap
|
|
170
171
|
}
|
|
171
172
|
|
|
173
|
+
// Return modified status
|
|
172
174
|
return true
|
|
173
175
|
}
|
|
174
176
|
|