stitches-native
stitches-native copied to clipboard
Migrate codes to typescript and yarn to pnpm
This repository almost doesn't depend on native library, so you can treat it as simple node_modules. So, I try DX improved migrate some tools.
- yarn to pnpm because pnpm is speedy about clean installation and installation with lock file and cache (benchmark)
- update versions of test and babel tools
- use
@swc/jest
instead of 'babel-jest' from react-native/jest-preset.js. The former is very faster than the latter.Please check benchmark. (e.g.: es5 so on)
And there are additional points worth noting.
- I can replace react-native-bob-build to webpack and swc-loader that accelerates build speed, but I didn't because swc is undergoing developing and there are some deferent behaviors from tsc or babel-typescript we can't fix although most codes work properly, so it is safety to use babel or tsc now. The swc is introduced for high-performance test.
- The reason why can be safe in swc test codes in this repository is that codes of this library doesn't need babel-metro-preset, thus it correctly transpile them and the code is used only in the test environment.
- Expo example project keep yarn, because if you setup a pnpm react-native project, it needs more complex setting to adapt metro-bundler or webpack. (Please check this article).
- I added ts-jest, because your jest configuration or set up files can be written using typescript though it isn't used for transpliation.
- ~I don't still replace ambient files in types directories and it's used as primary exported types although I can do so. That means codes in internal emits js codes and sourcemap without type definitions as before but you can use typescript under development. If the current definitions depend on and need to follow
@stitiches/react
types, we migrate writing them manually to emitting them from tsc, but it's enough now to define and use type advantage in internal. So I want to do that after you will have finished working athttps://github.com/Temzasse/stitches-native/tree/rewrite-media-styles
because you may feel convenient to use typescript and test improvements in the branch with merging this PR soon.~ This is done though loosely typing. But, the logic is almost same first JS file and if these types are wrong, the types are not used in the users' environment.
@Temzasse
I can migrate them to typescript.
~I marked @ts-nocheck
now. Please review it and could you merge it after checking it and unmarking draft?~
~I'll try to remove @ts-nocheck
as much as possible until you have finished reviewing.~
update
I could remove all @ts-nocheck
partial codes are loosely typed, and I had to change two js logics logic though it
affects nothing because I just only add logic to check undefined. It was not checked whether it's undefined but, it must be existed value as before.
https://github.com/Temzasse/stitches-native/pull/45/files#diff-a8848e503173984c129a0807b96c24aa84357346d46b6df7fbe57c7e9bf5a9f6R133
https://github.com/Temzasse/stitches-native/pull/45/files#diff-a8848e503173984c129a0807b96c24aa84357346d46b6df7fbe57c7e9bf5a9f6R114-R120
@Temzasse
Now, this PR includes SWC configuraiton and only rename js files to ts files with @ts-ignore
to prevent js codes from being broken.
Furthermore I notice we need to modify github actions.
- I switched yarn to pnpm in ci
- Change how to run tests in ci. They run only after PR branch have been created, though pushing all branches everytime triggers before.
And https://github.com/Temzasse/stitches-native/actions/runs/3812284842/jobs/6485411228 shows it works fine.