-
Notifications
You must be signed in to change notification settings - Fork 12
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 filename issue #36
Comments
Yeah this is the limitation of macro in general because it runs at build time. In your case it's not possible to resolve Maybe we can improve the error message. This one is actually copied from |
Ok gotcha. Thanks for clarifying! |
Actually, if you write
It would pass, and the below not
By the way, is there any |
Ok good news: turns out it's possible to do with some work. It's basically similar with how webpack dynamic require works The bad news is there's a lot of cases to cover. I've made a proof of concept in #37, feel free to send alternative solution or improve my PR. |
Ok done, the dynamic value inside template literal is limited up to 2 variables (1 for directory name, and another one for filename). I think this should be more than enough and cover > 99% of use case when using dynamic import. I also added some notes in README regarding this limitation. You can try it out it #37. I plan to merge it on Monday and release it as v0.4.0 if all goes well |
I am trying this library because I have not been able to dynamically import markdown files successfully using create-react-app. I am trying to avoid ejecting.
I saw a snippet on this thead: facebook/create-react-app#3722
I am trying to load markdown files dynamically based on a prop
lang
like so:I get the following error:
raw.macro: There was a problem evaluating the value of the argument for the code: raw(
./${lang}About.md). If the value is dynamic, please make sure that its value is statically deterministic. Learn more:
What this error is saying is puzzling to me. If setting a path like this is not possible I understand, however if this is something that should be possible another way, would love to know how.
The text was updated successfully, but these errors were encountered: