exhibitionist-digital / ultra

Zero-Legacy Deno/React Suspense SSR Framework

Home Page:https://ultrajs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON import crash on client side

d9k opened this issue · comments

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.

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";

At least this line needs to be changed to support json:

lib/middleware/compiler.ts:

const isCompilerTarget = [".ts", ".tsx", ".js", ".jsx"].includes(extension);

Seems to work on prod, preparing PR

Good work on providing a fix. I've ran into the same issue, this seems really essential to have resolved.