Meteor-Community-Packages / meteor-typescript

Typescript compiler package
https://packosphere.com/refapp/meteor-typescript
MIT License
5 stars 2 forks source link

Add react-fast-refresh support for meteor 2.0 with HMR #7

Open perbergland opened 3 years ago

perbergland commented 3 years ago

There’s some code to copy from the builtin typescript compiler to add a babel plugin using a new callback parameter sent to the babelcompiler constructor. Just a matter of extending the types and then copying the code and package dependencies

https://github.com/meteor/meteor/pull/11206/commits/088ea8518a7f845b1a09a04608673d7ed6bbd35b

DavidSichau commented 2 years ago

Is there any progress on this. We had to switch back to meteors typescript compiler, as this does not work with HMR.

perbergland commented 2 years ago

We've never had any issues even without this code, HMR works just fine. What problems do you get?

DavidSichau commented 2 years ago

We often need to completely restart meteor, as our code changes are not updated during the development.

This happens most of the time when several edits happen:

  1. edit a file
  2. compiler starts
  3. edit another file
  4. compiler from first file finishes

The app ends up during development in an unpredictable state, where some changes might be added to the code and other not. We need then to restart the application to get it clean state again.

One reason might be our large code base. The compiler takes about 40sec on the first run to compile all code.

perbergland commented 2 years ago

Ah I see yes that happened to us too (I mentioned it in the Meteor Slack) and the workaround we have in place and that works fine for us is the following setting in tsconfig.json. It seems more of a bug in the Typescript watch-with-polling implementation than anything to do with HMR

  "watchOptions": {
    "watchFile": "useFsEvents"
  },
DavidSichau commented 2 years ago

Thanks a lot, we try this out and see if this solves the issues.