Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't break the build on incorrect static JS assets #10855

Open
5 of 7 tasks
shalugin opened this issue Jan 21, 2025 · 3 comments
Open
5 of 7 tasks

Don't break the build on incorrect static JS assets #10855

shalugin opened this issue Jan 21, 2025 · 3 comments
Labels
closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)

Comments

@shalugin
Copy link

shalugin commented Jan 21, 2025

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.
@shalugin shalugin added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jan 21, 2025
@Josh-Cena
Copy link
Collaborator

Hi, this is working as expected. The static folder doesn't mean "no bundling"; it just means it will be copied to the output folder. You can use pathname:// to opt out. See https://docusaurus.io/docs/markdown-features/assets#static-assets

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2025
@Josh-Cena Josh-Cena added closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) and removed bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jan 21, 2025
@shalugin
Copy link
Author

@Josh-Cena Thank you for pointing this out to me! I didn't notice that. Great!

@slorber
Copy link
Collaborator

slorber commented Jan 22, 2025

Hi, this is working as expected.

Hmm, I'm not so sure in this case.

Markdown links referencing files are converted to require() calls, and by default require("./some.js") returns the transpiled module.

When it's used inside a Markdown links, returning the transpiled module has no utility at all IMHO, and we should probably use webpack file-loader in this case.

pathname:// is a decent workaround, but I still think we could improve a bit the default behavior for this edge case.

Note: this is unrelated to #10460

@slorber slorber reopened this Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)
Projects
None yet
Development

No branches or pull requests

3 participants