Skip to content
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
3 changes: 2 additions & 1 deletion packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ export function constructWebpackConfigFunction(
// Symbolication for dev-mode errors is done elsewhere.
if (!isDev) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const { sentryWebpackPlugin } = loadModule('@sentry/webpack-plugin') as any;
const { sentryWebpackPlugin } = loadModule<{ sentryWebpackPlugin: any }>('@sentry/webpack-plugin') ?? {};

if (sentryWebpackPlugin) {
if (!userSentryOptions.sourcemaps?.disable) {
// `hidden-source-map` produces the same sourcemaps as `source-map`, but doesn't include the `sourceMappingURL`
Expand Down
12 changes: 7 additions & 5 deletions packages/utils/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ export function loadModule<T>(moduleName: string): T | undefined {
// no-empty
}

try {
const { cwd } = dynamicRequire(module, 'process');
mod = dynamicRequire(module, `${cwd()}/node_modules/${moduleName}`) as T;
} catch (e) {
// no-empty
if (!mod) {
try {
const { cwd } = dynamicRequire(module, 'process');
mod = dynamicRequire(module, `${cwd()}/node_modules/${moduleName}`) as T;
} catch (e) {
// no-empty
}
}

return mod;
Expand Down
Loading