Skip to content

Commit

Permalink
fix(nextjs): Don't leak webpack types into exports
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Oct 29, 2024
1 parent a7193fb commit e065253
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
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: WebpackPluginInstance;
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
defaultLoaders: any; // needed for type tests (test:types)
Expand Down

0 comments on commit e065253

Please sign in to comment.