File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 88 * Typescript plugin docs: https://github.com/ezolenko/rollup-plugin-typescript2
99 */
1010
11+ import path from 'path' ;
12+
1113import commonjs from '@rollup/plugin-commonjs' ;
1214import deepMerge from 'deepmerge' ;
1315import 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 */
173176export function makeExcludeReplayPlugin ( ) {
174177 const replacementRegex = / \/ \/ _ _ R O L L U P _ E X C L U D E _ F R O M _ B U N D L E S _ B E G I N _ _ ( .| \n ) * _ _ R O L L U P _ E X C L U D E _ F R O M _ B U N D L E S _ E N D _ _ / 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
You can’t perform that action at this time.
0 commit comments