mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-04 20:57:17 +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,
|
||||
'prefer-template': 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-filename-extension': OFF, // Enable in future when migrating.
|
||||
'react/jsx-one-expression-per-line': OFF, // Formatting is left to Prettier.
|
||||
|
|
|
@ -34,14 +34,14 @@ class Users extends React.Component {
|
|||
</div>
|
||||
<div className="logos">{showcase}</div>
|
||||
{siteConfig.repoUrl && (
|
||||
<>
|
||||
<React.Fragment>
|
||||
<p>Are you using this project?</p>
|
||||
<a
|
||||
href={`${siteConfig.repoUrl}/edit/master/website/siteConfig.js`}
|
||||
className="button">
|
||||
Add your company
|
||||
</a>
|
||||
</>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</div>
|
||||
</Container>
|
||||
|
|
|
@ -49,6 +49,6 @@ program
|
|||
.parse(process.argv);
|
||||
|
||||
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);
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
mkdirp.sync(file.replace(new RegExp('/[^/]*$'), ''));
|
||||
fs.writeFileSync(file, content);
|
||||
|
@ -151,9 +162,7 @@ function execute() {
|
|||
glob.sync(`${CWD}/pages/en/**`).forEach((file) => {
|
||||
const extension = nodePath.extname(file);
|
||||
if (extension === '.js') {
|
||||
const ast = babylon.parse(fs.readFileSync(file, 'utf8'), {
|
||||
plugins: ['jsx'],
|
||||
});
|
||||
const ast = parseJSXFile(file);
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
if (
|
||||
|
|
Loading…
Add table
Reference in a new issue