Skip to content

[Bug]: ReferenceError in Elastic APM agent when lazyBarrel is enabled #9713

Description

@carey

Reproduction link or steps

https://repl.rolldown.rs/#eNptUO1KxTAMfZWSP1OYHYIizD+ir1GEsGWXapuOttOrY+9u2uHHlfurTc7JOTlZYYJ+BcsjHXVO5c/Q/9YtDKX0c4hZNQ/kMGU7dDj7q7j45l4IBH2OC20txODcGN5ZD4Ene/ijdwY5UV7VSJNleqqw2tQUg1fN91hj2DAdK1WIuLj6/gxcrIaVsjwvuVe7pPaUUddWW8CuUyJA0XrijK4XS4efH48YI0k1oUukNsPbpWGQLDMOr3gg/ZKCBNhTnPT2/auxgZFmkpPxYCkZEPHSLsD/ixXQwPOtvr7TNwYKrZgWTzF9E0WHmVKG7Qulyorh

The reproduction is simply to process

import "@elastic/apm-rum";

with no other configuration, and to load the bundled code in any browser on in Node.js.

What is expected?

Importing the bundled code in a browser should succeed, setting window.elasticApm as a side-effect.

What is actually happening?

Just importing the bundled code in any browser or in Node.js fails with a ReferenceError:

Uncaught ReferenceError: serviceCreators is not defined
    registerServices http://localhost:8000/dist/elastic.js:2024
    createServiceFactory http://localhost:8000/dist/elastic.js:2373
    getApmBase http://localhost:8000/dist/elastic.js:2528
    <anonymous> http://localhost:8000/dist/elastic.js:2532

This error occurs in node_modules/@elastic/apm-rum-core/dist/es/performance-monitoring/index.js, where only _serviceCreators and serviceCreators$1 are in scope if lazyBarrel is enabled.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 2.85 GB / 15.69 GB
  Binaries:
    Node: 24.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.9.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 149.0.7827.103
    Edge: Chromium (140.0.3485.54)
    Firefox: 151.0.4 - C:\Program Files\Mozilla Firefox\firefox.exe
  npmPackages:
    rolldown: ^1.1.0 => 1.1.0

Any additional comments?

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions