Skip to content

feat(solidstart): Streamline build logs #17304

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

Merged
merged 1 commit into from
Aug 4, 2025
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
31 changes: 15 additions & 16 deletions packages/solidstart/src/vite/sourceMaps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { consoleSandbox } from '@sentry/core';
import { sentryVitePlugin } from '@sentry/vite-plugin';
import type { Plugin, UserConfig } from 'vite';
import type { SentrySolidStartPluginOptions } from './types';
Expand All @@ -21,14 +20,13 @@ export function makeAddSentryVitePlugin(options: SentrySolidStartPluginOptions,
// For .output, .vercel, .netlify etc.
updatedFilesToDeleteAfterUpload = ['.*/**/*.map'];

consoleSandbox(() => {
debug &&
// eslint-disable-next-line no-console
console.log(
`[Sentry] Automatically setting \`sourceMapsUploadOptions.filesToDeleteAfterUpload: ${JSON.stringify(
updatedFilesToDeleteAfterUpload,
)}\` to delete generated source maps after they were uploaded to Sentry.`,
);
});
}

return [
Expand Down Expand Up @@ -103,36 +101,37 @@ export function getUpdatedSourceMapSettings(
let updatedSourceMapSetting = viteSourceMap;

const settingKey = 'vite.build.sourcemap';
const debug = sentryPluginOptions?.debug;

if (viteSourceMap === false) {
updatedSourceMapSetting = viteSourceMap;

consoleSandbox(() => {
// eslint-disable-next-line no-console
if (debug) {
// Longer debug message with more details
// eslint-disable-next-line no-console
console.warn(
`[Sentry] Source map generation is currently disabled in your SolidStart configuration (\`${settingKey}: false \`). This setting is either a default setting or was explicitly set in your configuration. Sentry won't override this setting. Without source maps, code snippets on the Sentry Issues page will remain minified. To show unminified code, enable source maps in \`${settingKey}\` (e.g. by setting them to \`hidden\`).`,
);
});
} else {
// eslint-disable-next-line no-console
console.warn('[Sentry] Source map generation is disabled in your SolidStart configuration.');
}
} else if (viteSourceMap && ['hidden', 'inline', true].includes(viteSourceMap)) {
updatedSourceMapSetting = viteSourceMap;

if (sentryPluginOptions?.debug) {
consoleSandbox(() => {
// eslint-disable-next-line no-console
console.log(
`[Sentry] We discovered \`${settingKey}\` is set to \`${viteSourceMap.toString()}\`. Sentry will keep this source map setting. This will un-minify the code snippet on the Sentry Issue page.`,
);
});
}
debug &&
// eslint-disable-next-line no-console
console.log(
`[Sentry] We discovered \`${settingKey}\` is set to \`${viteSourceMap.toString()}\`. Sentry will keep this source map setting. This will un-minify the code snippet on the Sentry Issue page.`,
);
} else {
updatedSourceMapSetting = 'hidden';

consoleSandbox(() => {
debug &&
// eslint-disable-next-line no-console
console.log(
`[Sentry] Enabled source map generation in the build options with \`${settingKey}: 'hidden'\`. The source maps will be deleted after they were uploaded to Sentry.`,
);
});
}

return updatedSourceMapSetting;
Expand Down
26 changes: 22 additions & 4 deletions packages/solidstart/test/vite/sourceMaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,31 @@ describe('getUpdatedSourceMapSettings', () => {
});

describe('when sourcemap is false', () => {
it('should keep sourcemap as false and show warning', () => {
it('should keep sourcemap as false and show short warning when debug is disabled', () => {
const result = getUpdatedSourceMapSettings({ build: { sourcemap: false } });

expect(result).toBe(false);
// eslint-disable-next-line no-console
expect(console.warn).toHaveBeenCalledWith(
expect.stringContaining('[Sentry] Source map generation is currently disabled'),
'[Sentry] Source map generation is disabled in your SolidStart configuration.',
);
});

it('should keep sourcemap as false and show long warning when debug is enabled', () => {
const result = getUpdatedSourceMapSettings({ build: { sourcemap: false } }, { debug: true });

expect(result).toBe(false);
// eslint-disable-next-line no-console
expect(console.warn).toHaveBeenCalledWith(
expect.stringContaining(
'[Sentry] Source map generation is currently disabled in your SolidStart configuration',
),
);
// eslint-disable-next-line no-console
expect(console.warn).toHaveBeenCalledWith(
expect.stringContaining(
'This setting is either a default setting or was explicitly set in your configuration.',
),
);
});
});
Expand All @@ -210,7 +228,7 @@ describe('getUpdatedSourceMapSettings', () => {
it.each([[undefined], ['invalid'], ['something'], [null]])(
'should set sourcemap to hidden when value is %s',
input => {
const result = getUpdatedSourceMapSettings({ build: { sourcemap: input as any } });
const result = getUpdatedSourceMapSettings({ build: { sourcemap: input as any } }, { debug: true });

expect(result).toBe('hidden');
// eslint-disable-next-line no-console
Expand All @@ -223,7 +241,7 @@ describe('getUpdatedSourceMapSettings', () => {
);

it('should set sourcemap to hidden when build config is empty', () => {
const result = getUpdatedSourceMapSettings({});
const result = getUpdatedSourceMapSettings({}, { debug: true });

expect(result).toBe('hidden');
// eslint-disable-next-line no-console
Expand Down
Loading