-
Notifications
You must be signed in to change notification settings - Fork 936
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
Implement "Bit Watch" with support of TS Project References #2677
Comments
After a POC, this is not going to work well.
This dist on the capsule has the SourceMap, which looks something like this:
As you can see, the source-map has the
I discussed this with @ranm8 , and the conclusion is, in short: |
Another POC I tried, similar to the suggestion in the comment above with an improvement - the dists sit in the node_modules dir and no need to link them to the workspace component's dir.
And this is the gist of the compilation process using the ts API:
Similar API exists for watch. Just replace |
After discussing with Ran, we can improve it.
It's wip on #2698. |
…se the compilation during development is happening on the workspace
…se the compilation during development is happening on the workspace (#2702)
In the branch above (harmony/compile-multiple) I was trying a POC of using the project references for the compilation on the capsules. |
Completed. |
Description
Currently,
bit watch
is slow. It runs the whole "compile" process for every change.For TS, it needs to run the compile on the dependencies/dependents as well.
Running
tsc -w
on each one of the capsules is problematic because we'll end up with lots of processes and high memory usage.Describe the solution you'd like
When the compiler is typescript, take advantage of the Project References to speed up the process.
Once implemented, one process of
tsc --build -w
will be running and it'll watch all capsules changes.Additional context
Step 1: the user is running
bit watch
getWatchProccesses(components: Component[])
.watchMultiple(capsulePaths: string[])
. It aggregates them by the compiler version.watchMultiple
.watchMultiple
, creates atsconfig.json
file with the project references in the tmp dir. The file name should be a hash of the capsules-paths withtsconifg.json
suffix. (so one group won't collide with another and only one file is created per group).e.g.: a file
abcdef.tsconfig.json
can have the following:tsc --build abcdef.tsconfig.json -w
from the CLI, and it watches all the directories mentioned in thereferences
array. (each one of the directories above should have its owntsconfig.json
file).tsc
command above and return them all to the Watch extension.Step 2: user changes a component file
bit watch
knows what component-id is it, it reloads the consumer+bitmap and the changed component. The reason for reloading them all is that a component might be tagged in the meanwhile, and the component in-memory is the old version that associated with the older capsule.Step 3A: user changes a Non-TS component file
bit watch
runs the "compile" extension with the component-id.Step 3B: user changes a TS component file
Performance
Tested on the
harmony/dogfooding
branch with our extensions. (171 files, 5,562 LOC, 25 extensions).The watch is still not as fast as I would expect. It takes around 2.5 seconds on v3.8 and about 1.5 seconds when using the new 3.9 version.
When the
tsc -w
is running on the workspace (bit-bin), the watch takes less than a second to complete. Interestingly enough, when usingtsc --build -w
, it takes 3 seconds.I don't understand why
--build
is slower, it should be faster as it uses an incremental build.It has been asked here microsoft/TypeScript#25600 (comment) and I hope it'll be answered.
Understanding this will help us to improve the performance running
tsc --build -w
on the capsules.The text was updated successfully, but these errors were encountered: