Skip to content

Commit 57ba5a7

Browse files
author
Luca Forstner
authored
fix(nextjs): Don't leak webpack types into exports (#14116)
Fixes #14066 We're just vendoring the types. The chance that anyone is depending on the specifics is lim x -> 0.
1 parent 81b1f9f commit 57ba5a7

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

packages/nextjs/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,7 @@
100100
"next": "13.2.0"
101101
},
102102
"peerDependencies": {
103-
"next": "^13.2.0 || ^14.0 || ^15.0.0-rc.0",
104-
"webpack": ">=5.0.0"
105-
},
106-
"peerDependenciesMeta": {
107-
"webpack": {
108-
"optional": true
109-
}
103+
"next": "^13.2.0 || ^14.0 || ^15.0.0-rc.0"
110104
},
111105
"scripts": {
112106
"build": "run-p build:transpile build:types",

packages/nextjs/src/config/types.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import type { GLOBAL_OBJ } from '@sentry/utils';
22
import type { SentryWebpackPluginOptions } from '@sentry/webpack-plugin';
3-
import type { DefinePlugin, WebpackPluginInstance } from 'webpack';
4-
5-
// Export this from here because importing something from Webpack (the library) in `webpack.ts` confuses the heck out of
6-
// madge, which we use for circular dependency checking. We've manually excluded this file from the check (which is
7-
// safe, since it only includes types), so we can import it here without causing madge to fail. See
8-
// https://github.com/pahen/madge/issues/306.
9-
export type { WebpackPluginInstance };
103

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

13+
interface WebpackPluginInstance {
14+
[index: string]: any;
15+
apply: (compiler: any) => void;
16+
}
17+
2018
export type NextConfigObject = {
2119
// Custom webpack options
2220
webpack?: WebpackConfigFunction | null;
@@ -502,7 +500,7 @@ export type BuildContext = {
502500
config: any;
503501
webpack: {
504502
version: string;
505-
DefinePlugin: typeof DefinePlugin;
503+
DefinePlugin: new (values: Record<string, string | boolean>) => WebpackPluginInstance;
506504
};
507505
// eslint-disable-next-line @typescript-eslint/no-explicit-any
508506
defaultLoaders: any; // needed for type tests (test:types)

0 commit comments

Comments
 (0)