Has anyone been able to get `arktype` working in React Native/Expo?
I found this issue (https://github.com/arktypeio/arktype/issues/1027) but there doesn't seem to be any resolution (no pun intended...).
I spent a couple hours trying different configurations but didn't have any luck. Just thought I would check if anyone has found a way to use
arktype
in a React Native project. Looks like a great library and I'd love to be able to pull it in.GitHub
Unable to use ArkType with Expo · Issue #1027 · arktypeio/arktype
Report a bug 🔎 Search Terms @babel/plugin-transform-class-static-block expo 🧩 Context ArkType version: 2.0.0-dev.25 TypeScript version (5.1+): 5.5.2 Other context you think may be relevant (JS flav...
13 Replies
You can take a look at some additional discussion here:
https://discord.com/channels/957797212103016458/1151222272250613802/1151222272250613802
Are you getting the same error that was mentioned in this issue?
If I just install
arktype
, the error I get is: Unable to resolve "@ark/schema/config" from "node_modules/arktype/out/config.js"
.Does it not support package.json exports?
That has been around since Node 12
You could try manually replacing that import with the primary
@ark/schema
entrypoint to see what happensOk I'll give that a shot. There is also a metro setting that I tried, turning it on looks like this
Which gets me to a new error message,
import.meta
is currently unsupported. There's a Babel plugin I tried, babel-plugin-transform-import-meta
, can't remember what the error was with that but couldn't get it to work either.
I'm just importing type
, eg import { type } from 'arktype'
so it's happening under the hood somewhereIt seems like a lot of ESM features aren't supported
Also are you using the latest version of arktype? I think based on our last conversation I wrapped
import.meta
in a try catch, unless that doesn't help because it's some static analysis process that doesn't are?I just installed so I assume so,
"^2.0.4"
Sorry I'm so unfamiliar with the ecosystem, but I assume if they want modern packages to be usable, they must have some recommendation of how you're supposed to transpile modern JS?
I'm not using anything that doesn't have broad support in ESM at this point, so it feels like there should be some recommended transpiler option for modern js => whatever they need
Yeah so I guess if it's static hermes it's trying to analyze it even though it's wrapped in a try catch ðŸ«

Yea it seems crazy, every time I have problems like this with react native I wonder why it's a problem.. I'm going to try stepping through the whole process again, I will post here for posterity.
So using
babel-plugin-transform-import-meta
had no effect, same error.
I wonder if this has to do with using pnpm
, I know there are some issues with monorepos and react native. I might try switching to yarn and seeing if the problem persists.
Interesting, I changed from node 18 to node 22 and I get a new error now, intersection.equals is not a function (it is undefined)
I mean ArkType is doing a lot of binding for and tricks for JIT optimizations. Obviously it's all a stable part of JS but maybe if hermes is trying to statically analyze it it can't?
Seems weird, but who knows. Hoping maybe someone else out there has used
arktype
with react native and could share some insight
I tried yarn and that didn't helpYeah I'm sure over time things will be fleshed out on one or both sides. From what I've heard static hermes is still pretty early-days in terms of stability. I'd assume the goal is to be able to support the same modern JS that gets shipped for other runtimes
Yea, I certainly hope so