Skip to content

Commit 196a8a5

Browse files
committed
skip files other than browser index
1 parent 99f805e commit 196a8a5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

rollup/plugins/bundlePlugins.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* Typescript plugin docs: https://github.com/ezolenko/rollup-plugin-typescript2
99
*/
1010

11+
import path from 'path';
12+
1113
import commonjs from '@rollup/plugin-commonjs';
1214
import deepMerge from 'deepmerge';
1315
import license from 'rollup-plugin-license';
@@ -169,13 +171,16 @@ export function makeTSPlugin(jsVersion) {
169171
* Creates a Rollup plugin that removes all code between the `__ROLLUP_EXCLUDE_FROM_BUNDLES_BEGIN__`
170172
* and `__ROLLUP_EXCLUDE_FROM_BUNDLES_END__` comment guards. This is used to exclude the Replay integration
171173
* from the browser and browser+tracing bundles.
174+
* If we need to add more such guards in the future, we might want to refactor this into a more generic plugin.
172175
*/
173176
export function makeExcludeReplayPlugin() {
174177
const replacementRegex = /\/\/ __ROLLUP_EXCLUDE_FROM_BUNDLES_BEGIN__(.|\n)*__ROLLUP_EXCLUDE_FROM_BUNDLES_END__/gm;
178+
const browserIndexFilePath = path.resolve(__dirname, '../../packages/browser/src/index.ts');
175179

176180
const plugin = {
177-
transform(code) {
178-
if (!replacementRegex.test(code)) {
181+
transform(code, id) {
182+
const isBrowserIndexFile = path.resolve(id) === browserIndexFilePath;
183+
if (!isBrowserIndexFile || !replacementRegex.test(code)) {
179184
return null;
180185
}
181186

0 commit comments

Comments
 (0)