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.
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
Improve CJS/ESM interoperability support #345
Improve CJS/ESM interoperability support #345
Changes from 4 commits
d27e77c
18906e7
99478d8
e00391e
c8e887c
cbdce84
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we just
fs.rename
this? Why do we need this fancy helper?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fs.rename
doesn't handle moving files to directories that don't exist, nor have any sort of recursive renaming AFAIK. So this function was created to recursively traverse a directory tree and create required directories before moving a file.However, in commit c8e887c I've removed this function in an attempt to simplify things.
Instead of outputting the
*.d.ts
type files intodist/esm/*
and then using themoveDir
helper to get them over todist/types/*
. Now when outputting ESM I output the types straight todist/types/*
and then only need to worry about movingdist/index.js
todist/esm/index.js
.We get to the same place as before, but with less code for us to maintain and a little more readable as we only are moving a single file instead of traversing a directory tree moving many files. Happy for feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems strange that we'd drop errors here—I think I'd like it to crash. Could we delete this function and just use
fs.rename
?