refine icon indicating copy to clipboard operation
refine copied to clipboard

[BUG] Remix (SPA) Support

Open pcfreak30 opened this issue 1 year ago • 2 comments

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 esbuildOptions via options.minify = false; (remix SPA does a sort-of 1 time SSR eval, running Refine through a node-js server which needs the ESM import, unminified)
  • Disable tsbuild --legacyOutput.
  • Add export maps with the esm import pointing to a .mjs file (this actually really matters)
    • Ensure export maps have typings as well.
  • Replace lodash-es and papaparse at a minimum to use .js extensions when imported
  • Update commands in packages/cli/src/commands/runner as remix-serve no longer exists and needs to use remix 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

pcfreak30 avatar Mar 08 '24 12:03 pcfreak30

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?

aliemir avatar Mar 08 '24 13:03 aliemir

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?

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.

pcfreak30 avatar Mar 08 '24 13:03 pcfreak30