-
Notifications
You must be signed in to change notification settings - Fork 140
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
v2 addon watching not working with BROCCOLI_ENABLED_MEMOIZE
#2194
Comments
@simonihmig the way you using sideWatch seems to be wrong. I compared it with the solution in #1892 (comment) In you repo, When it applies the watched dirs, its already to late. the packager already received the trees from app instance. module.exports = function (defaults) {
let app = new EmberApp(defaults, {
trees: {
app: sideWatch('app', {
watching: ['watch-test'],
}),
},
});
return Compat.compatBuild(app, Webpack);
}; |
You are right @patricklx , thanks a bunch! This also explains why I came up with the diagram above, I think it comes close to what I was getting with the previous wrong setup, but with your suggested changes, the watched dirs become inputs to the compatBuild, so rebuilding works correctly. However, the issue remains for classic builds. Not sure why though, as the WebpackBundler here does seem to receive the watched dirs as inputs as well, but my repo still reproduces this not working with the memoization flag turned on! 🤔 We can get around this though by not using Closing this one, as the Embroider part seems to be ok. Can create another issue in the eai repo if enough people care? /cc @ef4 |
I do not see the issue with the classic build in your repo |
When you run the |
you right, i didn't try with |
The fix there involves using webpack's own file watching, not just broccoli's. We're pretty sure it would also improve rebuild times. It would be a good change, if somebody wants to work on it we could pair on getting started. |
Already done At least on broccoli side |
Is it? Ci is pretty red! :) |
still babel/traverse issues...hopefully they merge the revert soon. |
That would enable using sideWatch as a workaround, but it's not the same thing I was describing. |
Are you saying that the same side-watch based approach would not work with eai? Because it seems to work fine for me!? |
No, I was apparently misunderstanding that this bug report claimed that doesn't work. |
No, it's just the |
When this flag is enabled, any changes in a watched addon do trigger a rebuild, with the changed file being mentioned in the terminal output, so watching itself is working, but the actual changes don't get picked up.
This is happening both in classic builds with eai and
watchDependencies
and with Embroider/Webpack andbroccoli-side-watch
set up.Here is a reproduction, see it's Readme for steps to reproduce.
My current working theory is as follows:
What both
watchDependencies
andbroccoli-side-watch
basically do is wrapping the main app tree with a broccoli-merge-trees that includesWatchedDir
nodes for the addon dist output, something like this (example for eai, but I think it would be similar for Embroider):So when some addon files change, the
WatchedDir
will cause broccoli to get notified to do a rebuild. Without the memoization flag, it will do a full build again, including the whole app tree and webpack stuff, that will then rebuild the code including the changed file. But with the flag enabled, the app tree node will think that nothing has changed (because none of the addon files are actually inputNodes anywhere in that tree, so broccoli does not know about them being involved, only webpack does), so will basically get short-circuited and not do a rebuild nut return the previous output.Again, just my theory, does that make sense?
What puzzles me is the fact that Embroider has this flag enabled by default. So how was this working before under Embroider? Was it even?
Note that I worked on a couple of addon watching related PRs, but they focused on narrowing down the watched folders to not include e.g.
src
. And given that the changed files do trigger a rebuild, I don't think these can have caused that. But in case it helps investigating the issue, I am listing these here:The text was updated successfully, but these errors were encountered: