fresh icon indicating copy to clipboard operation
fresh copied to clipboard

Cannot use automatic jsx runtime in fresh

Open lifeiscontent opened this issue 2 years ago • 8 comments

I changed my deno.json to:

{
  "$schema": "https://cdn.deno.land/deno/versions/v1.23.2/raw/cli/schemas/config-file.v1.json",
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "preact"
  },
  "tasks": {
    "start": "deno run -A --watch=static/,routes/ dev.ts"
  },
  "importMap": "./import_map.json"
}

but it doesn't work due to several lines in the fresh codebase explicitly setting

/** @jsx h */

Is there a reason for this? Why not use the automatic runtime always?

lifeiscontent avatar Jul 03 '22 01:07 lifeiscontent

The automatic runtime configured via deno.json is not supported in Deno Deploy as of now.

lucacasonato avatar Jul 03 '22 01:07 lucacasonato

@lucacasonato thanks for the info, much appreciated :)

lifeiscontent avatar Jul 05 '22 00:07 lifeiscontent

@lucacasonato is there a work-a-round in the meantime? I am working on a React component library that relies on the automatic import of React and trying to determine if I need to refactor upstream.

uipoet avatar Jul 07 '22 16:07 uipoet

FYI: automatic JSX runtime support was recently added to esbuild via https://github.com/evanw/esbuild/pull/2349.

That means, at the very least, files inside islands could take advantage of the automatic JSX runtime (if fresh were to update its esbuild dependency, and read in the user’s deno.json).

tylerbrostrom avatar Jul 29 '22 21:07 tylerbrostrom

Deno Deploy now also supports automatic runtime via deno.json and via /** @jsxImportSource */ :)

lucacasonato avatar Jul 29 '22 21:07 lucacasonato

That is to say: automatic JSX runtime coming to a fresh near you soon!

lucacasonato avatar Jul 29 '22 21:07 lucacasonato

@lucacasonato if this isn’t already being worked on, I’d be happy to take a stab at it

tylerbrostrom avatar Jul 29 '22 22:07 tylerbrostrom

I'm already working on it. Thanks for the offer though! (Currently blocked by an upstream Deno bug)

lucacasonato avatar Jul 29 '22 23:07 lucacasonato

Update: the upstream bug should be fixed in Deno 1.24.3.

lucacasonato avatar Aug 09 '22 20:08 lucacasonato

JSX automatic mode support has landed in #610. It will be part of next weeks' Fresh 1.1.0 release.

lucacasonato avatar Aug 26 '22 09:08 lucacasonato