Skip to content

Commit 1923843

Browse files
committed
skip files other than browser index
1 parent 527f34d commit 1923843

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';
@@ -170,13 +172,16 @@ export function makeTSPlugin(jsVersion) {
170172
* Creates a Rollup plugin that removes all code between the `__ROLLUP_EXCLUDE_FROM_BUNDLES_BEGIN__`
171173
* and `__ROLLUP_EXCLUDE_FROM_BUNDLES_END__` comment guards. This is used to exclude the Replay integration
172174
* from the browser and browser+tracing bundles.
175+
* If we need to add more such guards in the future, we might want to refactor this into a more generic plugin.
173176
*/
174177
export function makeExcludeReplayPlugin() {
175178
const replacementRegex = /\/\/ __ROLLUP_EXCLUDE_FROM_BUNDLES_BEGIN__(.|\n)*__ROLLUP_EXCLUDE_FROM_BUNDLES_END__/gm;
179+
const browserIndexFilePath = path.resolve(__dirname, '../../packages/browser/src/index.ts');
176180

177181
const plugin = {
178-
transform(code) {
179-
if (!replacementRegex.test(code)) {
182+
transform(code, id) {
183+
const isBrowserIndexFile = path.resolve(id) === browserIndexFilePath;
184+
if (!isBrowserIndexFile || !replacementRegex.test(code)) {
180185
return null;
181186
}
182187

0 commit comments

Comments
 (0)