form icon indicating copy to clipboard operation
form copied to clipboard

chore: add solid export condition to `@tanstack/solid-form`

Open Brendonovich opened this issue 1 year ago • 4 comments

Solid relies on the solid export condition to perform a custom JSX transform depending on whether the code is being built for client or server, but @tanstack/solid-form only has dist/cjs and dist/esm, which are client-only since they import stuff like memo from solid-js/web (which is only available in client builds).

To fix this I've added tsc to the build of process of @tanstack/solid-form so that .js/.jsx files are emitted which solid can apply its custom JSX transform on. There's probably nicer ways of doing this that can integrate with vite but this is what I did to fix a similar problem for SolidStart.

Brendonovich avatar Mar 19 '24 08:03 Brendonovich

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 80035f2cdac36103e90e0dedf5b8f7c461318832. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

nx-cloud[bot] avatar Mar 19 '24 08:03 nx-cloud[bot]

@lachlancollins can you investigate this? We'd want this to integrate with Vite

Also CC @ryansolid if you have any guidance on how to do this (sorry for the ping Ryan)

crutchcorn avatar Mar 19 '24 20:03 crutchcorn

This is pretty much correct. We want the source, but not necessarily the TypeScript so we tend to tsc it into dist folder. My only recommendation is build it into a .jsx entry file if there is any JSX anywhere in the solid implementation of the library. That way it will get processed properly.

ryansolid avatar Mar 19 '24 22:03 ryansolid

My only recommendation is build it into a .jsx entry file if there is any JSX anywhere in the solid implementation of the library. That way it will get processed properly.

This is probably true but having the entrypoint be .js seems to be working fine for us

Brendonovich avatar Mar 20 '24 01:03 Brendonovich

Is there anything blocking this from being merged? tanstack forms is unusable on solid without this

TheKnightCoder avatar Jun 09 '24 22:06 TheKnightCoder

@TheKnightCoder I'd like to see our build tooling unified to solve this problem before we merge. @lachlancollins any chance you could take another look into merging into Vite?

Alternatively, if you think this fine to publish as-is for now and refine later, we can

crutchcorn avatar Jun 19 '24 06:06 crutchcorn

Merging, per some research from @lachlancollins showing this should work now. Let us know if you run into additional problems around ESM/CJS support

crutchcorn avatar Jun 20 '24 00:06 crutchcorn