Prevent configuration file "loading loop" when transpiling TS.#202
Conversation
…ng TypeScript configs.
| if (equal(project.config.rawConfig, config.rawConfig)) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
I added this logic when I saw that there were too many file events happening, but didn't know why and assumed the reason was something outside the scope of this Extension.
Removing it here again, since sometimes we actually want a restart even if the config didn't really change.
|
You can download the latest build of the extension for this PR here: To install the extension, download the file, unzip it and install it in VS Code by selecting "Install from VSIX..." in the Extensions view. Alternatively, run code --install-extension vscode-apollo-0.0.0-build-1726589621.pr-202.commit-2dabc63.vsix --forcefrom the command line. For older builds, please see the edit history of this comment. |
|
I've come to the conclusion that creating this file in another folder is not a good idea, since it would stop any imports from working... doing some changes. |
This was also present in the original
cosmiconfigloader logic, which would compile aapollo.config.tsto aapollo.config.mjsand then import from that file.Problem with this is that that file creation (and deletion) would trigger the file event watcher, which then would trigger another config parse, leading to an infinite loop.
This didn't lead to particularly high system load, since it happened only every 2 seconds or so, with all the async layers involved, but it was definitely problematic.
We now create that file in a temporary directory outside the workspace, and we use
apollo.config.ts.mjs, which is not a valid config file name and wouldn't lead to a loop even if picked up (e.g. if someone opens the system temp folder as a workspace).