JSON import crash on client side
d9k opened this issue · comments
Dmitry commented
import schemaData from '/~/shared/api/supabase/schema.generated.json' assert {
type: 'json',
};
console.log(schemaData);
Works on server side. On client side causes error
schema.generated.json:1 Failed to load module script: Expected a JSON module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
Dmitry commented
Ultra really just renders html page in response...
> curl http://localhost:8000/_ultra/compiler/src/shared/api/supabase/schema.generated.json
<!DOCTYPE html><html lang="en" data-mantine-color-scheme="dark"><head><meta charSet="utf-8"/>
<title>Ultra</title><meta name="viewport" content="width=device-width, initial-scale=1"/><lin
k rel="shortcut icon" href="/favicon.ico"/><script data-mantine-script="true">try {
var _colorScheme = window.localStorage.getItem("mantine-color-scheme-value");
var colorScheme = _colorScheme === "light" || _colorScheme === "dark" || _colorScheme === "
auto" ? _colorScheme : "dark";
Dmitry commented
At least this line needs to be changed to support json:
lib/middleware/compiler.ts:
const isCompilerTarget = [".ts", ".tsx", ".js", ".jsx"].includes(extension);
Dmitry commented
Deployed my Ultra fork with fix JSON import fix at
https://deno.land/x/ultra_fork_d9k@v2.3.8.1
Can't test with production build due to
`/~/` alias + build => Module not found on runtime | ultra issue #290
Dmitry commented
Seems to work on prod, preparing PR
Falco Gerritsjans commented
Good work on providing a fix. I've ran into the same issue, this seems really essential to have resolved.