Description
NPM package is producing side-effects, injecting itself in window.DD_RUM
at module level:
https://github.com/DataDog/browser-sdk/blob/main/packages/rum/src/entries/main.ts#L39
Just by importing this library it changes global namespace, which is something not desired when using a module system.
Is your feature request related to a problem? Please describe.
I have a big micro-frontend application where each part of the application was handling the initialization of v4 from this NPM package. I'm migrating it to a single global initialization using v5.
I could disable the initialization of the v4 in a central place while I gradually clean up, but, due to this issue, just by these parts of the application importing v4 it already messes up my v5 initialization. I'll have to first do a huge cleanup, losing monitoring in the process, only then to enable my global v5 init.
Describe the solution you'd like
I'd like this NPM package to not change the global scope.
As bonus it could even declare in its sideEffects: false
in its package.json
, which can increase the bundlers efficiency (although I don't expect improvements in this case). More info here: https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free
Describe alternatives you've considered
I tried to use the code bellow with my v5 initialization, to prevent it from being overwritten, but then the v4 imports start failing.
Object.defineProperty(window, 'DD_RUM', {
configurable: false,
enumerable: true,
writable: false,
value: window.DD_RUM,
});