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

Runtime error in version 3.3.1 #99

Open
bsrikanth-tby opened this issue Aug 18, 2024 · 2 comments
Open

Runtime error in version 3.3.1 #99

bsrikanth-tby opened this issue Aug 18, 2024 · 2 comments

Comments

@bsrikanth-tby
Copy link

In my angular project after upgrading @mongodb-js/charts-embed-dom to version 3.3.1 code compiles fine but I see this runtime error.

TypeError: _mongodb_js_charts_embed_dom__WEBPACK_IMPORTED_MODULE_0___default(...) is not a constructor

This runtime error is thrown exactly when the below code is run

const sdk = new EmbedSDK({ baseUrl: 'https://charts.mongodb.com' });

I'm using import statement like this in my angular component.

import EmbedSDK from '@mongodb-js/charts-embed-dom';

I'm using ES2022 module system in my tsconfig file. (compilerOptions.module: 'ES2022' and compilerOptions.target: 'ES2022')

image

Note: Just after upgrading to 3.3.1 I got an error mentioned in #98. To fix it I added this to webpack.config.js file.

experiments: {topLevelAwait: true, outputModule: true}, resolve: {fallback: { "crypto": false }}

@mhdejonge-tby
Copy link

The import is resulting in a promise that resolves to the module, instead of the module itself. We can work around that by reading the default field on the result of the promise. But obviously we'd like to use the import as intended.

@FredM7
Copy link

FredM7 commented Oct 11, 2024

The webpack experiments solution did not work for us. It broke the rest of our project unfortunately.

We ended up overriding the bson package as mentioned here: #98 (comment)

 "overrides": {
    "bson": "^4.5.2"
  }

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

3 participants