-
-
Notifications
You must be signed in to change notification settings - Fork 433
with projectReferences:true, referenced source files are not watched #1042
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
Comments
I suspect this is a duplicate of one of the existing project references issues. I believe @andrewbranch may be looking at this at some point, but I must confess I haven't been tracking this. If you or anyone else would like to assist it would be most welcome 🥰 |
I'm stuck on the same issue. When we "yarn dev" start webpack-dev-server, the referenced project is built and compiled *.js files are written to disk. Subsequent changes trigger build updates, but these changes are not reflected in the compiled *.js files, and the consuming project does not update. Manually changing the compiled *.js files does trigger an update in the consuming project. Behind this question appears to be a fundamental question about how project references should work? #815 (comment). I feel project references should get written to disk, as this would enable/take advantage of TSC incremental builds(?). The goal of workspaces/project references is (?) to have a seamless DX across your whole codebase - from core/utilities/components/app, while maintaining the referenced projects black-box-yness. I think this is the issue being looked at in #1028, but I'm not sure. After several days (and nights) of determined digging to build the kind of DX I'm used to in native development, I feel like I know less about what is supposed to happen than when I started. In the meantime I've dropped down to using "tsc --build --watch" to compile and setting webpack to watch the output js files. This works, but then requires more setup for copying around css modules etc, which kinda seems to undo some of the magic of project references. |
(side note - I'd be happy to assist if I could get some guidance on what is -supposed- to happen. ts-loader is a substantial codebase, and I gave up digging when I realised that typescript & ts-loader both have file-watchers in them and I didn't know which of them should be responsible for tracking file updates). |
Happy new year @andrewbranch! Is there any chance you could give @FrozenKiwi some pointers to get them started? I'm very keen to get people who are willing to help involved, but I'm not super knowledgeable about where the project references stuff has got to. It looks like @sheetalkamat started work on something but that that is paused at present? |
@johnnyreilly I am waiting for help from @TheLarkInn to the road blockers I hit while working on project references PR #1028 |
Awesome - thanks for the update @sheetalkamat! |
what are the roadblocks there? maybe someone else can help. would be awesome to get this working. |
I'm afraid I don't know; if @sheetalkamat or @TheLarkInn are able to advise that'd be amazing and could possibly help someone else move this forward. As always I'd like to say, this is open source and there's no requirement on anybody to do anything. Everything that is done is appreciated; no problems if there's other things going on. ❤️🌻 |
Here is the progress and road block that I have hit. If anyone can help, I can work with that person to see what needs to be done. The work in progress ts-loader changes for project references are at:: #1028 The steps to setup ts-loader are:: The projects in test\comparison-tests\projectReference* are the examples for the project reference scenario. Working scenario
Scenario that is not working
I think in general we want to be able to convey that lib\out\index.js depends on lib\index.ts since that’s just simple case if there are transitive references (eg. lib\index.ts depending on lib2\index.ts) we want to specify that as well. Typescript knows the output and input filename relation for these and that is not being able to conveyed is causing this in my opinion. |
I just read the typescript documentation about project references and never used it, so I may not be aware of all the details of project references. That's how I understand ts-loader should work with projectReferences by the README:
Correct me if this is wrong... Note: It's pretty unusual for webpack loaders to write files to the disk. I heard some rumors that the typescript compiler doesn't allow to read files from memory, so I we need to tolerate that. Writing files into the current directory probably lead to weird repeated watching triggers, so you may check if it's possible to use a separate directory for output files ( Anyway here is a design I would propose: But first some notes: You can add and compile an unconnected module with the So here my design idea: When
This should result in the following workflow:
As As When a application file has changed only Hope this helps There is a |
Thanks so much @sokra - that's incredibly helpful! |
@sokra thank you.. I will experiment with your proposal in our next milestone making sure that typescript API is sound and make any necessary changes and post back.. It would be sometime later next week or a week after that.. |
Would be great to get this solved. We ran into this issue in a monorepo with yarn workspaces where we have a vue frontend (generated by vue cli) with some shared packages. On initial yarn serve everything works and ts loader is building the shared packages. On file changes inside the frontend src directory or inside the dist directory of the shared packages (e.g. by manually run tsc -b inside a shared package) rebuild the frontend app. But changes in the src directory of the shared packages aren't recognized. I was able to detect file changes by adding a context dependecy to the compilation inside a webpack afterCompile hook, but it did not rebuild the shared package. If you need a tiny repro repo let me know. PS: Unfortunately i am relatively new to webpack and typescript, otherwise i would like to help. I was looking into the code of ts-loader and was debugging a bit but i don't know what exactly is happening there :D. |
Has anyone found a viable workaround until this is solved? E.g. manually telling webpack-dev-server to watch those files? |
I am currently just directly compiling those projects in my webpack config.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. Please reopen if you'd like to work on this further. |
This is still a problem as of 2021. I'm using Webpack v4 and ts-loader v8.3.0. |
Expected Behaviour
With projectReferences set to true and webpack set up to watch (e.g. via webpack-dev-server), modifications to referenced source files should result in a webpack recompile.
Actual Behaviour
Modifications to the entry seem to result in a recompile, but referenced projects that might be dynamically imported do not seem to be watched.
Steps to Reproduce the Problem
the repository linked below has repro instructions
Location of a Minimal Repository that Demonstrates the Issue.
https://github.com/starpit/ts-loader-references-watch-bug
The text was updated successfully, but these errors were encountered: