facebook / facebook/docusaurus

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

Aperta
#8,646 11 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug status: needs more information
Lingua principale
TypeScript
Stelle
66.2k
Fork
10k
Merge medio
1g 3h
PR unite (30g)
52

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.