feat: refactoring the codebase to be ESM #558
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧰 Changes
Our
update-notifier
dependency currently has a CVE for its nestedgot
dependency. Unfortunatelyupdate-notifier
has moved to being ESM-only in v6 and we can't use it without moving this codebase over to ESM.That's this.
🐳 Problems
__dirname
is unavailable with in ES scope in Node. I've polyflled it in a few spots but I'm not sure if thats the right solution or if we could replace it with aprocess.cwd()
call instead.--watch
is currently broken because of the way that we're loading commands for the help screen. Jest will run tests the first time just fine but if you make any changes it'll fail with a "module is not a module" error because we're dynamically loading in commands withawait import()
and Jest has already town down its environment. Instead of futzing with this it might be best to move away from dynamic command loading and have anindex
file in thecmds/
directory that exports everything.type: module
inrdme
will force you to havetype: module
in any package that has this as a dependency, or if it's fine because nobody is doingrequire('rdme')
.chalk
. At all. I've had to do some module resolution in the config to get it working and it's unfortunately causing us to not be able to upgrade chalk to its latest ESM-only version.