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

Perform TypeScript type checking while bundle-serving #173

Closed
afoxman opened this issue Apr 29, 2021 · 4 comments · Fixed by #447
Closed

Perform TypeScript type checking while bundle-serving #173

afoxman opened this issue Apr 29, 2021 · 4 comments · Fixed by #447
Assignees
Labels
feature: metro This is related to Metro

Comments

@afoxman
Copy link
Contributor

afoxman commented Apr 29, 2021

This is related to #113. The difference being that I want typescript validation while running a metro bundle server. As source code is updated, metro detects the changes, transpiles, and publishes delta-bundles through fast-refresh. I want any added/modified files to be transpiled (removed files will be ignored).

The output should show up in the metro bundle-server log console.

Type errors should cause the fast-refresh bundle generation to fail, if possible, leaving the running app unchanged.

@afoxman afoxman self-assigned this Apr 29, 2021
@afoxman
Copy link
Contributor Author

afoxman commented Apr 29, 2021

As this is meant to be a long-running process, it should use tsserver to benefit from caching. This means it will have a substantially different internal architecture than the code in #113.

Initial idea is to use a new experimental hook in the metro config: experimentalSerializerHook. It is supposed to be called anytime the graph changes. That's where I'll start. Then I'll move on to seeing how I can output to the metro log console, and how I can fail the bundle generation process.

@afoxman
Copy link
Contributor Author

afoxman commented Apr 29, 2021

Additional use-case to consider: when a metro server is running, it should react to changes in any dependent package in the repo, not just the app package. If it doesn't make that work because we need it. Once Metro is watching all in-repo dependencies, make sure that typescript validation is happening on these dependencies -- specifically, on the source .ts[x] files.

@afoxman
Copy link
Contributor Author

afoxman commented May 7, 2021

Made a successful prototype using Metro's experimentalSerializerHook which provide delta updates. Works during bundling and serving. Catches changes in the current package and in external packages.

Branch: afoxman/serializer-hook-prototype

@afoxman
Copy link
Contributor Author

afoxman commented May 20, 2021

Another step -- I updated Metro so that calls to experimentalSerializerHook now deliver the target platform as well. We're going to need this when telling TypeScript how to type-check any files that were added/updated.

https://github.com/afoxman/metro/tree/add-platform-to-serializer-hook

Using Verdaccio as a local npm registry, I was able to publish this build (and consumers: react-native, @react-native-community/cli, @rnx-kit) and verify that the entire pipeline is working end-to-end.

@tido64 tido64 added the feature: metro This is related to Metro label Jul 8, 2021
@afoxman afoxman linked a pull request Jul 13, 2021 that will close this issue
@afoxman afoxman linked a pull request Jul 30, 2021 that will close this issue
@ghost ghost locked as resolved and limited conversation to collaborators Jun 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature: metro This is related to Metro
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants