facebook / facebook/docusaurus

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

Open
#8,646 11 comments 0 reactions 0 assignees View on GitHub
bug status: needs more information
Dominant language
TypeScript
Stars
66.2k
Forks
10k
Avg merge
1d 3h
Merged PRs (30d)
52

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.