Skip to content

profiling-node should not shim cjs globals #13259

Closed
@mbrevda

Description

@mbrevda

(sorry, the regular templates weren't working for me - github was returning an ambiguous error).

As I try updating to v8 (8.24.0), I'm encountering an issue where profiling-node tries to shim cjs globals without first checking if they are set. This is done via the @rollup/plugin-esm-shim package in the rollup config, resulting in some cjs specific globals being injected even if they are already defined (see lines 19-21).

This is an issue because some bundlers require defining these globals manually (where they require defining the cjs globals), causing the Sentry variables to error with SyntaxError: Identifier '__filename' has already been declared

I'd expect

that Sentry should not define global variables. If these variables are crucial and there is no other way to define them, respectfully check if they are set before defining them.

var __filename = cjsUrl.fileURLToPath(import.meta.url);
   ^

SyntaxError: Identifier '__filename' has already been declared
   at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
   at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:163:18)
   at callTranslator (node:internal/modules/esm/loader:430:14)
   at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:436:30)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions