facebook / facebook/docusaurus

Markdown links linking to JS files should resolve to the asset url, not transpiled code

Open
#10,855 4 comments 0 reactions 0 assignees View on GitHub
bug domain: bundler
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

Something similar to https://github.com/facebook/docusaurus/issues/10460

### Reproducible demo

_No response_

### Steps to reproduce

This is simple to reproduce.

1. Create a fresh docusaurus site.
1. Create a file `static/assets/upload/test.js`:
```js
{
- / -sss;
}
```
2. Create a link in the documentation to this file
```markdown
---
sidebar_position: 6
---

# Congratulations!

[Test](/assets/upload/test.js)
```

This will break a build (rspack also).
It looks like https://github.com/facebook/docusaurus/issues/10460.

If the ‘invalid’ JavaScript is in the folder, but there is no reference to it, everything will build correctly.

### Expected behavior

Documentation is built even if there is a reference to an invalid JavaScript file in static assets.

### Actual behavior

```text
[ERROR] Client bundle compiled with errors therefore further build is impossible.
SyntaxError: /temp/docusaurus-rs-pack/my-website/static/assets/upload/test.js: Unterminated regular expression. (2:5)
1 | {
> 2 | - / -sss;
| ^
3 | }
4 |
at parser.next ()
at normalizeFile.next ()
at run.next ()
at transform.next ()
```

### Your environment

docusaurus 3.7.0
node 20.17.0
npm 10.8.2

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