Issue
I get a top-level-await error upon when importing BSON:
./node_modules/bson/lib/bson.mjs - Error: Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
File was processed with these loaders:
* ./node_modules/@angular-devkit/build-angular/src/tools/babel/webpack-loader.js
* ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
I'm importing the library inside my component like so:
import { ObjectId } from 'bson';
Been searching everywhere but can't find an answer.
Solution
You can update your angular builder to esbuild:
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser-esbuild",
Still experimental in Angular, it'll be tagged as stable with the Angular 17 release.
Answered By - Gérôme Grignon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.