Skip to content
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

feat(core): support docusaurus.config.cjs as default file name #7371

Merged
merged 2 commits into from May 27, 2022

Conversation

Josh-Cena
Copy link
Collaborator

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Related: #6520, #5379

I have heard of users who have "type": "module" in their package.json, which often prevents the docusaurus.config.js file from being read correctly. We should support .cjs extension out-of-the-box, which can also enable us to support .mjs, or even .ts in the future.

In addition, I fixed a little bug with the error message where it's using the default config file name instead of the actual one.

Test Plan

Added a test case.

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

@Josh-Cena Josh-Cena added the pr: new feature This PR adds a new API or behavior. label May 8, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label May 8, 2022
@netlify
Copy link

netlify bot commented May 8, 2022

[V2]

Name Link
🔨 Latest commit d75a0cd
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/628dcf7fd7b01a0008de29b0
😎 Deploy Preview https://deploy-preview-7371--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented May 8, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 69 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 79 🟢 99 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented May 8, 2022

Size Change: 0 B

Total Size: 796 kB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.3 kB
website/build/assets/css/styles.********.css 106 kB
website/build/assets/js/main.********.js 598 kB
website/build/index.html 38.9 kB

compressed-size-action

@IvanGoncharov
Copy link

I discovered that issue trying to migrate graphql-js to ESM and docusaurus is the only blocker left: graphql/graphql-js#3564
@Josh-Cena Big thanks for this PR 👍

@slorber @lex111 Can you please release a new beta with this change? 🙏

@Josh-Cena
Copy link
Collaborator Author

Josh-Cena commented May 9, 2022

@IvanGoncharov This is more complex than that. See #7379 also, which kind of got blocked because of a cryptic error I don't know how to fix for now (and haven't looked deeply into).

If you just want the changes from this PR, you can always use docusaurus start --config docusaurus.config.cjs.

Also, we have our release schedule, so if we reviewed and merged it, you can always use the canary release instead of waiting for the next stable release.

@@ -156,7 +156,7 @@ next build. You can clear all build artifacts (including this folder) with the

const genSiteConfig = generate(
generatedFilesDir,
DEFAULT_CONFIG_FILE_NAME,
`${DEFAULT_CONFIG_FILE_NAME}.mjs`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: #7379

@slorber
Copy link
Collaborator

slorber commented May 27, 2022

LGTM 👍

@slorber slorber merged commit be912c6 into main May 27, 2022
@slorber slorber deleted the jc/cjs-config branch May 27, 2022 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants