Skip to content

Copy public directory files verbatim instead of running the asset optimizer#5651

Open
LucaCappelletti94 wants to merge 1 commit into
DioxusLabs:mainfrom
LucaCappelletti94:serve-public-verbatim
Open

Copy public directory files verbatim instead of running the asset optimizer#5651
LucaCappelletti94 wants to merge 1 commit into
DioxusLabs:mainfrom
LucaCappelletti94:serve-public-verbatim

Conversation

@LucaCappelletti94

Copy link
Copy Markdown

Files in the public/ directory are documented as served as-is, but dx serve and dx bundle both ran them through the asset optimizer, and the two did not always agree. A .js entry gets inlined and minified, which shifts import.meta.url and can drop the entry's re-exports, so a worker module could work through dx bundle and fail under dx serve.

This bit us building a multi-threaded wasm app with wasm-bindgen-rayon (no-bundler feature). A build.rs emits the wasm-bindgen --target web glue plus a small loader.js entry into public/, and the entry re-exports the glue because the pool spawns blob workers that re-import it by URL and call pkg.default(...) and pkg.wbg_rayon_start_worker(...). Once those exports were optimized away, every pool worker threw TypeError: r.default is not a function and the SharedArrayBuffer pool never came up, while the same code ran fine through dx bundle. So it was a development-only break.

Copying public/ verbatim also stops optimizing public CSS and images, which matches the served-as-is contract (asset!() stays the path for assets you want optimized).

@LucaCappelletti94 LucaCappelletti94 requested a review from a team as a code owner June 23, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant