MetaMask / snaps

Extend the functionality of MetaMask using Snaps
https://metamask.io/snaps/
Other
733 stars 561 forks source link

Investigate CLI building twice when using `watch` #2613

Open FrederikBolding opened 4 months ago

FrederikBolding commented 4 months ago

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.

ritave commented 3 months ago

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.