-
Notifications
You must be signed in to change notification settings - Fork 16
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
getSearchParams is not parsing correctly when using Vite #39
Comments
Thanks for the report. I'll take a look. |
Thanks @kiliman for your quick answer. As you mentioned, I tried copying the helper directly in my codebase and everything work as expected. This is indeed pretty weird, I'll continue investigating and update here if I find something |
I did some more investigation. It looks like I need to make a pure ESM package. By default it was loading the CJS version, and for some reason, this code was always returning function parseParams(o, schema, key, value) {
var _a;
// find actual shape definition for this key
let shape = schema;
console.log('parseParams', shape instanceof zod_1.ZodObject)
while (shape instanceof zod_1.ZodObject || shape instanceof zod_1.ZodEffects) {
shape =
shape instanceof zod_1.ZodObject
? shape.shape
: shape instanceof zod_1.ZodEffects
? shape._def.schema
: null;
if (shape === null) {
throw new Error(`Could not find shape for key ${key}`);
}
}
// ...
} |
I was about to send the same finding after debugging in node_modules, |
Sorry for recommending something different here. I needed a quick fix and started using Zodix. |
@mauscoelho I'm glad you found something that works for you. |
I think the issue is a dual package hazard (see https://nodejs.org/api/packages.html#dual-package-hazard) of zod dependency where user code loads esm version of zod (via I was interested in this issue since this might be a general problem which others libraries might face. export default defineConfig({
plugins: [remix(), tsconfigPaths()],
ssr: {
noExternal: ['remix-params-helper'],
},
resolve: {
alias: {
'remix-params-helper': 'node_modules/remix-params-helper/dist/helper.js',
},
},
}); I'm not familiar with |
+1 to this. an error is always returned. I'm trying to use this in my loader to parse queryParams for my API but just throws an error everytime. |
I'll be publishing an updated package that works properly for both CJS and ESM imports. |
Fixed in v0.5.0 |
Hi,
When using Remix 2.2.0 using Vite, it seems that getSearchParams stopped parsing correctly the query params without throwing any errors.
It could be related to Request polyfill in vite adapater as mentionned here : remix-run/remix#7819
The text was updated successfully, but these errors were encountered: