-
-
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
misc: convert all internal scripts to ESM #6286
Conversation
Size Change: 0 B Total Size: 676 kB ℹ️ View Unchanged
|
run().then( | ||
() => { | ||
process.exit(0); | ||
}, | ||
(e) => { | ||
console.error(e.message); | ||
console.error(e.stack); | ||
process.exit(1); | ||
}, | ||
); |
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.
Tip: review with hide whitespace
✔️ [V2] 🔨 Explore the source changes: 25825cc 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61d912fe7dbb360007183460 😎 Browse the preview: https://deploy-preview-6286--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6286--docusaurus-2.netlify.app/ |
await new Promise((resolve) => { | ||
setTimeout(resolve, 0); | ||
}); | ||
const FeatureRequestsPlugin = (await import('./src/featureRequests/FeatureRequestsPlugin.mjs')).default; |
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.
🤪 IMHO this looks weird, we should just use createConfig
now and put everything inside the function
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.
Yea, but that creates too much indentation changes... I'd rather use this with the return of less indentation for our massive config
object
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.
I'd rather use this with the return of less indentation for our massive config object
I don't understand what you mean here
Do you see this as a temporary step?
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.
No, I view this as a long term solution.
const config = {
foo: bar, // two spaces of indentation
};
async function createConfig() {
return {
foo: bar, // four spaces of indentation
};
}
I'd like to avoid that extra level of indentation at all costs
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.
I'd 1000% prefer to have an extra indentation than to have this in the long term (which we currently have):
const config = {
foo: bar, // two spaces of indentation
};
async function createConfig()
config.xyz = await abc();
return config;
}
module.exports = createConfig;
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.
Ha, I'm not sure if we are to add more async items in the future. We'll see...
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.
We can keep it for now, I'll figure out a way to clean this up later
Motivation
ESM looks nicer. Also allows top-level await. Also a POC that the docusaurus.config.js file now supports dynamically importing ES module dependencies.
Seems Jest can't ergonomically import ESM yet, so the
theme-translations/update.js
was not converted.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Ran the scripts locally.