-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Open
Labels
apprenticeIssues that are good candidates to be handled by a Docusaurus apprentice / traineeIssues that are good candidates to be handled by a Docusaurus apprentice / traineeproposalThis issue is a proposal, usually non-trivial changeThis issue is a proposal, usually non-trivial change
Description
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - I have tried creating a repro with https://new.docusaurus.io.
- I have read the console error message carefully (if applicable).
Description
If I add the docs plugin to the list of plugins (multi-instance) and I point it to the same folder that the preset is already pointing to (docs by default), the build process stops working and I see the following errors:
SyntaxError: /code/src/......../index.mdx: Identifier 'React' has already been declared. (46:184)
I believe the bug might be caused by the way each mdx file is being processed. Because a mdx file is (basically) a JSX file, import React from 'react'; is being prepended at the top of each file. But since I have two instances of the docs plugin pointing to the same folder, the import statement is being prepended twice (hence the error).
I made a minimal repro codesandbox.
Reproducible demo
https://codesandbox.io/s/trusting-rosalind-sc4s15
Steps to reproduce
- Open the link
- Open a new tty and type
npm run build - The build will fail.
- Comment the
pluginssection of thedocusaurus.config.js - Run
npm run buildagain. - The build will succeed.
Expected behavior
I should be able to point multiple instances of the docs plugin to the same folder.
Actual behavior
The build crashes.
Your environment
- Public source code: N/A
- Public site URL: N/A
- Docusaurus version used: 2.0.0-beta20
- Environment name and version (e.g. Chrome 89, Node.js 16.4): N/A
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): N/A
Self-service
- I'd be willing to fix this bug myself.
Metadata
Metadata
Assignees
Labels
apprenticeIssues that are good candidates to be handled by a Docusaurus apprentice / traineeIssues that are good candidates to be handled by a Docusaurus apprentice / traineeproposalThis issue is a proposal, usually non-trivial changeThis issue is a proposal, usually non-trivial change