-
-
Couldn't load subscription status.
- Fork 1.7k
feat(react-router): Align options with shared build time options type #18014
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||
| import { rm } from 'node:fs/promises'; | ||||||
| import type { Config } from '@react-router/dev/config'; | ||||||
| import SentryCli from '@sentry/cli'; | ||||||
| import type { SentryVitePluginOptions } from '@sentry/vite-plugin'; | ||||||
| import { glob } from 'glob'; | ||||||
| import type { SentryReactRouterBuildOptions } from '../types'; | ||||||
|
|
||||||
|
|
@@ -23,17 +24,31 @@ function getSentryConfig(viteConfig: unknown): SentryReactRouterBuildOptions { | |||||
| export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteConfig }) => { | ||||||
| const sentryConfig = getSentryConfig(viteConfig); | ||||||
|
|
||||||
| // todo(v11): Remove deprecated sourceMapsUploadOptions support (no need for spread/pick anymore) | ||||||
| const { | ||||||
| sourceMapsUploadOptions, // extract to exclude from rest config | ||||||
| ...sentryConfigWithoutDeprecatedSourceMapOption | ||||||
| } = sentryConfig; | ||||||
|
|
||||||
| const { | ||||||
| authToken, | ||||||
| org, | ||||||
| project, | ||||||
| release, | ||||||
| sourceMapsUploadOptions = { enabled: true }, | ||||||
| sourcemaps = { disable: false }, | ||||||
| debug = false, | ||||||
| unstable_sentryVitePluginOptions, | ||||||
| }: SentryReactRouterBuildOptions = { | ||||||
| }: Omit<SentryReactRouterBuildOptions, 'sourcemaps' | 'sourceMapsUploadOptions'> & | ||||||
| // Pick 'sourcemaps' from Vite plugin options as the types allow more (e.g. Promise values for `deleteFilesAfterUpload`) | ||||||
| Pick<SentryVitePluginOptions, 'sourcemaps'> = { | ||||||
| ...sentryConfig.unstable_sentryVitePluginOptions, | ||||||
| ...sentryConfig, | ||||||
| ...sentryConfigWithoutDeprecatedSourceMapOption, // spread in the config without the deprecated sourceMapsUploadOptions | ||||||
| sourcemaps: { | ||||||
| ...sentryConfig.unstable_sentryVitePluginOptions?.sourcemaps, | ||||||
| ...sentryConfig.sourcemaps, | ||||||
| ...sourceMapsUploadOptions, | ||||||
| // eslint-disable-next-line deprecation/deprecation | ||||||
| disable: sourceMapsUploadOptions?.enabled === false ? true : sentryConfig.sourcemaps?.disable, | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: following would do the same and is a little shorter
Suggested change
|
||||||
| }, | ||||||
| release: { | ||||||
| ...sentryConfig.unstable_sentryVitePluginOptions?.release, | ||||||
| ...sentryConfig.release, | ||||||
|
|
@@ -44,8 +59,9 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo | |||||
| authToken, | ||||||
| org, | ||||||
| project, | ||||||
| ...unstable_sentryVitePluginOptions, | ||||||
| ...sentryConfig.unstable_sentryVitePluginOptions, | ||||||
| }); | ||||||
|
|
||||||
| // check if release should be created | ||||||
| if (release?.name) { | ||||||
| try { | ||||||
|
|
@@ -56,7 +72,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (sourceMapsUploadOptions?.enabled ?? (true && viteConfig.build.sourcemap !== false)) { | ||||||
| if (!sourcemaps?.disable && viteConfig.build.sourcemap !== false) { | ||||||
| // inject debugIds | ||||||
| try { | ||||||
| await cliInstance.execute( | ||||||
|
|
@@ -84,9 +100,10 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo | |||||
| } | ||||||
| } | ||||||
| // delete sourcemaps after upload | ||||||
| let updatedFilesToDeleteAfterUpload = sourceMapsUploadOptions?.filesToDeleteAfterUpload; | ||||||
| let updatedFilesToDeleteAfterUpload = await sourcemaps?.filesToDeleteAfterUpload; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: Why is this awaited? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this can be a Promise when coming from the |
||||||
|
|
||||||
| // set a default value no option was set | ||||||
| if (typeof sourceMapsUploadOptions?.filesToDeleteAfterUpload === 'undefined') { | ||||||
| if (typeof updatedFilesToDeleteAfterUpload === 'undefined') { | ||||||
| updatedFilesToDeleteAfterUpload = [`${reactRouterConfig.buildDirectory}/**/*.map`]; | ||||||
| debug && | ||||||
| // eslint-disable-next-line no-console | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file are basically just a back-port of the changes in the bundler-plugin type.
getsentry/sentry-javascript-bundler-plugins@main/packages/bundler-plugin-core/src/types.ts