mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-05 05:07:14 +02:00
fix(v1): fresh install failing due to <> syntax
https://github.com/facebook/docusaurus/issues/3199 (#3213)
This commit is contained in:
parent
8f0c00f3d4
commit
83d160f017
4 changed files with 16 additions and 6 deletions
|
@ -28,6 +28,7 @@ module.exports = {
|
||||||
'no-plusplus': OFF,
|
'no-plusplus': OFF,
|
||||||
'prefer-template': OFF,
|
'prefer-template': OFF,
|
||||||
'import/no-extraneous-dependencies': OFF,
|
'import/no-extraneous-dependencies': OFF,
|
||||||
|
'react/jsx-fragments': OFF, // Babylon v6 does not support <> fragments
|
||||||
'react/jsx-closing-bracket-location': OFF, // Formatting is left to Prettier.
|
'react/jsx-closing-bracket-location': OFF, // Formatting is left to Prettier.
|
||||||
'react/jsx-filename-extension': OFF, // Enable in future when migrating.
|
'react/jsx-filename-extension': OFF, // Enable in future when migrating.
|
||||||
'react/jsx-one-expression-per-line': OFF, // Formatting is left to Prettier.
|
'react/jsx-one-expression-per-line': OFF, // Formatting is left to Prettier.
|
||||||
|
|
|
@ -34,14 +34,14 @@ class Users extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
<div className="logos">{showcase}</div>
|
<div className="logos">{showcase}</div>
|
||||||
{siteConfig.repoUrl && (
|
{siteConfig.repoUrl && (
|
||||||
<>
|
<React.Fragment>
|
||||||
<p>Are you using this project?</p>
|
<p>Are you using this project?</p>
|
||||||
<a
|
<a
|
||||||
href={`${siteConfig.repoUrl}/edit/master/website/siteConfig.js`}
|
href={`${siteConfig.repoUrl}/edit/master/website/siteConfig.js`}
|
||||||
className="button">
|
className="button">
|
||||||
Add your company
|
Add your company
|
||||||
</a>
|
</a>
|
||||||
</>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
|
|
|
@ -49,6 +49,6 @@ program
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
startDocusaurus().catch((ex) => {
|
startDocusaurus().catch((ex) => {
|
||||||
console.error(chalk.red(`Failed to start Docusaurus server: ${ex}`));
|
console.error(chalk.red(ex && ex.stack ? ex.stack : ex));
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,6 +55,17 @@ if (fs.existsSync(`${CWD}/data/custom-translation-strings.json`)) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseJSXFile(file) {
|
||||||
|
try {
|
||||||
|
return babylon.parse(fs.readFileSync(file, 'utf8'), {
|
||||||
|
plugins: ['jsx'],
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(`Babylon parsing failure for file=${file}: ${e.message}
|
||||||
|
\nNote: Docusaurus v1 currently uses Babylon v6, and <> fragment syntax is not supported`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function writeFileAndCreateFolder(file, content) {
|
function writeFileAndCreateFolder(file, content) {
|
||||||
mkdirp.sync(file.replace(new RegExp('/[^/]*$'), ''));
|
mkdirp.sync(file.replace(new RegExp('/[^/]*$'), ''));
|
||||||
fs.writeFileSync(file, content);
|
fs.writeFileSync(file, content);
|
||||||
|
@ -151,9 +162,7 @@ function execute() {
|
||||||
glob.sync(`${CWD}/pages/en/**`).forEach((file) => {
|
glob.sync(`${CWD}/pages/en/**`).forEach((file) => {
|
||||||
const extension = nodePath.extname(file);
|
const extension = nodePath.extname(file);
|
||||||
if (extension === '.js') {
|
if (extension === '.js') {
|
||||||
const ast = babylon.parse(fs.readFileSync(file, 'utf8'), {
|
const ast = parseJSXFile(file);
|
||||||
plugins: ['jsx'],
|
|
||||||
});
|
|
||||||
traverse(ast, {
|
traverse(ast, {
|
||||||
enter(path) {
|
enter(path) {
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Add table
Reference in a new issue