Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON import crash on client side #288

Open
d9k opened this issue Dec 13, 2023 · 6 comments
Open

JSON import crash on client side #288

d9k opened this issue Dec 13, 2023 · 6 comments

Comments

@d9k
Copy link

d9k commented Dec 13, 2023

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.
@d9k
Copy link
Author

d9k commented Dec 13, 2023

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

@d9k
Copy link
Author

d9k commented Dec 13, 2023

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

lib/middleware/compiler.ts:

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

@d9k
Copy link
Author

d9k commented Dec 14, 2023

Deployed my Ultra fork with fix JSON import fix at
https://deno.land/x/[email protected]

Can't test with production build due to
`/~/` alias + build => Module not found on runtime | ultra issue #290

@d9k
Copy link
Author

d9k commented Dec 29, 2023

Seems to work on prod, preparing PR

d9k added a commit to d9k/ultra that referenced this issue Dec 29, 2023
@d9k
Copy link
Author

d9k commented Dec 29, 2023

PR #293

@FalcoG
Copy link

FalcoG commented May 9, 2024

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

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

No branches or pull requests

2 participants