Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nextjs): Don't leak webpack types into exports #14116

Merged
merged 2 commits into from
Oct 29, 2024
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
8 changes: 1 addition & 7 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,7 @@
"next": "13.2.0"
},
"peerDependencies": {
"next": "^13.2.0 || ^14.0 || ^15.0.0-rc.0",
"webpack": ">=5.0.0"
},
"peerDependenciesMeta": {
"webpack": {
"optional": true
}
"next": "^13.2.0 || ^14.0 || ^15.0.0-rc.0"
},
"scripts": {
"build": "run-p build:transpile build:types",
Expand Down
14 changes: 6 additions & 8 deletions packages/nextjs/src/config/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import type { GLOBAL_OBJ } from '@sentry/utils';
import type { SentryWebpackPluginOptions } from '@sentry/webpack-plugin';
import type { DefinePlugin, WebpackPluginInstance } from 'webpack';

// Export this from here because importing something from Webpack (the library) in `webpack.ts` confuses the heck out of
// madge, which we use for circular dependency checking. We've manually excluded this file from the check (which is
// safe, since it only includes types), so we can import it here without causing madge to fail. See
// https://github.com/pahen/madge/issues/306.
export type { WebpackPluginInstance };

// The first argument to `withSentryConfig` (which is the user's next config).
export type ExportedNextConfig = NextConfigObject | NextConfigFunction;
Expand All @@ -17,6 +10,11 @@ type NextRewrite = {
destination: string;
};

interface WebpackPluginInstance {
[index: string]: any;
apply: (compiler: any) => void;
}

export type NextConfigObject = {
// Custom webpack options
webpack?: WebpackConfigFunction | null;
Expand Down Expand Up @@ -502,7 +500,7 @@ export type BuildContext = {
config: any;
webpack: {
version: string;
DefinePlugin: typeof DefinePlugin;
DefinePlugin: new (values: Record<string, string | boolean>) => WebpackPluginInstance;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
defaultLoaders: any; // needed for type tests (test:types)
Expand Down
Loading