angular-cli: ERROR: Top-level await is not available in the configured target environment

Which @angular/* package(s) are the source of the bug?

Don’t known / other

Is this a regression?

Yes

Description

17349 │ /******/ __webpack_exports__ = globalThis.pdfjsLib = await (globalThis.pdfjsLibPromise = __webpack_exports__);


01:55:45 [vite] error while updating dependencies:
Error: Build failed with 1 error:
node_modules/pdfjs-dist/build/pdf.mjs:17349:53: ERROR: Top-level await is not available in the configured target environment ("chrome118.0", "edge118.0", "firefox115.0", "
ios16.0", "safari16.0" + 7 overrides)

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

@angular-devkit/architect       0.1602.10
@angular-devkit/build-angular   16.2.10
@angular-devkit/core            16.2.10
@angular-devkit/schematics      16.2.10
@angular/cli                    16.2.10
@schematics/angular             16.2.10
rxjs                            7.8.1
typescript                      4.9.5
zone.js                         0.13.3

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 7 months ago
  • Reactions: 1
  • Comments: 18 (3 by maintainers)

Most upvoted comments

@madurapa can you please share the complete config file. I’m not sure where to add optimizeDeps and build.

export default defineConfig({
    optimizeDeps: {
        esbuildOptions: {
            target: 'esnext'
        }
    },
    build: {
        target: 'esnext'
    },
});

Put your config if you find it difficult to edit, I can include those values and past here

For those who experience the same issue in the both dev and build commands, add the following

// vite.config.js
optimizeDeps: {
  esbuildOptions: {
    target: 'esnext'
  }
},
build: {
  target: 'esnext'
}