angular/angular-cli

Top-level await is not available in the configured target environment

ChellappanRajan opened this issue · 4 comments

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

Description

Angular is throwing a 'Top-level await is not available' error when attempting to import the pdf-dist library.

What I have tried

I attempted to proceed with zoneLess, but the same error persists.

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome123.0", "edge123.0", "firefox115.0", "ios16.0", "node22.0.0", "safari16.0" + 5 overrides)

Minimal Reproduction

https://github.com/ChellappanRajan/pdf-dist.git

Exception or Error

✘ [ERROR] Top-level await is not available in the configured target environment ("chrome123.0", "edge123.0", "firefox115.0", "ios16.0", "node22.0.0", "safari16.0" + 5 overrides)

    node_modules/pdfjs-dist/build/pdf.mjs:19764:53:
      19764 │ ...s__ = globalThis.pdfjsLib = await (globalThis.pdfjsLibPromis..

Your Environment

^18.0.0-next.0

Anything else relevant?

No response

Duplicate of #27554

Hello @alan-agius4 I noticed that the issue you mentioned have been closed as duplicates. Does this mean Angular won't be compatible with these libraries? Thank you for your assistance.

Currently, we're not considering enabling this feature due to concerns regarding bundling correctness and potential optimization challenges, such as cross-module code motion.

That being said, we do plan to discuss this matter during our next team sync.

Currently, we're not considering enabling this feature due to concerns regarding bundling correctness and potential optimization challenges, such as cross-module code motion.

That being said, we do plan to discuss this matter during our next team sync.

Thanks @alan-agius4 👍