-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
chore(gatsby-plugin-mdx): refactor mdx-loader async code #25790
Conversation
This function was not optimally using the syntactic sugar of `async` functions. It was manually creating and returning a promise, including dealing with exceptions. Instead, the `async` keyword takes care of all of that for you implicitly. So this simplifies the function a little bit.
Should this merge into master or merge into #25757? |
#25757 is likely to merge to master long after this one so I'll rebase that PR to master once it does and resolve the inevitable merge conflict. |
Once I fix the tests ... 🤔 |
Your pull request can be previewed in Gatsby Cloud: https://build-4ea45a4c-3d40-43d2-9693-5aefb40130a1.staging-previews.gtsb.io |
I'm going to need more time to validate this is not going to break webpack so I'm going to put it in draft mode and return to it after my vacation, |
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.
If you're not sure you can always do this:
module.exports = function loader(content) {
const callback = this.async();
mdxLoader
.call(this, content)
.then(args => callback(null, args), err => callback(err));
}
async function mdxLoader(content) {
This function was not optimally using the syntactic sugar of
async
functions. It was manually creating and returning a promise, including dealing with exceptions. Instead, theasync
keyword takes care of all of that for you implicitly. So this simplifies the function a little bit.Suggest to review without whitespace.