@@ -119,7 +119,8 @@ function webpackDebugIdInjectionPlugin(): UnpluginOptions {
119119
120120function webpackDebugIdUploadPlugin (
121121 upload : ( buildArtifacts : string [ ] ) => Promise < void > ,
122- logger : Logger
122+ logger : Logger ,
123+ forceExitOnBuildCompletion ?: boolean
123124) : UnpluginOptions {
124125 const pluginName = "sentry-webpack-debug-id-upload-plugin" ;
125126 return {
@@ -136,7 +137,7 @@ function webpackDebugIdUploadPlugin(
136137 } ) ;
137138 } ) ;
138139
139- if ( compiler . options . mode === "production" ) {
140+ if ( forceExitOnBuildCompletion && compiler . options . mode === "production" ) {
140141 compiler . hooks . done . tap ( pluginName , ( ) => {
141142 setTimeout ( ( ) => {
142143 logger . debug ( "Exiting process after debug file upload" ) ;
@@ -184,8 +185,24 @@ const sentryUnplugin = sentryUnpluginFactory({
184185 bundleSizeOptimizationsPlugin : webpackBundleSizeOptimizationsPlugin ,
185186} ) ;
186187
188+ type SentryWebpackPluginOptions = Options & {
189+ _experiments : Options [ "_experiments" ] & {
190+ /**
191+ * If enabled, the webpack plugin will exit the build process after the build completes.
192+ * Use this with caution, as it will terminate the process.
193+ *
194+ * More information: https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/345
195+ *
196+ * @default false
197+ */
198+ forceExitOnBuildCompletion ?: boolean ;
199+ } ;
200+ } ;
201+
187202// eslint-disable-next-line @typescript-eslint/no-explicit-any
188- export const sentryWebpackPlugin : ( options ?: Options ) => any = sentryUnplugin . webpack ;
203+ export const sentryWebpackPlugin : ( options ?: SentryWebpackPluginOptions ) => any =
204+ sentryUnplugin . webpack ;
189205
190206export { sentryCliBinaryExists } from "@sentry/bundler-plugin-core" ;
191- export type { Options as SentryWebpackPluginOptions } from "@sentry/bundler-plugin-core" ;
207+
208+ export type { SentryWebpackPluginOptions } ;
0 commit comments