Skip to content

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

Open
@shalugin

Description

@shalugin

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • 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.
  • I have read the console error message carefully (if applicable).

Description

Something similar to #10460

Reproducible demo

No response

Steps to reproduce

This is simple to reproduce.

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

# Congratulations!

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

This will break a build (rspack also).
It looks like #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

[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 (<anonymous>)
    at normalizeFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiondomain: bundler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions