-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
es-module import syntax #13
Comments
Right! Well, PRs welcome! We’re using regexes here for the detection so that should be updated. And for the registration, there’s probably a way to turn the experimental modules flag on? |
the regex seems like a reasonable change, but getting the module flag turned on is certainly the first hurdle. since i'm using do you have a suggestion for that piece? |
My suggestion would be to wait before modules are stable and land 🤷♂️ I understand it’s a nice feature to have, but as it hasn’t landed, it’s subject to change! |
thats fair to an extent. the reason i'd like for my usage examples to use es-module syntax, though, is because that the intended use is to support bundling with either webpack or rollup. both of these expect module syntax for more optimal bundling, so i'd prefer to not de-optimize the examples. i'm certainly not using the flagged node behavior directly, but instead through babel. the transpilation buys me some stability, even if the native implementation changes. i assume there isn't currently a way to apply a babel config before the verification that the file is valid, but use the original source in the inclusion into the markdown? would such a feature be possible? i could see how something like that could be pretty disruptive, but figure its worth at least asking about. |
You can use Babel, but that doesn’t mean your users use it, or that the code you run in Babel works their environments! I’m also wondering if adding babel even works, we’re just loading the script with Maybe a fork of this plugin that uses babel is the way to go? 🤷♂️ |
when publishing packages, i always include both a common-js bundle as the with that said, a consumer of a package can import from a package built this way using either nothing wrong with the current situation, mostly just that it limits options. i can certainly understand ways that adding a transpilation step would not be a small change, so i was mostly curious if it was something you were considering or not on the radar. from the outside, the ast manipulation of babel and that of unified seem aligned enough that i wouldnt have been surprised if you were already considering it somehow, but can understand if thats not the case. since i dont have much detail to offer without investigation, i'm not sure how valuable this would be, but i do think that there is a way with babel to apply babel-register (the piece that does the transpilation) only if available in the project. beyond the conditional transpilation, the other benefit to that would be that it uses the version provided by the consumer of, in this case, remark-usage instead of introducing a dependency directly by this package that can conflict with versions already provided by the consumers. thanks for your continued input, but i can understand if you close as out of scope for now. |
Wellllll! Thanks for your patience. It took a bit to rewrite everything with Babel, and then the ES Modules weren’t that hard. I’ll release this soon. |
outstanding! thanks so much! i'm excited to give it a try |
i normally use es-module syntax for imports in my usage examples, but i love the idea of writing the example as a separate file that is lintable/testable. since es-module syntax isn't yet part of the language, it makes sense why it wouldn't work out of the box. any chance there is an existing way to apply babel-register or similar to support things like this?
The text was updated successfully, but these errors were encountered: