Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Jul 8, 2021
1 parent 4650b55 commit d8f4a82
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { SERVER_SDK_INIT_PATH, storeServerConfigFileLocation } from './utils';

export { SentryWebpackPlugin };

logger.enable();

// TODO: merge default SentryWebpackPlugin ignore with their SentryWebpackPlugin ignore or ignoreFile
// TODO: merge default SentryWebpackPlugin include with their SentryWebpackPlugin include
// TODO: drop merged keys from override check? `includeDefaults` option?
Expand Down Expand Up @@ -54,7 +56,7 @@ export function constructWebpackConfigFunction(
): WebpackConfigFunction {
// Will be called by nextjs and passed its default webpack configuration and context data about the build (whether
// we're building server or client, whether we're in dev, what version of webpack we're using, etc). Note that
// `currentWebpackConfig` and `buildContext` are referred to as `config` and `options` in the nextjs docs.
// `incomingConfig` and `buildContext` are referred to as `config` and `options` in the nextjs docs.
const newWebpackFunction = (incomingConfig: WebpackConfigObject, buildContext: BuildContext): WebpackConfigObject => {
let newConfig = { ...incomingConfig };

Expand Down Expand Up @@ -203,7 +205,7 @@ function addFileToExistingEntryPoint(
newEntryPoint = [...currentEntryPoint, filepath];
}
// descriptor object (webpack 5+)
else {
else if (typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint) {
const currentImportValue = currentEntryPoint.import;
let newImportValue: string | string[];

Expand All @@ -217,6 +219,13 @@ function addFileToExistingEntryPoint(
...currentEntryPoint,
import: newImportValue,
};
} else {
logger.warn(
`Could not inject SDK initialization code into entry point ${entryPointName}, as it is not a recognized format.\n`,
`Expected: string | Array<string> | { [key:string]: any, import: string | Array<string> }\n`,
`Got: ${currentEntryPoint}`,
);
return;
}

entryProperty[entryPointName] = newEntryPoint;
Expand Down

0 comments on commit d8f4a82

Please sign in to comment.