-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
refactor(remark-plugin-npm2yarn): migrate package to TS #5931
Conversation
✔️ [V2] 🔨 Explore the source changes: b894444 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/618e6636d6c1a7000844b3de 😎 Browse the preview: https://deploy-preview-5931--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5931--docusaurus-2.netlify.app/ |
Wow, thanks! LGTM 👍 It's just reconciling the types for the config file that's left. |
const {children: result} = | ||
(transformer(node.children[index], _) as Parent) ?? {}; |
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.
kinda hacky to return a dummy node with the list of children and then destructuring it but it's the minimal change to make transformer
a valid unified Transformer
type. don't know if that's alright though
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.
Actually can we use unist-util-visit
for this? I'm not sure why we don't now
Like this: https://github.com/smack0202/luxdocs/blob/main/src/remark/video.js
Thanks, made some refactors so things look better. All the type assertions & typeguards are pretty justified. Since the behavior is still the same and we don't have many edge cases for this, I'll merge |
|
||
// To continue supporting `require('npm2yarn')` without the `.default` ㄟ(▔,▔)ㄏ | ||
// TODO change to export default after migrating to ESM | ||
export = plugin; |
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.
That's annoying me due to not working with Babel, isn't there a better way to handle that interop problem?
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.
There is:
// To trick Babel & tsc
export default plugin;
// To actual do the export
module.exports = plugin;
This will be transpiled as:
exports.default = plugin;
module.exports = plugin;
Because exports
is an alias for module.exports
, the last line decouples the exports
reference from module.exports
and makes the second last line useless. However this makes everyone happy
Motivation
#5817
WIP
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Preview still shows the same result: https://deploy-preview-5931--docusaurus-2.netlify.app/docs/installation/#running-the-development-server