-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
formatjs not compatible with ES Modules #2961
Comments
do you have a repro repo? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm hitting this too, I will try to produce a minimal repro example tomorrow. The issue is this is not a standard import - you can't import JSON (unless bundling your code with a tool like webpack): import * as digitMapping from './digit-mapping.json' |
longlho
added a commit
that referenced
this issue
Jun 26, 2021
longlho
added a commit
that referenced
this issue
Jun 26, 2021
longlho
added a commit
that referenced
this issue
Jun 26, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried to integrate the formatjs library in my project, but I ran into problems because of the following:
The script that uses the library is loaded as a module. However, this is not working with the browser throwing the following error:
🚧 Browser logs on Chromium:
TypeError: Failed to fetch dynamically imported module
🚧 Browser logs on Webkit:
TypeError: 'application/json' is not a valid JavaScript MIME type.
🚧 Browser logs on Firefox:
TypeError: error loading dynamically imported module
The error is caused by the line:
digitMapping = tslib_1.__importStar(require("./digit-mapping.json"));
Modules are expecting js files and do not consider
json
a valid JavaScript MIME type.I believe it could be beneficial to multiple people to have the imports changed so that the library could be loaded as module.
Thanks!
The text was updated successfully, but these errors were encountered: