Get Fresh working in Node

Open
#3,284 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
node.js, typescript, vite

Research direction

Start with the import chain in packages/plugin-vite/src/mod.ts, packages/plugin-vite/src/plugins/server_entry.ts, packages/fresh/src/internals_dev.ts, and packages/fresh/src/dev/builder.ts, then inspect the referenced middleware.tsx and the installed @fresh/core package. Check why the .tsx source has no corresponding compiled .js file and whether the cause is Fresh packaging or JSR. Done means the Vite config loads in Node with @fresh/plugin-vite.

Written by the indexing model from the issue text.

Description

feat upstream

I'm trying to see if @fresh/plugin-vite can be made to work in Node (not Deno). One of the issues I've run into is that this package depends (indirectly) on a .tsx file, which results in the vite config failing to load.

I've traced it to the middleware.tsx file.

Import chain

https://github.com/freshframework/fresh/blob/e33b44776838b756cf9e52088c4352dd894cdc76/packages/plugin-vite/src/mod.ts#L9

https://github.com/freshframework/fresh/blob/e33b44776838b756cf9e52088c4352dd894cdc76/packages/plugin-vite/src/plugins/server_entry.ts#L2-L6

https://github.com/freshframework/fresh/blob/e33b44776838b756cf9e52088c4352dd894cdc76/packages/fresh/src/internals_dev.ts#L11

https://github.com/freshframework/fresh/blob/e33b44776838b756cf9e52088c4352dd894cdc76/packages/fresh/src/dev/builder.ts#L22

For some reason, the @fresh/core JSR package, when installed through npm/pnpm, does not contain the compiled .js files next to the .tsx source files. This is unlike the .ts files, each of which does have a corresponding .js file next to them. There is no easy way to "inspect" this on the web, but you can verify it by running pnpm install jsr:@fresh/core and looking inside the node_modules folder (see screenshot).

This could either be some misconfiguration or a potential bug in JSR. I saw https://github.com/jsr-io/jsr/issues/24#issuecomment-2677117503 which claims that JSX is supported, so this scenario is supposed to work in theory at least.

Dominant language
TypeScript
Stars
13.8k
Forks
757
Avg merge
3m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from freshframework/fresh

All issues in freshframework/fresh

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.