bfanger / tvkit

Proxy to run a modern dev server in old browsers
MIT License
22 stars 5 forks source link

Problem loading Sveltekit modules on Tizen 6 #15

Open chipndahla opened 6 months ago

chipndahla commented 6 months ago

We're using TVkit to transpile our code to older Tizen models. This works very well in general so big thanks. But have an odd issue with Tizen 6 (M76) I use TVkit to transpile to Tizen 5 and that works for both Tizen 5 and Tizen 6.5, but oddly not on a Tizen 6. Also tried to target Tizen 6 with Tvkit but still no success.

In the console I get many of these errors while loading different javascript files:

"Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec."

Any ideas why?

bfanger commented 6 months ago

I don't have access to a Tizen 6 device, so i'm speculating here:

Try if a hosted works or if adding --add "es6-module" to tvkit fixes it.

chipndahla commented 6 months ago

Did some more investigations.

First, to my best knowledge the Tizen TV doesn't have an internal webserver, instead it accesses the assets through file:/// which is not normally allowed but Tizen launches Chromium with --allow-file-access-from-files (and a number of other special parameters)

Example how Tizen loads a file (notice the file:///) image

Since no webserver can set the MIME types, at least in M76, Chromium refuses to load the JS modules. Will try to verify now

And already uses --add "es6-module" as per a previous chat (a very useful feature! thanks!)

chipndahla commented 6 months ago

Update I installed old Chrome versions om my dev machine and started it with same params as Tizen does. Could repeat the results!

On M63 (Tizen 5) file:/// are loaded but no MIME type is assigned but no strict MIME-type is required either.

On M76 (Tizen 6) js files are loaded in the same way but console shows lots of MIME warnings: image Console: image

On a modern M120 MIME-types headers seem to be automatically added: image

So this is clearly an issue with chrome versions around M76.

Will now see if I can work around the issue by assigning MIME-types in javascript

chipndahla commented 6 months ago

Have now experimented further and despite all the console errors my application seem to work fine (the original errors I had instead seem to come from a Firestore issue on Tizen). Still seem very odd to me that to show a image

and then anyhow seem to load the module.

One possible work around would be to either set the MIME-type manually while importing them. Is that possible in Rollup or Babel? Alternatively storing them online and then get the expected MIME-headers from the server.

Any ideas? And thanks for taking the time