fresh icon indicating copy to clipboard operation
fresh copied to clipboard

HTTP imports are no longer a thing when building with vite (?)

Open CAYdenberg opened this issue 3 months ago • 4 comments

Fresh 2.1.1 Deno 2.5.1

  1. Create a new Fresh app deno run -Ar jsr:@fresh/init
  2. In routes/index.tsx, add import { z } from "https://deno.land/x/[email protected]/mod.ts"; above the main function, and then z.string() within the main function body
  3. deno run dev
  4. Visit localhost:5173
  5. Observe that the app crashes with
TypeError: [ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLs are supported by the default ESM loader. Received protocol 'https'
  1. After deno task build and deno task start the page does load, but the island does not.

I understand I can probably work around with JSR or by just putting the import in deno.json, but my project is meant to be a Fresh plugin (used to build other final progjects), that also contains some JSX, so I'm not exactly sure what the best way is to deploy it at this point. (It would be really sweet if JSR supported JSX given that was supposed to be "baked in" to Deno).

In any case I think the error message could be a little more clear?

CAYdenberg avatar Sep 22 '25 03:09 CAYdenberg

Fresh 1 plugins are not supported in Fresh 2.

Also using esm.sh is discouraged, see here -> https://fresh.deno.dev/docs/advanced/troubleshooting#dont-use-esmsh

fry69 avatar Sep 22 '25 03:09 fry69

@fry69 Zod is not a fresh 1 plugin. This is a bug. Whilst we don't encourage http imports, they're still supported.

marvinhagemeister avatar Sep 22 '25 08:09 marvinhagemeister

@marvinhagemeister I was referring to this part, I should have made this more clear in my response:

but my project is meant to be a Fresh plugin

fry69 avatar Sep 22 '25 08:09 fry69

Sorry, by plugin I mean "package that is meant to be used as a dependency on Fresh sites"

CAYdenberg avatar Sep 22 '25 15:09 CAYdenberg