Skip to content

Commit 8bbfb7c

Browse files
authored
Merge pull request #114 from DataDog/yoann/small-fixes
[fix] Small fixes
2 parents d7ff9ce + 546f6bf commit 8bbfb7c

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

packages/core/src/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ export const outputFileSync = (filepath: string, data: string) => {
153153

154154
// Output a JSON file.
155155
export const outputJson = async (filepath: string, data: any) => {
156+
// FIXME: This will crash on strings too long.
156157
const dataString = JSON.stringify(data, null, 4);
157158
return outputFile(filepath, dataString);
158159
};
159160

160161
export const outputJsonSync = (filepath: string, data: any) => {
162+
// FIXME: This will crash on strings too long.
161163
const dataString = JSON.stringify(data, null, 4);
162164
outputFileSync(filepath, dataString);
163165
};

packages/plugins/build-report/src/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import path from 'path';
2222
const EXTENSION_RX = /\.(?!.*(?:\.|\/|\\))(\w{1,})/g;
2323

2424
// Will match any type of query characters.
25+
// "?" or "%3F" (url encoded "?") or "|"
2526
const QUERY_RX = /(\?|%3F|\|)+/gi;
2627

2728
const getExtension = (filepath: string) => {
@@ -226,6 +227,7 @@ export const cleanReport = <T = string>(
226227
};
227228

228229
// Clean a path from its query parameters and leading invisible characters.
230+
// Careful with this and webpack/rspack as loaders may add "|" before and after the filepath.
229231
export const cleanPath = (filepath: string) => {
230232
return (
231233
filepath

packages/plugins/build-report/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const getBuildReportPlugins = (context: GlobalContext, log: Logger): Plug
1717
enforce: 'post',
1818
esbuild: getEsbuildPlugin(context, log),
1919
rspack: getXpackPlugin(context, PLUGIN_NAME, log),
20-
webpack: getXpackPlugin(context, PLUGIN_NAME, log) as PluginOptions['webpack'],
20+
webpack: getXpackPlugin(context, PLUGIN_NAME, log),
2121
// Vite and Rollup have the same API.
2222
vite: getRollupPlugin(context, log),
2323
rollup: getRollupPlugin(context, log),

packages/plugins/build-report/src/xpack.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ export const getXpackPlugin =
367367
// Filter the ones that includes the entry name.
368368
.filter(
369369
(f) => f.includes(name) || (entrypoint.name && f.includes(entrypoint.name)),
370-
)[0];
370+
)
371+
// Only keep JS files.
372+
.find((f) => getType(f) === 'js');
371373

372374
for (const file of entryFiles) {
373375
const outputFound = reportOutputsIndexed.get(file);

packages/plugins/telemetry/src/common/sender.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ Metrics:
4141
return doRequest({
4242
method: 'POST',
4343
url: `${auth.endPoint}/api/v1/series?api_key=${auth.apiKey}`,
44-
getData: () => ({ data: JSON.stringify({ series: metrics }) }),
44+
getData: () => ({
45+
data: JSON.stringify({ series: Array.from(metrics) } satisfies {
46+
series: MetricToSend[];
47+
}),
48+
}),
4549
})
4650
.then(() => {
4751
log.debug(`Sent metrics in ${formatDuration(Date.now() - startSending)}.`);

0 commit comments

Comments
 (0)