Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular SSR Application Insights tracking: Module 'applicationinsights' used by 'apps/dummy-app/server.ts' is not ESM #1341

Closed
work933k opened this issue Jun 6, 2024 · 2 comments
Assignees

Comments

@work933k
Copy link

work933k commented Jun 6, 2024

When trying to use this module in an out-of-the-box Angular SSR application, errors are given about that the module is not ESM.
How can this be made to work?

▲ [WARNING] Constructing "ImportInTheMiddle" will crash at run-time because it's an import namespace object, not a constructor [call-import-namespace]

    node_modules/@azure/opentelemetry-instrumentation-azure-sdk/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:268:24:
      268 │       var esmHook = new ImportInTheMiddle([module_2.name], {
          ╵                         ~~~~~~~~~~~~~~~~~

  Consider changing "ImportInTheMiddle" to a default import instead:

    node_modules/@azure/opentelemetry-instrumentation-azure-sdk/node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:58:7:
      58 │ import * as ImportInTheMiddle from 'import-in-the-middle';
         │        ~~~~~~~~~~~~~~~~~~~~~~
         ╵        ImportInTheMiddle


▲ [WARNING] Constructing "ImportInTheMiddle" will crash at run-time because it's an import namespace object, not a constructor [call-import-namespace]

    node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:296:24:
      296 │       var esmHook = new ImportInTheMiddle([module_2.name], {
          ╵                         ~~~~~~~~~~~~~~~~~

  Consider changing "ImportInTheMiddle" to a default import instead:

    node_modules/@opentelemetry/instrumentation/build/esm/platform/node/instrumentation.js:58:7:
      58 │ import * as ImportInTheMiddle from 'import-in-the-middle';
         │        ~~~~~~~~~~~~~~~~~~~~~~
         ╵        ImportInTheMiddle


▲ [WARNING] Module 'applicationinsights' used by 'apps/platform-app/server.ts' is not ESM

  CommonJS or AMD dependencies can cause optimization bailouts.
  For more information see: https://angular.io/guide/build#configuring-commonjs-dependencies

@work933k work933k changed the title Angular SSR Application Insights tracking Angular SSR Application Insights tracking: Module 'applicationinsights' used by 'apps/dummy-app/server.ts' is not ESM Jun 6, 2024
@JacksonWeber
Copy link
Contributor

JacksonWeber commented Jun 13, 2024

@work933k I expect this issue to be resolved by open-telemetry/opentelemetry-js#4745 as other OpenTelemetry users were experiencing the same issue documented here in this issue: open-telemetry/opentelemetry-js#4717 which is marked as resolved by that PR. Since the fix was released in v0.52.0 of the experimental package which we're updating to in the Azure Monitor OpenTelemetry release today, this fix will be available upon the next release of this package.

@JacksonWeber JacksonWeber self-assigned this Jun 13, 2024
@work933k
Copy link
Author

By overriding a dependency, the error seems to be resolved.

...
  "overrides": {
    "@opentelemetry/instrumentation": "0.52.1"
  },
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants