- Notifications
You must be signed in to change notification settings - Fork51
feat: add support for ESM presets#544
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
travi commentedOct 3, 2023
these are great PRs and highlight the duplication we have for loading across these two plugins (which i'd like to resolve at some point). I wont be able to take a close look for a few days, but should be able to take a look friday at the latest. the one thing that i'm wondering without a deeper look is if there would be a way to cover the full loading of a cjs preset and esm preset with an integration test. it may be easier to do this in the core repo, but i wanted to put the thought out there in case you'd already considered options about this before i can look deeper. |
sheerlox commentedOct 3, 2023
are you thinking about creating a separate
I could work on a PR on the core repo to add that kind of test if you confirm that's the best option, let me know!
not in a hurry, I'm just glad I could find some time to work on this since we talked about it a few months ago 😄 |
sheerlox commentedOct 3, 2023
While doing research today, I found a "corner" case I didn't test that should fail with this PR. The issue is with loading a module from the parent module That means the current code probably won't be able to load conventional-commit presets installed along I didn't run into this issue while testing, since I'm using a relative path to my local preset, and test suites cannot detect that bug since they are using their own I'm working on a solution. |
travi commentedOct 8, 2023
yeah, i'm definitely leaning in this direction, but that would be a future step. no need to worry about this at this point other than maybe trying to be careful to keep the two current implementations as similar as possible and call out where they differ and how necessary any differences are.
i think that is the easiest place to add them today, but it has the downside of not catching issues locally within this package before publishing. with the additional use case you mentioned most recently, that highlights even further that an integration test that truly loaded the configs could be a helpful feedback loop. i wont hold up getting this merged based on existence of that type of test, but would be open to the addition if you think it helps give you feedback that would give you more confidence with the solution. if you decide it is worth it, let me know how i can be helpful |
sheerlox commentedOct 12, 2023
after encountering the error with importing a module from multiple levels above, I realized the task at hand was a bit more complex than expected and that it might be useful to others, so I decided to port the package also has the ability to load files regardless of their extension ( I've tested this version of the PRs with 4 different configurations: CJS /or/ ESM preset /and/ relative path /or/ npm module specifier. source for the new package is available atsheerlox/import-from-esm, please let me know what you think of this solution. |
sheerlox commentedOct 12, 2023
creating a
I think that type of test would be a great addition, and indeed would add to my confidence for this PR. but this is going to take time, and since I've been kicking issues down the road for weeks, I'd prefer if you could raise an issue to remember that needs to be done if that's okay for you. I've extensively tested the solution I'm proposing and I'm feeling confident about it. I always monitor my GH notifications closely, and I'll free some time right away if work needs to be done either on |
sheerlox commentedOct 13, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Note: I've made significant efforts to get the best |
befe208 to1576687Comparetravi commentedOct 27, 2023
sorry that i've been slow to get back to these. i dont think i'm going to get a chance today, but these are still on my radar |
travi commentedNov 5, 2023
i like the solution and appreciate that you'vementioned it in the thread for the original project. there is one detail about the package implementation that i'm curious about. it looks like you've vendored a manually tree-shaken version ofimport-meta-resolve. can you help me understand the benefit of vendoring it that way? the downside that stands out to me is that pulling in a potential vulnerability patch would now be more manual than getting an automated update PR from dependabot or renovate (and consumers would also not get a notification as easily that a vulnerability exists). |
sheerlox commentedNov 5, 2023
There are two reasons for this choice:
I see two different ways of resolving the issues you mentioned:
The first solution indeed seems to be the most straightforward and durable/stable solution. Please let me know your thoughts on this, and I'll raise an issue ASAP to discuss that with the maintainer. |
travi commentedNov 5, 2023
that makes sense. i overlooked this detail. i dont want a suggestion to improve that to hold up these PRs. if you could update the PRs with mainline once more to resolve conflicts, i'm good with getting these merged. they are great contributions and get us past what i think is our last ESM hurdle in core functionality.
this seems worthwhile to at least ask about. i wouldnt be concerned about the additional size, honestly. that is such a small difference and being more easily aware of potential vulnerabilities and general improvements greatly outweigh the size benefit, imho. if the answer is no for that package, it could make sense to continue to vendor, but would be interesting to hear their answer. |
4611164 to1c1b269Comparesheerlox commentedNov 5, 2023
Raisedwooorm/import-meta-resolve#18 to ask if exporting the |
🎉 This PR is included in version 12.1.0 🎉 The release is available on: Yoursemantic-release bot 📦🚀 |
sheerlox commentedNov 6, 2023
Turns out exporting the |
Uh oh!
There was an error while loading.Please reload this page.
This PR adds support for loading pure ESM presets. This was not previously possible because
import-fromusescreateRequireunder the hood.In order to replace it, I've created anES module loader that abstracts the preset loading logic for
semantic-releaserepos (first tries to hitnode_modules, then if not found tries to hit the relative path from the current working directory).I've tested these changes locally on thehttps://github.com/insurgent-lab/conventional-changelog-preset repo (which is a preset but also uses its current version for releasing with
semantic-release), both with the current latest version and the ESM version (which you can find in therefactor/esmbranch since it's probably the only conventional-changelog ESM preset at this time).Related
cc@travi 😉