Skip to content

Commit 10a021e

Browse files
committed
centralize standard terser plugin
1 parent bdbbe73 commit 10a021e

File tree

4 files changed

+29
-53
lines changed

4 files changed

+29
-53
lines changed

packages/tracing/rollup.config.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
1-
import { terser } from 'rollup-plugin-terser';
21
import typescript from 'rollup-plugin-typescript2';
32
import license from 'rollup-plugin-license';
43
import resolve from '@rollup/plugin-node-resolve';
54
import replace from '@rollup/plugin-replace';
65

7-
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
6+
import { terserPlugin } from '../../rollup.config';
87

9-
const terserInstance = terser({
10-
mangle: {
11-
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
12-
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
13-
// We need those full names to correctly detect our internal frames for stripping.
14-
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
15-
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
16-
properties: {
17-
regex: /^_[^_]/,
18-
},
19-
},
20-
output: {
21-
comments: false,
22-
},
23-
});
8+
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
249

2510
const paths = {
2611
'@sentry/utils': ['../utils/src'],
@@ -98,6 +83,6 @@ export default [
9883
file: 'build/bundle.tracing.min.js',
9984
},
10085
// Uglify has to be at the end of compilation, BUT before the license banner
101-
plugins: bundleConfig.plugins.slice(0, -1).concat(terserInstance).concat(bundleConfig.plugins.slice(-1)),
86+
plugins: bundleConfig.plugins.slice(0, -1).concat(terserPlugin).concat(bundleConfig.plugins.slice(-1)),
10287
},
10388
];

packages/vue/rollup.config.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
1-
import { terser } from 'rollup-plugin-terser';
21
import typescript from 'rollup-plugin-typescript2';
32
import license from 'rollup-plugin-license';
43
import resolve from '@rollup/plugin-node-resolve';
54
import replace from '@rollup/plugin-replace';
65

7-
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
6+
import { terserPlugin } from '../../rollup.config';
87

9-
const terserInstance = terser({
10-
mangle: {
11-
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
12-
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
13-
// We need those full names to correctly detect our internal frames for stripping.
14-
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
15-
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
16-
properties: {
17-
regex: /^_[^_]/,
18-
},
19-
},
20-
output: {
21-
comments: false,
22-
},
23-
});
8+
const commitHash = require('child_process').execSync('git rev-parse --short HEAD', { encoding: 'utf-8' }).trim();
249

2510
const paths = {
2611
'@sentry/utils': ['../utils/src'],
@@ -98,6 +83,6 @@ export default [
9883
file: 'build/bundle.vue.min.js',
9984
},
10085
// Uglify has to be at the end of compilation, BUT before the license banner
101-
plugins: bundleConfig.plugins.slice(0, -1).concat(terserInstance).concat(bundleConfig.plugins.slice(-1)),
86+
plugins: bundleConfig.plugins.slice(0, -1).concat(terserPlugin).concat(bundleConfig.plugins.slice(-1)),
10287
},
10388
];

packages/wasm/rollup.config.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
import { terser } from 'rollup-plugin-terser';
21
import typescript from 'rollup-plugin-typescript2';
32
import resolve from '@rollup/plugin-node-resolve';
43
import replace from '@rollup/plugin-replace';
54

6-
const terserInstance = terser({
7-
mangle: {
8-
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
9-
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
10-
// We need those full names to correctly detect our internal frames for stripping.
11-
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
12-
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
13-
properties: {
14-
regex: /^_[^_]/,
15-
},
16-
},
17-
output: {
18-
comments: false,
19-
},
20-
});
5+
import { terserPlugin } from '../../rollup.config';
216

227
const plugins = [
238
typescript({
@@ -74,7 +59,7 @@ function loadAllIntegrations() {
7459
},
7560
{
7661
extension: '.min.js',
77-
plugins: [...plugins, terserInstance],
62+
plugins: [...plugins, terserPlugin],
7863
},
7964
].forEach(build => {
8065
builds.push({

rollup.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Shared config used by individual packages' Rollup configs
3+
*/
4+
5+
import { terser } from 'rollup-plugin-terser';
6+
7+
export const terserPlugin = terser({
8+
mangle: {
9+
// captureExceptions and captureMessage are public API methods and they don't need to be listed here
10+
// as mangler doesn't touch user-facing thing, however sentryWrapped is not, and it would be mangled into a minified version.
11+
// We need those full names to correctly detect our internal frames for stripping.
12+
// I listed all of them here just for the clarity sake, as they are all used in the frames manipulation process.
13+
reserved: ['captureException', 'captureMessage', 'sentryWrapped'],
14+
properties: {
15+
regex: /^_[^_]/,
16+
},
17+
},
18+
output: {
19+
comments: false,
20+
},
21+
});

0 commit comments

Comments
 (0)