diff --git a/lib/core/hooks.js b/lib/core/hooks.js index 9b5e2d8a..f2304e08 100644 --- a/lib/core/hooks.js +++ b/lib/core/hooks.js @@ -1,6 +1,5 @@ import { resolve, posix } from 'path' import merge from 'lodash.mergewith' -import { DefinePlugin } from 'webpack' import * as Sentry from '@sentry/node' import { canInitialize, clientSentryEnabled, envToBool, serverSentryEnabled } from './utils' import { resolveRelease, resolveClientOptions, resolveServerOptions } from './options' @@ -46,9 +45,10 @@ export async function buildHook (moduleContainer, moduleOptions, logger) { // Tree shake debugging code if not running in dev mode and Sentry debug option is not enabled on the client. if (!clientOptions.dev && !clientOptions.config.debug) { + const webpack = await import('webpack').then(m => m.default || m) moduleContainer.options.build.plugins = moduleContainer.options.build.plugins || [] moduleContainer.options.build.plugins.push( - new DefinePlugin({ + new webpack.DefinePlugin({ __SENTRY_DEBUG__: 'false', }), )