Skip to content

Commit 9d14781

Browse files
committed
STASH
1 parent 2ee4434 commit 9d14781

File tree

7 files changed

+1884
-1547
lines changed

7 files changed

+1884
-1547
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"jest": "^24.7.1",
6161
"karma-browserstack-launcher": "^1.5.1",
6262
"karma-firefox-launcher": "^1.1.0",
63-
"lerna": "3.13.4",
63+
"lerna": "^4.0.0",
6464
"madge": "4.0.2",
6565
"mocha": "^6.1.4",
6666
"npm-run-all": "^4.1.2",

packages/browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"rollup-plugin-typescript2": "^0.21.0",
5252
"sinon": "^7.3.2",
5353
"typescript": "3.7.5",
54-
"webpack": "^4.30.0"
54+
"webpack": "^5"
5555
},
5656
"scripts": {
5757
"build": "run-s build:es5 build:esm build:bundle",

packages/nextjs/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
"@sentry/tracing": "6.13.3",
2525
"@sentry/utils": "6.13.3",
2626
"@sentry/webpack-plugin": "1.17.3",
27-
"tslib": "^1.9.3"
27+
"tslib": "^1.9.3",
28+
"webpack-inject-plugin": "1.5.4"
2829
},
2930
"devDependencies": {
3031
"@sentry/types": "6.13.3",
31-
"@types/webpack": "^5.28.0",
32+
"@types/webpack": ">= 4.41.31",
3233
"eslint": "7.20.0",
3334
"next": "10.1.3",
3435
"rimraf": "3.0.2"

packages/nextjs/src/config/webpack.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { default as SentryWebpackPlugin } from '@sentry/webpack-plugin';
44
import * as fs from 'fs';
55
import * as path from 'path';
66
import { DefinePlugin, WebpackPluginInstance } from 'webpack';
7+
import { default as InjectPlugin, ENTRY_ORDER } from 'webpack-inject-plugin';
78

89
import {
910
BuildContext,
@@ -92,6 +93,13 @@ export function constructWebpackConfigFunction(
9293
newConfig.plugins.push(new DefinePlugin({ __rewriteFramesDistDir__: distDir }));
9394
}
9495

96+
newConfig.plugins.push(
97+
(new InjectPlugin(() => `global.__rewriteFramesDistDir__ = ${distDir};`, {
98+
entryName: shouldAddSentryToEntryPoint, // Limit the injected code to only the entry w/ this name
99+
entryOrder: ENTRY_ORDER.First, // Make the injected code be the first entry point
100+
}) as unknown) as WebpackPluginInstance, // necessary because of a mismatch in @types/webpack versions between this plugin
101+
);
102+
95103
// Enable the Sentry plugin (which uploads source maps to Sentry when not in dev) by default
96104
const enableWebpackPlugin = buildContext.isServer
97105
? !userNextConfig.sentry?.disableServerWebpackPlugin

packages/nextjs/src/index.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function sdkAlreadyInitialized(): boolean {
4646
return !!hub.getClient();
4747
}
4848

49+
debugger;
50+
4951
// webpack will replace this placeholder at build time
5052
const SOURCEMAP_FILENAME_REGEX = new RegExp(escapeStringForRegex('__rewriteFramesDistDir__'));
5153

packages/nextjs/test/config.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ describe('webpack config', () => {
353353
incomingWebpackBuildContext: getBuildContext('server', mightHaveDistDir),
354354
});
355355

356+
// testing this separately from the definition values so that if this tests fails, it's clear why
356357
expect(finalWebpackConfig.plugins).toEqual(expect.arrayContaining([expect.any(DefinePlugin)]));
357358

358359
const definePluginInstance = findWebpackPlugin(finalWebpackConfig, 'DefinePlugin') as DefinePlugin;

0 commit comments

Comments
 (0)