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

Dynamic Import JSON not working #3557

Closed
ad1992 opened this issue Dec 18, 2023 · 2 comments
Closed

Dynamic Import JSON not working #3557

ad1992 opened this issue Dec 18, 2023 · 2 comments

Comments

@ad1992
Copy link

ad1992 commented Dec 18, 2023

Hi I am trying to using ESBuild for creating the ESM build of Excalidraw. However dynamic import json doesn't seem to work even though its mention in docs (The support for with was released in 0.19.7

const  currentLangData = await import(`./locales/${currentLang.code}.json`, {
    with: { type: "json" },
  });

This gets converted to 👇🏻

 currentLangData = await globImport_locales_json(`./locales/${currentLang.code}.json`);

This code throws error -> "chunk-EGAXOKDI.js:7443 Failed to load language en: globImport_locales_json is not defined" .

EDIT

However, If I hardcode the string path then it works, so probably the root cause is the path is dynamic and that's why its not working.

Is there anything I am missing to make Dynamic Import JSON work with dynamic paths ?

Thank you!

@evanw
Copy link
Owner

evanw commented Dec 19, 2023

Thank you for the report. I'm hoping that this was #3319, which was just fixed. Please update esbuild and try again.

If that didn't fix it, then I'm going to need a way to reproduce your issue as I unfortunately am not able to fix your issue without a way to reproduce it. Please provide a way for me to reproduce your issue.

@ad1992
Copy link
Author

ad1992 commented Dec 19, 2023

@evanw you are awesome, Thanks for releasing the fix so quickly. It works now 🚀

@ad1992 ad1992 closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants