Skip to content

Commit 56b0cf0

Browse files
committed
pull replacement of browser bundle flag into central config
1 parent e575196 commit 56b0cf0

File tree

6 files changed

+27
-60
lines changed

6 files changed

+27
-60
lines changed

packages/browser/rollup.config.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { terser } from 'rollup-plugin-terser';
22
import typescript from 'rollup-plugin-typescript2';
33
import resolve from '@rollup/plugin-node-resolve';
4-
import replace from '@rollup/plugin-replace';
54

6-
import { makeLicensePlugin, paths } from '../../rollup.config';
5+
import { makeLicensePlugin, markAsBrowserBuild, paths } from '../../rollup.config';
76

87
const licensePlugin = makeLicensePlugin();
98

@@ -49,16 +48,8 @@ const plugins = [
4948
},
5049
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
5150
}),
52-
replace({
53-
// don't replace `__placeholder__` where it's followed immediately by a single `=` (to prevent ending up
54-
// with something of the form `let "replacementValue" = "some assigned value"`, which would cause a
55-
// syntax error)
56-
preventAssignment: true,
57-
// the replacements to make
58-
values: {
59-
__SENTRY_BROWSER_BUNDLE__: true,
60-
},
61-
}),
51+
// replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code
52+
markAsBrowserBuild,
6253
resolve({
6354
mainFields: ['module'],
6455
}),

packages/integrations/rollup.config.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { terser } from 'rollup-plugin-terser';
44
import typescript from 'rollup-plugin-typescript2';
55
import resolve from '@rollup/plugin-node-resolve';
66
import commonjs from '@rollup/plugin-commonjs';
7-
import replace from '@rollup/plugin-replace';
87

9-
import { paths } from '../../rollup.config';
8+
import { markAsBrowserBuild, paths } from '../../rollup.config';
109

1110
const terserInstance = terser({
1211
mangle: {
@@ -35,16 +34,8 @@ const plugins = [
3534
},
3635
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
3736
}),
38-
replace({
39-
// don't replace `__placeholder__` where it's followed immediately by a single `=` (to prevent ending up
40-
// with something of the form `let "replacementValue" = "some assigned value"`, which would cause a
41-
// syntax error)
42-
preventAssignment: true,
43-
// the replacements to make
44-
values: {
45-
__SENTRY_BROWSER_BUNDLE__: true,
46-
},
47-
}),
37+
// replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code
38+
markAsBrowserBuild,
4839
resolve({
4940
mainFields: ['module'],
5041
}),

packages/tracing/rollup.config.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import typescript from 'rollup-plugin-typescript2';
22
import resolve from '@rollup/plugin-node-resolve';
3-
import replace from '@rollup/plugin-replace';
43

5-
import { makeLicensePlugin, paths, terserPlugin } from '../../rollup.config';
4+
import { makeLicensePlugin, markAsBrowserBuild, paths, terserPlugin } from '../../rollup.config';
65

76
const licensePlugin = makeLicensePlugin('@sentry/tracing & @sentry/browser');
87

@@ -19,16 +18,8 @@ const plugins = [
1918
},
2019
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
2120
}),
22-
replace({
23-
// don't replace `__placeholder__` where it's followed immediately by a single `=` (to prevent ending up
24-
// with something of the form `let "replacementValue" = "some assigned value"`, which would cause a
25-
// syntax error)
26-
preventAssignment: true,
27-
// the replacements to make
28-
values: {
29-
__SENTRY_BROWSER_BUNDLE__: true,
30-
},
31-
}),
21+
// replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code
22+
markAsBrowserBuild,
3223
resolve({
3324
mainFields: ['module'],
3425
}),

packages/vue/rollup.config.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import typescript from 'rollup-plugin-typescript2';
22
import resolve from '@rollup/plugin-node-resolve';
3-
import replace from '@rollup/plugin-replace';
43

5-
import { makeLicensePlugin, paths, terserPlugin } from '../../rollup.config';
4+
import { makeLicensePlugin, markAsBrowserBuild, paths, terserPlugin } from '../../rollup.config';
65

76
const licensePlugin = makeLicensePlugin();
87

@@ -19,16 +18,8 @@ const plugins = [
1918
},
2019
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
2120
}),
22-
replace({
23-
// don't replace `__placeholder__` where it's followed immediately by a single `=` (to prevent ending up
24-
// with something of the form `let "replacementValue" = "some assigned value"`, which would cause a
25-
// syntax error)
26-
preventAssignment: true,
27-
// the replacements to make
28-
values: {
29-
__SENTRY_BROWSER_BUNDLE__: true,
30-
},
31-
}),
21+
// replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code
22+
markAsBrowserBuild,
3223
resolve({
3324
mainFields: ['module'],
3425
}),

packages/wasm/rollup.config.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import typescript from 'rollup-plugin-typescript2';
22
import resolve from '@rollup/plugin-node-resolve';
3-
import replace from '@rollup/plugin-replace';
43

5-
import { paths, terserPlugin } from '../../rollup.config';
4+
import { paths, markAsBrowserBuild, terserPlugin } from '../../rollup.config';
65

76
const plugins = [
87
typescript({
@@ -17,16 +16,8 @@ const plugins = [
1716
},
1817
include: ['*.ts+(|x)', '**/*.ts+(|x)', '../**/*.ts+(|x)'],
1918
}),
20-
replace({
21-
// don't replace `__placeholder__` where it's followed immediately by a single `=` (to prevent ending up
22-
// with something of the form `let "replacementValue" = "some assigned value"`, which would cause a
23-
// syntax error)
24-
preventAssignment: true,
25-
// the replacements to make
26-
values: {
27-
__SENTRY_BROWSER_BUNDLE__: true,
28-
},
29-
}),
19+
// replace `__SENTRY_BROWSER_BUNDLE__` with `true` to enable treeshaking of non-browser code
20+
markAsBrowserBuild,
3021
resolve({
3122
mainFields: ['module'],
3223
}),

rollup.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import license from 'rollup-plugin-license';
6+
import replace from '@rollup/plugin-replace';
67
import { terser } from 'rollup-plugin-terser';
78

89
export const paths = {
@@ -46,3 +47,14 @@ export const terserPlugin = terser({
4647
comments: false,
4748
},
4849
});
50+
51+
export const markAsBrowserBuild = replace({
52+
// don't replace `__placeholder__` where it's followed immediately by a single `=` (to prevent ending up
53+
// with something of the form `let "replacementValue" = "some assigned value"`, which would cause a
54+
// syntax error)
55+
preventAssignment: true,
56+
// the replacement to make
57+
values: {
58+
__SENTRY_BROWSER_BUNDLE__: true,
59+
},
60+
});

0 commit comments

Comments
 (0)