Skip to content

Commit 7c37103

Browse files
author
Luca Forstner
committed
.
1 parent 68bbbe9 commit 7c37103

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/nextjs/src/config/runAfterProductionCompile.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { SentryBuildOptions } from './types';
22
import { getWebpackBuildFunctionCalled } from './util';
3-
import { createSentryBuildPluginManager } from '@sentry/bundler-plugin-core';
43
import { getBuildPluginOptions } from './webpackPluginOptions';
54
import { glob } from 'glob';
5+
import { loadModule } from '@sentry/core';
6+
import type { createSentryBuildPluginManager as createSentryBuildPluginManagerType } from '@sentry/bundler-plugin-core';
67

78
/**
89
* A function to do Sentry stuff for the `runAfterProductionCompile` Next.js hook
@@ -20,6 +21,20 @@ export async function handleAfterProductionCompile(
2021
return;
2122
}
2223

24+
const { createSentryBuildPluginManager } =
25+
loadModule<{ createSentryBuildPluginManager: typeof createSentryBuildPluginManagerType }>(
26+
'@sentry/bundler-plugin-core',
27+
module,
28+
) ?? {};
29+
30+
if (!createSentryBuildPluginManager) {
31+
// eslint-disable-next-line no-console
32+
console.warn(
33+
'[@sentry/nextjs] Could not load build manager package. Will not run runAfterProductionCompile logic.',
34+
);
35+
return;
36+
}
37+
2338
const sentryBuildPluginManager = createSentryBuildPluginManager(
2439
getBuildPluginOptions(sentryBuildOptions, buildInfo.releaseName, 'after-production-build', buildInfo.distDir),
2540
{

0 commit comments

Comments
 (0)