-
-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expo Router Adapter / CJS Support #837
Comments
I did a quick and dirty cjs build of nuqs and it seems to work. I am gonna do some testing wiht Expo and wire everything up. |
Thanks for the contribution! Unfortunately, adding CJS support back (it was removed in nuqs v2) is not planned, it's time for the ecosystem to move forward. What's blocking Metro from allowing ESM, do you know? It feels like efforts should be directed towards this goal instead of keeping CJS alive (a format deprecated since Node 18), that would allow modern libraries running in Expo/Metro. |
Ya I'm fully with you. Metra has lagged behind for a long time. That's a beast to change and people are trying but you have to deal with Facebook. Do you mind if I publish a cjs fork for everyone using expo? |
Let me poke at it a bit more this morning. I might be able to get around it. Will let you know. |
Ok, seems like on dev you have some code that isn't released yet that will get around the above issue. Testing that now. |
Ok here is how I have this working for me. I built the next branch. I have the following adapter:
I followed the following post: expo/expo#30323 (comment) and add this to my babel.config.ts overrides: [
{
test: [/nuqs/],
plugins: [
'babel-plugin-transform-import-meta',
'module:@reactioncommerce/babel-remove-es-create-require',
],
},
], I then had to import from @franky47 what the timeline for releasing support for |
Was that a TypeScript or a runtime issue? If runtime, I assume it's the Expo/Metro resolver that doesn't support package.json "exports" fields. I have a few things I want to test on the React Router adapters before releasing 2.3.0 in GA (hopefully early next week when I'm back home from holidays), but there's |
Metro spits out the following:
|
Hum that's weird, because we do define this export: nuqs/packages/nuqs/package.json Lines 103 to 107 in 10e526d
Do you get the same error when importing |
Have to do this: |
Do you have |
That breaks the babel hack to get around no cjs support. |
I think if you got rid of |
Yeah I've been doing a lot of experiments to properly support various TypeScript configurations (see #708). Putting everything at the top level might not be convenient in the monorepo setup, but it's worth a try. |
Here's a preview deployment with everything at the top level:
|
Seems like with that preview I run into the CJS issue again. I think importing from dist was letting me around it. |
Ok, thanks for the feedback, it also gives me weird behaviours in some TS configs, so I'll close that branch. |
I have stubbed out an adapter that would work for Expo Router:
The problem I am running into is expo uses the metro bundler. Metro doesn't support ESM yet, so everything has to be CJS. Is there away we can add CJS support back to this package?
The text was updated successfully, but these errors were encountered: