Skip to content

Commit c65a052

Browse files
authored
build: separate content scripts build to exclude sentry plugin (#1990)
Sentry release tracking pollutes global scope by declaring 'e' variable, which can cause conflicts with dapp code when used in the injected script. We were NOT using sentry in the content scripts, so this has no functional effect. The reason that this code was injected is because we were using the same webpack build configuration for both: Lace app scripts and content scripts. Webpack plugins extend compiler behavior globally (applies to all entrypoints).
1 parent e3c67cb commit c65a052

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

apps/browser-extension-wallet/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
"scripts": {
2828
"build": "run-s cleanup:dist build:project",
2929
"build:app": "NODE_OPTIONS='--openssl-legacy-provider' run -T webpack --config webpack.app.${WEBPACK_ENV:-prod}.js --progress",
30+
"build:cs": "NODE_OPTIONS='--openssl-legacy-provider' run -T webpack --config webpack.cs.${WEBPACK_ENV:-prod}.js --progress",
3031
"build:dev": "WEBPACK_ENV=dev yarn build",
3132
"build:firefox": "BROWSER=firefox yarn build",
3233
"build:firefox:dev": "WEBPACK_ENV=dev yarn build:firefox",
33-
"build:project": "run-p build:sw build:app",
34+
"build:project": "run-p build:sw build:app build:cs",
3435
"build:sw": "NODE_OPTIONS='--openssl-legacy-provider' run -T webpack --config webpack.sw.${WEBPACK_ENV:-prod}.js --progress",
3536
"cleanup": "run-p cleanup:*",
3637
"cleanup:dist": "rm -rf dist",

apps/browser-extension-wallet/webpack.common.app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ module.exports = () =>
2626
entry: {
2727
popup: withMaybeSentry(path.join(__dirname, 'src/index-popup.tsx')),
2828
options: withMaybeSentry(path.join(__dirname, 'src/index-options.tsx')),
29-
content: path.join(__dirname, 'src/lib/scripts/background/content.ts'),
30-
inject: path.join(__dirname, 'src/lib/scripts/background/inject.ts'),
3129
dappConnector: withMaybeSentry(path.join(__dirname, 'src/index-dapp-connector.tsx')),
3230
['trezor-content-script']: path.join(__dirname, 'src/lib/scripts/trezor/trezor-content-script.ts'),
3331
['trezor-usb-permissions']: withMaybeSentry(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const path = require('path');
2+
const { merge } = require('webpack-merge');
3+
const commonConfig = require('./webpack.common');
4+
5+
require('dotenv-defaults').config({
6+
path: './.env',
7+
encoding: 'utf8',
8+
defaults: process.env.BUILD_DEV_PREVIEW === 'true' ? './.env.developerpreview' : './.env.defaults'
9+
});
10+
11+
module.exports = () =>
12+
merge(commonConfig(), {
13+
entry: {
14+
content: path.join(__dirname, 'src/lib/scripts/background/content.ts'),
15+
inject: path.join(__dirname, 'src/lib/scripts/background/inject.ts')
16+
},
17+
output: {
18+
path: path.join(__dirname, 'dist/app'),
19+
filename: '[name].js',
20+
// the following setting is required for SRI to work:
21+
crossOriginLoading: 'anonymous'
22+
},
23+
experiments: {
24+
syncWebAssembly: true
25+
}
26+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { merge } = require('webpack-merge');
2+
3+
const commonDevConfig = require('./webpack.common.dev');
4+
const commonCsConfig = require('./webpack.common.cs');
5+
require('dotenv-defaults').config({
6+
path: './.env',
7+
encoding: 'utf8',
8+
defaults: process.env.BUILD_DEV_PREVIEW === 'true' ? './.env.developerpreview' : './.env.defaults'
9+
});
10+
11+
module.exports = (env) => merge(commonDevConfig({ devServerPort: 3001 })(env), commonCsConfig());
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { merge } = require('webpack-merge');
2+
const commonProdConfig = require('./webpack.common.prod');
3+
const commonCsConfig = require('./webpack.common.cs');
4+
5+
require('dotenv-defaults').config({
6+
path: './.env',
7+
encoding: 'utf8',
8+
defaults: process.env.BUILD_DEV_PREVIEW === 'true' ? './.env.developerpreview' : './.env.defaults'
9+
});
10+
11+
module.exports = () =>
12+
merge(commonProdConfig(), commonCsConfig(), {
13+
optimization: {
14+
splitChunks: {
15+
maxSize: 4000000,
16+
cacheGroups: {
17+
vendors: {
18+
test: /[/\\]node_modules[/\\]/,
19+
enforce: true,
20+
priority: -20,
21+
chunks: 'async',
22+
reuseExistingChunk: true
23+
}
24+
}
25+
}
26+
}
27+
});

0 commit comments

Comments
 (0)