@@ -8,14 +8,14 @@ type PlainObject<T = any> = { [key: string]: T };
8
8
9
9
// Man are these types hard to name well. "Entry" = an item in some collection of items, but in our case, one of the
10
10
// things we're worried about here is property (entry) in an object called... entry. So henceforth, the specific
11
- // proptery we're modifying is going to be known as an EntryProperty, or EP for short .
11
+ // property we're modifying is going to be known as an EntryProperty.
12
12
13
13
// The function which is ultimately going to be exported from `next.config.js` under the name `webpack`
14
14
type WebpackExport = ( config : WebpackConfig , options : WebpackOptions ) => WebpackConfig ;
15
- // type WebpackExport = (config: WebpackConfig, options: WebpackOptions) => Promise<WebpackConfig>;
16
15
17
16
// The two arguments passed to the exported `webpack` function, as well as the thing it returns
18
17
type WebpackConfig = { devtool : string ; plugins : PlainObject [ ] ; entry : EntryProperty } ;
18
+ // TODO use real webpack types
19
19
type WebpackOptions = { dev : boolean ; isServer : boolean } ;
20
20
21
21
// For our purposes, the value for `entry` is either an object, or a function which returns such an object
@@ -27,7 +27,6 @@ type EntryProperty = (() => Promise<EntryPropertyObject>) | EntryPropertyObject;
27
27
type EntryPropertyObject = PlainObject < string | Array < string > | EntryPointObject > ;
28
28
type EntryPointObject = { import : string | Array < string > } ;
29
29
30
- // const injectSentry = async (origEntryProperty: EntryProperty, isServer: boolean): Promise<EntryPropertyObject> => {
31
30
const injectSentry = async ( origEntryProperty : EntryProperty , isServer : boolean ) : Promise < EntryProperty > => {
32
31
// Out of the box, nextjs uses the `() => Promise<EntryPropertyObject>)` flavor of EntryProperty, where the returned
33
32
// object has string arrays for values. But because we don't know whether someone else has come along before us and
@@ -77,7 +76,8 @@ const injectSentry = async (origEntryProperty: EntryProperty, isServer: boolean)
77
76
78
77
newEntryProperty [ injectionPoint ] = injectedInto ;
79
78
80
- // TODO: hack made necessary because promises are currently kicking my butt
79
+ // TODO: hack made necessary because the async-ness of this function turns our object back into a promise, meaning the
80
+ // internal `next` code which should do this doesn't
81
81
if ( 'main.js' in newEntryProperty ) {
82
82
delete newEntryProperty [ 'main.js' ] ;
83
83
}
@@ -115,19 +115,17 @@ export function withSentryConfig(
115
115
. map ( key => key in Object . keys ( providedWebpackPluginOptions ) ) ;
116
116
if ( webpackPluginOptionOverrides . length > 0 ) {
117
117
logger . warn (
118
- '[next-plugin-sentry ] You are overriding the following automatically-set SentryWebpackPlugin config options:\n' +
118
+ '[Sentry ] You are overriding the following automatically-set SentryWebpackPlugin config options:\n' +
119
119
`\t${ webpackPluginOptionOverrides . toString ( ) } ,\n` +
120
120
"which has the possibility of breaking source map upload and application. This is only a good idea if you know what you're doing." ,
121
121
) ;
122
122
}
123
123
124
- // const newWebpackExport = async (config: WebpackConfig, options: WebpackOptions): Promise<WebpackConfig> => {
125
124
const newWebpackExport = ( config : WebpackConfig , options : WebpackOptions ) : WebpackConfig => {
126
125
let newConfig = config ;
127
126
128
127
if ( typeof providedExports . webpack === 'function' ) {
129
128
newConfig = providedExports . webpack ( config , options ) ;
130
- // newConfig = await providedExports.webpack(config, options);
131
129
}
132
130
133
131
// Ensure quality source maps in production. (Source maps aren't uploaded in dev, and besides, Next doesn't let you
@@ -140,8 +138,6 @@ export function withSentryConfig(
140
138
// Inject user config files (`sentry.client.confg.js` and `sentry.server.config.js`), which is where `Sentry.init()`
141
139
// is called. By adding them here, we ensure that they're bundled by webpack as part of both server code and client code.
142
140
newConfig . entry = ( injectSentry ( newConfig . entry , options . isServer ) as unknown ) as EntryProperty ;
143
- // newConfig.entry = await injectSentry(newConfig.entry, options.isServer);
144
- // newConfig.entry = async () => injectSentry(newConfig.entry, options.isServer);
145
141
146
142
// Add the Sentry plugin, which uploads source maps to Sentry when not in dev
147
143
newConfig . plugins . push (
0 commit comments