Skip to content

Commit f3de074

Browse files
authored
fix(releases): cover case with empty map body (#397)
1 parent d222bf8 commit f3de074

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

workers/release/src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,22 +248,30 @@ export default class ReleaseWorker extends Worker {
248248
* @param {SourcemapCollectedData[]} sourceMaps — source maps passed from user after bundle
249249
*/
250250
private extendReleaseInfo(sourceMaps: SourcemapCollectedData[]): SourceMapDataExtended[] {
251-
return sourceMaps.map((file: SourcemapCollectedData) => {
251+
return sourceMaps.flatMap((file: SourcemapCollectedData) => {
252252
/**
253253
* Decode base64 source map content
254254
*/
255255
const buffer = Buffer.from(file.payload, 'base64');
256256
const mapBodyString = buffer.toString();
257+
258+
/**
259+
* If content is empty, return nothing for this file
260+
*/
261+
if (!mapBodyString || mapBodyString.trim().length === 0) {
262+
return [];
263+
}
264+
257265
/**
258266
* @todo use more efficient method to extract "file" from big JSON
259267
*/
260268
const mapContent = JSON.parse(mapBodyString) as RawSourceMap;
261269

262-
return {
270+
return [{
263271
mapFileName: file.name,
264272
originFileName: mapContent.file,
265273
content: mapBodyString,
266-
};
274+
}];
267275
});
268276
}
269277

0 commit comments

Comments
 (0)