@sentry/nextjs
Version:
Official Sentry SDK for Next.js
71 lines (68 loc) • 3.2 kB
JavaScript
import { detectActiveBundler } from '../util.js';
function migrateDeprecatedWebpackOptions(userSentryOptions) {
userSentryOptions.webpack = userSentryOptions.webpack || {};
const webpack = userSentryOptions.webpack;
const withDeprecatedFallback = (newValue, deprecatedValue, message) => {
if (deprecatedValue !== void 0) {
console.warn(message);
}
return newValue ?? deprecatedValue;
};
const deprecatedMessage = (deprecatedPath, newPath) => {
const message = `[@sentry/nextjs] DEPRECATION WARNING: ${deprecatedPath} is deprecated and will be removed in a future version. Use ${newPath} instead.`;
if (detectActiveBundler() === "turbopack" && newPath.startsWith("webpack.")) {
return `${message} (Not supported with Turbopack.)`;
}
return message;
};
webpack.autoInstrumentServerFunctions = withDeprecatedFallback(
webpack.autoInstrumentServerFunctions,
userSentryOptions.autoInstrumentServerFunctions,
deprecatedMessage("autoInstrumentServerFunctions", "webpack.autoInstrumentServerFunctions")
);
webpack.autoInstrumentMiddleware = withDeprecatedFallback(
webpack.autoInstrumentMiddleware,
userSentryOptions.autoInstrumentMiddleware,
deprecatedMessage("autoInstrumentMiddleware", "webpack.autoInstrumentMiddleware")
);
webpack.autoInstrumentAppDirectory = withDeprecatedFallback(
webpack.autoInstrumentAppDirectory,
userSentryOptions.autoInstrumentAppDirectory,
deprecatedMessage("autoInstrumentAppDirectory", "webpack.autoInstrumentAppDirectory")
);
webpack.excludeServerRoutes = withDeprecatedFallback(
webpack.excludeServerRoutes,
userSentryOptions.excludeServerRoutes,
deprecatedMessage("excludeServerRoutes", "webpack.excludeServerRoutes")
);
webpack.unstable_sentryWebpackPluginOptions = withDeprecatedFallback(
webpack.unstable_sentryWebpackPluginOptions,
userSentryOptions.unstable_sentryWebpackPluginOptions,
deprecatedMessage("unstable_sentryWebpackPluginOptions", "webpack.unstable_sentryWebpackPluginOptions")
);
webpack.disableSentryConfig = withDeprecatedFallback(
webpack.disableSentryConfig,
userSentryOptions.disableSentryWebpackConfig,
deprecatedMessage("disableSentryWebpackConfig", "webpack.disableSentryConfig")
);
if (userSentryOptions.disableLogger !== void 0) {
webpack.treeshake = webpack.treeshake || {};
webpack.treeshake.removeDebugLogging = withDeprecatedFallback(
webpack.treeshake.removeDebugLogging,
userSentryOptions.disableLogger,
deprecatedMessage("disableLogger", "webpack.treeshake.removeDebugLogging")
);
}
webpack.automaticVercelMonitors = withDeprecatedFallback(
webpack.automaticVercelMonitors,
userSentryOptions.automaticVercelMonitors,
deprecatedMessage("automaticVercelMonitors", "webpack.automaticVercelMonitors")
);
webpack.reactComponentAnnotation = withDeprecatedFallback(
webpack.reactComponentAnnotation,
userSentryOptions.reactComponentAnnotation,
deprecatedMessage("reactComponentAnnotation", "webpack.reactComponentAnnotation")
);
}
export { migrateDeprecatedWebpackOptions };
//# sourceMappingURL=deprecatedWebpackOptions.js.map