facebook / facebook/docusaurus

Scaffolded project not working when custom SVGR config placed in parent directory

Abierto
#8,646 11 comentarios 0 reacciones 0 asignados Ver en GitHub
bug status: needs more information
Lenguaje dominante
TypeScript
Estrellas
66.2k
Forks
10k
Merge medio
1 d 3 h
PR fusionados (30 d)
52

Descripción

### Have you read the Contributing Guidelines on issues?

- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).

### Prerequisites

- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [ ] I have tried creating a repro with https://new.docusaurus.io.
- [X] I have read the console error message carefully (if applicable).

### Description

Hi, i create new project like this:

```bash
npx create-docusaurus@latest docusaurus-try classic --typescript
cd docusaurus-try
npm start
```

After it i get next error:
```

> showcase@0.0.0 start
> docusaurus start

[INFO] Starting the development server...
[SUCCESS] Docusaurus website is running at: http://localhost:3000/

✖ Client
Compiled with some errors in 935.15ms

SyntaxError: unknown: Unexpected reserved word 'interface'. (3:0)
1 | import * as React from "react";
2 | import { SVGProps } from "react";
> 3 | interface SVGRProps {
| ^
4 | title?: string;
5 | titleId?: string;
6 | }
at parser.next ()
at normalizeFile.next ()
at run.next ()
at transform.next ()
SyntaxError: unknown: Unexpected reserved word 'interface'. (3:0)
1 | import * as React from "react";
2 | import { SVGProps } from "react";
> 3 | interface SVGRProps {
| ^
4 | title?: string;
5 | titleId?: string;
6 | }
at parser.next ()
at normalizeFile.next ()
at run.next ()
at transform.next ()
SyntaxError: unknown: Unexpected reserved word 'interface'. (3:0)
1 | import * as React from "react";
2 | import { SVGProps } from "react";
> 3 | interface SVGRProps {
| ^
4 | title?: string;
5 | titleId?: string;
6 | }
at parser.next ()
at normalizeFile.next ()
at run.next ()
at transform.next ()
client (webpack 5.75.0) compiled with 3 errors
```

It is because in parent directory of docusaurus-try there is a `svgr.config.js` file

### Reproducible demo

_No response_

### Steps to reproduce

1. create and run project by:
```bash
npx create-docusaurus@latest docusaurus-try classic --typescript
cd docusaurus-try
npm start
```
2. see an error in terminal and in browser

### Expected behavior

May be docusaurus should log messages to terminal when it uses configurations outside target directory

### Actual behavior

There is an error:

```

> showcase@0.0.0 start
> docusaurus start

[INFO] Starting the development server...
[SUCCESS] Docusaurus website is running at: http://localhost:3000/

✖ Client
Compiled with some errors in 935.15ms

SyntaxError: unknown: Unexpected reserved word 'interface'. (3:0)
1 | import * as React from "react";
2 | import { SVGProps } from "react";
> 3 | interface SVGRProps {
| ^
4 | title?: string;
5 | titleId?: string;
6 | }
at parser.next ()
at normalizeFile.next ()
at run.next ()
at transform.next ()
SyntaxError: unknown: Unexpected reserved word 'interface'. (3:0)
1 | import * as React from "react";
2 | import { SVGProps } from "react";
> 3 | interface SVGRProps {
| ^
4 | title?: string;
5 | titleId?: string;
6 | }
at parser.next ()
at normalizeFile.next ()
at run.next ()
at transform.next ()
SyntaxError: unknown: Unexpected reserved word 'interface'. (3:0)
1 | import * as React from "react";
2 | import { SVGProps } from "react";
> 3 | interface SVGRProps {
| ^
4 | title?: string;
5 | titleId?: string;
6 | }
at parser.next ()
at normalizeFile.next ()
at run.next ()
at transform.next ()
client (webpack 5.75.0) compiled with 3 errors
```

### Your environment

- Public source code: non needed
- Public site URL: non needed
- Docusaurus version used: latest 2.3.1
- Environment name and version (e.g. Chrome 89, Node.js 16.15.1): Node.js 16.15.1
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): mac os

### Self-service

- [ ] I'd be willing to fix this bug myself.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.