Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Small fixes #114

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,13 @@ export const outputFileSync = (filepath: string, data: string) => {

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

export const outputJsonSync = (filepath: string, data: any) => {
// FIXME: This will crash on strings too long.
const dataString = JSON.stringify(data, null, 4);
outputFileSync(filepath, dataString);
};
Expand Down
2 changes: 2 additions & 0 deletions packages/plugins/build-report/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import path from 'path';
const EXTENSION_RX = /\.(?!.*(?:\.|\/|\\))(\w{1,})/g;

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

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

// Clean a path from its query parameters and leading invisible characters.
// Careful with this and webpack/rspack as loaders may add "|" before and after the filepath.
export const cleanPath = (filepath: string) => {
return (
filepath
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/build-report/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getBuildReportPlugins = (context: GlobalContext, log: Logger): Plug
enforce: 'post',
esbuild: getEsbuildPlugin(context, log),
rspack: getXpackPlugin(context, PLUGIN_NAME, log),
webpack: getXpackPlugin(context, PLUGIN_NAME, log) as PluginOptions['webpack'],
webpack: getXpackPlugin(context, PLUGIN_NAME, log),
// Vite and Rollup have the same API.
vite: getRollupPlugin(context, log),
rollup: getRollupPlugin(context, log),
Expand Down
4 changes: 3 additions & 1 deletion packages/plugins/build-report/src/xpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ export const getXpackPlugin =
// Filter the ones that includes the entry name.
.filter(
(f) => f.includes(name) || (entrypoint.name && f.includes(entrypoint.name)),
)[0];
)
// Only keep JS files.
.find((f) => getType(f) === 'js');

for (const file of entryFiles) {
const outputFound = reportOutputsIndexed.get(file);
Expand Down
6 changes: 5 additions & 1 deletion packages/plugins/telemetry/src/common/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ Metrics:
return doRequest({
method: 'POST',
url: `${auth.endPoint}/api/v1/series?api_key=${auth.apiKey}`,
getData: () => ({ data: JSON.stringify({ series: metrics }) }),
getData: () => ({
data: JSON.stringify({ series: Array.from(metrics) } satisfies {
series: MetricToSend[];
}),
}),
})
.then(() => {
log.debug(`Sent metrics in ${formatDuration(Date.now() - startSending)}.`);
Expand Down