Skip to content
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

[Question] Using a thread worker written in TypeScript #67

Open
omatrot opened this issue Mar 13, 2019 · 9 comments
Open

[Question] Using a thread worker written in TypeScript #67

omatrot opened this issue Mar 13, 2019 · 9 comments

Comments

@omatrot
Copy link

omatrot commented Mar 13, 2019

I'm using Typescript and a worker thread using a lot of modules.
I guess I should take the release route even for development to produce a correct javascript file to be used by this library. Am I wrong?

@cjroth
Copy link

cjroth commented Mar 13, 2019

I'll be on the same page soon when I switch to TS. If you figure this out it'd be great if someone could add it to the readme :)

@omatrot
Copy link
Author

omatrot commented Mar 13, 2019

Have you done it with Javascript with multiple files or only one file containing all the business logic? Are you using native modules?
I've managed to give it a javascript file but it is failing with a red screen telling me that

'DeviceInfo native module is not installed'

DeviceInfo.js: 17:10

This file is here:
./node_modules/react-native/Libraries/Utilities/DeviceInfo.js

@cjroth
Copy link

cjroth commented Mar 13, 2019

I'm using native modules and multiple JS files on iOS but I have not tried Android. The readme has instructions for setting up native modules with Android which requires an additional step. It sounds like you may need to do that.

@omatrot
Copy link
Author

omatrot commented Mar 13, 2019

I've seen that and used it already. The problem is that DeviceInfo is a React Native module !

@cjroth
Copy link

cjroth commented Mar 13, 2019 via email

@omatrot
Copy link
Author

omatrot commented Mar 13, 2019

It is a packager problem, there is a request to the 'thread.js' file to bundle it.
It seems to me that my file is somehow invalid for the bundler which may not be able to require the modules correctly...
How do you import your dependencies at the top of your .js thread file?

@cjroth
Copy link

cjroth commented May 9, 2019

Oops I missed your last comment. Yeah, I just import everything at the top of my js thread file. Importing works just the same as it does in the main RN JS thread though. It's basically a parallel universe.

Were you able to get TS working with the thread? I'm starting to look into moving over to it now.

@genesy
Copy link

genesy commented Dec 12, 2019

Did you guys find a way to solve this?

@lucasew
Copy link

lucasew commented Jul 30, 2022

is it possible to run a string encoded js bundle instead of a file name?

that way one could transpile TS and generate a big chungus JS bundle to run in the worker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants