refine
refine copied to clipboard
[BUG] Remix (SPA) Support
Describe the bug
The current build process of refine packages makes it incompatible with Remix SPA, and possibly? more.
This has been tested on Remix 2.8.0.
The following steps need to be taken:
- Disable minify on all repos in tsup
esbuildOptionsviaoptions.minify = false;(remix SPA does a sort-of 1 time SSR eval, runningRefinethrough a node-js server which needs the ESM import, unminified) - Disable tsbuild
--legacyOutput. - Add export maps with the esm
importpointing to a.mjsfile (this actually really matters)- Ensure export maps have typings as well.
- Replace
lodash-esandpapaparseat a minimum to use.jsextensions when imported - Update commands in
packages/cli/src/commands/runnerasremix-serveno longer exists and needs to useremix vite:*?
You can see a debug branch with many of these changes at https://github.com/LumeWeb/refine/tree/remix for reference.
Steps To Reproduce
Try to build a remix SPA with any basic refine example.
Expected behavior
It should run the dev server and build correctly.
Packages
All refine packages are likely impacted if they are to be used within remix.
Additional Context
No response
Thanks for the explanation @pcfreak30! About the lodash imports, we have an esbuild plugin to replace them in cjs and esm builds which is shared between packages, I think updating it to include .js so we don't have to worry about cjs builds 😅
About the types in the package.json#exports, do you think we should also create ones with .mts extensions or is it not required?
Thanks for the explanation @pcfreak30! About the lodash imports, we have an esbuild plugin to replace them in
cjsandesmbuilds which is shared between packages, I think updating it to include.jsso we don't have to worry aboutcjsbuilds 😅About the types in the
package.json#exports, do you think we should also create ones with.mtsextensions or is it not required?
The .mts I don't know, but Webstorm definitely complained about types in general (while honoring exports) (prob from tsc). That is mostly an IDE thing, IIRC.