Git Product home page Git Product logo

Comments (11)

jamesgpearce avatar jamesgpearce commented on September 27, 2024 2

OK, so I've confirmed that TextEncoder was only added in SDK 51. Blog post here.

I am going to add an expo SDK peer dependency to stop people running into this too hard, but if anyone has to run SDK50 or below and forces past the peer requirements, it's possible to work around this issue with the text-encoding polyfill:

npm install text-encoding

And then in the file that imports TinyBase v5:

import 'text-encoding';

cc @brentvatne

from tinybase.

mdj-uk avatar mdj-uk commented on September 27, 2024 1

Update: I've realised that enabling package exports support by setting config.resolver.unstable_enablePackageExports = true; in the metro config file solves the issue.

So I wonder if just documenting that and asking users to enable the setting would be a better solution than having to make a drastic change to the package? (I'm afraid I don't have enough experience to know what problems that setting might cause. In a simple starter app everything is fine.)

But if you make the change I'll be very happy to try the beta

Thanks again

from tinybase.

jamesgpearce avatar jamesgpearce commented on September 27, 2024

Ugh, why are the RN imports so fiddly? I can look at this tomorrow.

from tinybase.

jamesgpearce avatar jamesgpearce commented on September 27, 2024

I think the basic problem is that the library is in lib but the types are in lib/types/with-schemas. Most bundlers get to know about this split from package.json but apparently not Metro. I'll see if I can find a way to get it to work.

from tinybase.

mdj-uk avatar mdj-uk commented on September 27, 2024

Ugh, why are the RN imports so fiddly? I can look at this tomorrow.

My sympathies! Thanks for taking a look

from tinybase.

jamesgpearce avatar jamesgpearce commented on September 27, 2024

OK, I have a horrible thought that the only way to fix this is to relayout the structure of the distributed package so that it matches the import pattern literally (rather than relying on the exports field in package.json).

It should be a barely breaking change but I think I need to put it in the forthcoming v5 release. Would you be OK with trying out a beta of that once I make these changes?

from tinybase.

jamesgpearce avatar jamesgpearce commented on September 27, 2024

That was going to be my other suggestion (but when I tried it it didn't work for me!). Glad you're unblocked though!

from tinybase.

jamesgpearce avatar jamesgpearce commented on September 27, 2024

I'm hoping we are past these sorts of issues in v5.0.0-beta.21

It seems to work great in your app (though still currently needs the --force install). If you get a chance could you give it a whirl yourself please? Thanks!

from tinybase.

mdj-uk avatar mdj-uk commented on September 27, 2024

Hi, as far as I can tell the latest beta works perfectly with expo sdk 51.

I'm afraid it seems to break apps using tinybase with expo 50 though.

As soon as I add the following

import { createStore } from "tinybase";

const store = createStore();

I get an error when running on a (real) android device. Web seems ok. (I'm not able to test iOS)

The not-very-helpful error message:

 ERROR  TypeError: Cannot read property 'prototype' of undefined, js engine: hermes 
    at ContextNavigator (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:149934:24)
    at ExpoRoot (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:149890:28)
    at App
    at ErrorToastContainer (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:194841:24)
    at ErrorOverlay
    at withDevTools(ErrorOverlay) (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:194591:27)
    at RCTView
    at View (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:40188:43)
    at RCTView
    at View (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:40188:43)
    at AppContainer (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:39999:36)
    at main(RootComponent) (http://192.168.1.17:8081/node_modules/expo-router/entry.bundle//&platform=android&dev=true&hot=false&lazy=true&transform.engine=hermes&transform.bytecode=true&transform.routerRoot=app:124871:28)

I've added a branch to my reproduction repo which downgrades from expo 51 to 50 and uses the latest tinybase beta. If you uncomment the lines above in app/(tabs)/index.tsx you'll see the error. Link: https://github.com/mdj-uk/cea/tree/expo-50 (Downgrading to tinybase@latest there's no problem.)

from tinybase.

jamesgpearce avatar jamesgpearce commented on September 27, 2024

what the what

from tinybase.

jamesgpearce avatar jamesgpearce commented on September 27, 2024

Yeah I can repro this on iOS too. Error indicates it doesn't like this integer 🤔 but more likely it's the TextEncoder above it...

image

from tinybase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.