snaps icon indicating copy to clipboard operation
snaps copied to clipboard

Investigate CLI building twice when using `watch`

Open FrederikBolding opened this issue 1 year ago • 1 comments

When using mm-snap watch, the CLI will rebuild the Snap twice after detecting a change in the source code. Once because the source file changed and once again because rebuilding causes snap.manifest.json to be updated.

We should look into minimizing this and strictly rebuilding when necessary.

FrederikBolding avatar Jul 30 '24 12:07 FrederikBolding

I've investigated the cause.

  1. We use webpack to watch the filesystem including the manifest
  2. We run the webpack plugin to update the manifest outside of webpack build process.
  3. Webpack notices that the manifest has been updated and rebuilds the bundle

I've tried the following:

  1. Webpack has no way to conditionally watch files
  2. Webpack has no way to abort the build for the second change
  3. Debouncing the build by collating modified files does not work
  4. Emitting the updated manifest using webpack APIs does not work

What we could do is to rewrite much of the snaps-cli to manually watch the manifest outside webpack and manually execute a webpack build on manifest update.

For the time being we decided to timebox this issue and not do it at this time.

ritave avatar Aug 13 '24 12:08 ritave