stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.78k stars 144 forks source link

Source maps won't load from source map files #1091

Open FossPrime opened 1 year ago

FossPrime commented 1 year ago

Describe the bug

Upstream: https://bugs.chromium.org/p/chromium/issues/detail?id=1206431#c13

All .map files in node_modules are served via a service worker. DevTools ignoring our service worker seems like a bug.

Here is TS example: vite.new/vue-ts Here is a JS example: vite.new/vue

This is very hard to debug in userland. I tried tearing DevTools apart to see the 404 code... with ANY other Chrome request the response will be 200 because of the service worker. DevTools ignoring our service worker is unexpected unique behavior.

Link to the blitz that caused the error

vite.new/vue-ts

Steps to reproduce

load some js that points to a source map file

Expected behavior

Source map files load

Parity with Local

Screenshots

Screenshot 2023-06-01 17 59 22

Platform

Additional context

In big projects, this will flood the console and make it very difficult to debug

work around filter -/DevTools\sfailed\sto\sload\ssource\smap:/

Reading the room, I'm not clear that they see this as a bug or a prioritized feature. There is a service worker side solution possible,

  1. embedding source maps.
    • turning the transformer on only on the second time the file is requested would be an acceptable compromise. Or setting it to always-on, on ports over 9000.
  2. Rewriting source map links to unpkg urls
  3. provide a sourcemap transform plugin under @stackblitz/vite-plugin-sourcemaps
  4. Host a cloudflare worker that tries to serve sourcemaps on a wildcard subdomain.
  5. Have separate webcontainer that you can enable with better debugability and soucemaps embedding enabled.

Easiest is #2.

SamVerschueren commented 1 year ago

Thanks for bringing this up with the Chrome team and responding to that upstream issue 🙏 ! Seems like there's not much we can do for now but wait until they fix it?

FossPrime commented 1 year ago

Thanks for bringing this up with the Chrome team and responding to that upstream issue 🙏 ! Seems like there's not much we can do for now but wait until they fix it?

I think it would go a long way to drop a message in the chromium issue from an @stackblitz email referencing this or related issues, in support of getting it resolved. Looks like its a problem for several other use cases.