Open jspizziri opened 4 months ago
@jspizziri Unfortunately at the moment parts of the ts-toolkit are not NodeJS-compatible, in fact I've never actually tested running it in a NodeJS env. It's definitely possible to do for the ts-toolkit/shared
package (definitely not in e.g. the navigator because that's for web browsers) without much work, and I can add that to a TODO. If you're interested in helping ensure that package's NodeJS compatibility let me know
That specific API is from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter
@chocolatkey , thanks for the response!
So... I feel like a huge idiot now, so I'm sorry for how stupid this next question must sound. If you're not using NodeJS, what runtime are you using to build? I noticed in the GitHub workflow, the CI job seems to at least reference node. Also, I did see that web spec you referenced, so I assumed it was just some sort of TS targeting issue.
I haven't really looked at this project to much until just now as we've been using another epub readium reader (R2D2BC). Again, the more I write this the more I feel like I'm an idiot, so I apologize if I'm missing some sort of fundamental concept or doc I should've read.
Also, in case this is helpful context: the reason I care is that react-native-readium currently supports web in addition to Android and iOS (which is where I'm leveraging the dependency of the @d-i-t-a/reader
)
EDIT: Also, I am potentially interested in helping with node support, but I feel like I don't know enough to be able know if I need that or not.
@jspizziri Basically, there were maintainers for the ts-toolkit before me, and one of them wrote the majority of what is now the ts-toolkit/shared
code. The code at the time was 100% NodeJS compatible. Then, I took over, and have been using this toolkit to develop the web reader at DeMarque, so I added in the navigator and injectables code, plus some new code in the shared models to support the web reader use case. During that process, I broke NodeJS compatibility of the shared
code, and haven't gotten around to fixing it (in fact I didn't realize the issue until now). It seems luckily based on what you said I just need to fix the Intl
stuff, which is a fairly new addition, then it will at least compile for NodeJS.
I'd be interested in having non-web users of the ts-toolkit
, as that was the intention of the shared
code package anyway. We do plan, pretty soon, to actually package up the code into some NPM packages soon to help out with that. I'm sorry we don't have enough documentation yet.
@chocolatkey , I'd be happy to try and pitch in on node compatibility and documentation. I worry that, due to my lack of knowledge about the lib that I'll end up just asking you a ton of questions. If I were to pitch in, it sounds like these might be some areas that would be helpful:
README.md
documentation.testapp
running (note: I tried to do that last night also and ran into some issues).If that sounds like it might be helpful just let me know, and, if so, if you could provide any top level guidance for how you're interacting with the build of the packages and running of the test app that'd be great. Thanks again!
It appears this issue (the issue in my initial report) is related to the tsdx
library. I found a similar issue report here. They filed an issue with tsdx
(back in 2021) and there hasn't been any response. Considering that there have only been 2 commits in the last 4 years on tsdx
in addition to the fact that there are 200 open issues, I think it's probably safe to say that it's not maintained anymore.
As such, It looks like migrating away from it as the build tool is the best solution.
LMK your thoughts.
@jspizziri I'm very sorry about the delay, I ended up very busy and then on a trip. I agree that we need to replace the build tool, since it cannot support the newer TS features beyond ES2020 and is no longer maintained. I've been trying out a new build "system" for the vanilla testapp using tsc and vite, but I'm sure there are many options out there.
P.S. I've removed the prepare
script from the shared toolkit in order to stop tsdx from spamming errors when you install in the toolkit
I just attempted to clone and built the project and ran into the following typescript error:
Repro steps:
git clone git@github.com:readium/ts-toolkit.git
cd ts-toolkit
pnpm install
If I simply add some
@ts-ignore
's to theTextTokenizer.ts
(lines 40 & 50) the install completes successfully.Environment:
macOS@14 pnpm@8.15.7 node@21.7.1