diff --git a/packages/mason/lib/src/generator.dart b/packages/mason/lib/src/generator.dart index 44bd53bd..899ac760 100644 --- a/packages/mason/lib/src/generator.dart +++ b/packages/mason/lib/src/generator.dart @@ -15,7 +15,13 @@ import 'package:pool/pool.dart'; part 'hooks.dart'; -const bool _isAotCompiled = bool.fromEnvironment('dart.vm.product'); +const bool _isProductMode = bool.fromEnvironment('dart.vm.product'); +const _hookIsolateName = '__mason_hook__'; +bool get _isHookIsolate => Isolate.current.debugName == _hookIsolateName; +bool get _useAot { + if (_isHookIsolate) return false; + return _isProductMode; +} final _descriptorPool = Pool(32); final _partialRegExp = RegExp(r'\{\{~\s(.+)\s\}\}'); @@ -641,7 +647,7 @@ extension on HookFile { } File module(String checksum) { - const extension = _isAotCompiled ? 'aot' : 'dill'; + final extension = _useAot ? 'aot' : 'dill'; return File( p.join( buildDirectory.path, diff --git a/packages/mason/lib/src/hooks.dart b/packages/mason/lib/src/hooks.dart index d5c08871..3a04024d 100644 --- a/packages/mason/lib/src/hooks.dart +++ b/packages/mason/lib/src/hooks.dart @@ -251,8 +251,7 @@ class GeneratorHooks { final uri = await _getHookUri(hook, checksum); if (uri == null) throw HookMissingRunException(hook.path); - - const mode = _isAotCompiled ? 'aot-snapshot' : 'kernel'; + final mode = _useAot ? 'aot-snapshot' : 'kernel'; final progress = logger?.progress('Compiling ${p.basename(hook.path)}'); final result = await Process.run( 'dart', @@ -315,6 +314,7 @@ class GeneratorHooks { [json.encode(vars)], messagePort.sendPort, paused: true, + debugName: _hookIsolateName, ); }