Recursively export constants from modules#10049
Conversation
This might be a reason why regular `let` might be problematic in modules. In the case of `const`, we can grab the value directly from the parsed results, but with `let`, we might need to evaluate the module.
|
Just discovered that when you import constants with |
amtoine
left a comment
There was a problem hiding this comment.
this looks like a very good PR to me, very good job 👌
and i love your examples 🙏 ❤️
i just have a question about one test 😏
|
also, maybe we should wait for after the release at this point? |
|
I'd personally include it in the release, since the original export const implementation had some rough edges that are easy to encounter. We could ship with a more polished experience. |
85fa2c5 to
db7d162
Compare
|
thanks for answering my thread @kubouch 🙏 |
|
Thanks! LGTM! I've tried and played with it, and it works pretty good! |
|
let's land this before we freeze for the release for real 🥳 |
…tern` (#14920) # Description This PR replaces most of the constants in `ResolvedImportPattern` from values to VarIds, this has benefits of: 1. less duplicated variables in state 2. precise span of variable, for example when calling `goto def` on a const imported by the `use` command, this allows it to find the original definition, instead of where the `use` command is. Note that the logic is different here for nested submodules, not all values are flattened and propagated to the outmost record variable, but I didn't find any differences in real world usage. I noticed that it was changed from `VarId` to `Value` in #10049. Maybe @kubouch can find some edge cases where this PR fails to work as expected. In my view, the record constants for `ResolvedImportPattern` should even reduced to single entry, if not able to get rid of. # User-Facing Changes # Tests + Formatting # After Submitting
Description
#9773 introduced constants to modules and allowed to export them, but only within one level. This PR:
Should unblock #9678
Example:
Limitation 1:
Considering the above
spammodule, attempting to geteggs baconfromspammodule doesn't work directly:Workaround (for example):
I'm thinking I'll just leave it in, as you can easily work around this. It is also a limitation of the import pattern in general, not just constants.
Limitation 2:
overlay usesuccessfully imports the constants, butoverlay hidedoes not hide them, even though it seems to hide normal variables successfully. This needs more investigation.User-Facing Changes
Allows recursive constant exports from submodules.
Tests + Formatting
After Submitting