Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix synthesized template-only components crash
This fixes the first scenario detailed in #1619, where a synthesized template-only component .js file is not cleaned up when the corresponding .hbs file is deleted. There are actually two bugs here. The first issue is we never attempt to clean up these unneeded files, which is fixed by keeping track of which of the emitted files are still needed after the main loop. The second issue is that, even with that fix, it still does not work, because we are incorrectly using the async version of the fs API here without awaiting for the promise. With the way the promisify code is written, the fs delete is actually scheduled to happen on the microtask queue, so by the time the `mergeTrees` code runs, the deletion hasn't actually happened yet. Since the synthesized tree appears after the appTree, I believe (but haven't tested) this has also been causing a different bug, where if you started with just a `.hbs` file, then add a `.js` file later, the new file does not actually take effect until one more build later, since the build triggered by the `.js` file creation would get shadowed by the previously synthesized template-only component file. Perhaps no caught this issue because the typical workflow involves creating either an empty file or generating a stub `.js` file, then filling it in with the actual content. By the "first meaningful save", the deletion would probably have gone through and this would self-resolve.
- Loading branch information