diff --git a/packages/snaps-cli/src/commands/watch/implementation.ts b/packages/snaps-cli/src/commands/watch/implementation.ts index e7e540ed62..d9b8660854 100644 --- a/packages/snaps-cli/src/commands/watch/implementation.ts +++ b/packages/snaps-cli/src/commands/watch/implementation.ts @@ -1,3 +1,4 @@ +import { assert } from '@metamask/utils'; import { basename } from 'path'; import type { Watching } from 'webpack'; @@ -39,6 +40,11 @@ export async function watch( return; } + assert( + compiler.watching, + 'Expected `compiler.watching` to be defined.', + ); + resolve(compiler.watching); }, ); diff --git a/packages/snaps-cli/src/webpack/plugins.ts b/packages/snaps-cli/src/webpack/plugins.ts index ca90580c7e..307fa2b953 100644 --- a/packages/snaps-cli/src/webpack/plugins.ts +++ b/packages/snaps-cli/src/webpack/plugins.ts @@ -5,7 +5,6 @@ import type { Ora } from 'ora'; import type { Compiler, ProvidePlugin, - ResolvePluginInstance, Resolver, StatsError, WebpackPluginInstance, @@ -231,6 +230,13 @@ export class SnapsWatchPlugin implements WebpackPluginInstance { } } +/** + * Webpack's resolver plugin interface, which is not exported by Webpack. + */ +type ResolverPlugin = { + apply: (resolver: Resolver) => void; +}; + /** * The options for the {@link SnapsBuiltInResolver}. */ @@ -247,7 +253,7 @@ export type SnapsBuiltInResolverOptions = { * plugin is used to warn the user when they try to import a built-in module, * when no fallback is configured. */ -export class SnapsBuiltInResolver implements ResolvePluginInstance { +export class SnapsBuiltInResolver implements ResolverPlugin { /** * The built-in modules that have been imported, but not resolved. */