mustache icon indicating copy to clipboard operation
mustache copied to clipboard

Executed dart2native report error error: import of dart:mirrors is not supported in the current Dart runtime

Open nimengbo opened this issue 5 years ago • 2 comments

import 'package:mustache/mustache.dart' as mustache;
import 'file_system.dart';

void renderTemplate(String absoluteSourcePath, String finalDestinationPath,
    Map<String, dynamic> context) {
  final sourceFile = fs.file(absoluteSourcePath);
  final templateContents = sourceFile.readAsStringSync();
  final renderedContents =
      mustache.Template(templateContents).renderString(context);

  final finalDestinationFile = fs.file(finalDestinationPath);
  finalDestinationFile.writeAsStringSync(renderedContents);
}

remove mustache import , dart2native can output the bin

nimengbo avatar Jan 07 '20 06:01 nimengbo

The library has a hard dependency on dart:mirrors at the moment. This means it's not possible to use with dart2native.

Should be pretty easy for someone to implement a patch.

See: https://github.com/xxgreg/mustache/issues/19#issuecomment-562525727

xxgreg avatar Jan 13 '20 03:01 xxgreg

I ran into exactly the same thing trying to do dart2native on dart-sitegen which had a dependency on this package and can confirm that changing over to reflected-mustache fork allows dart2native to compile.

maks avatar Jul 03 '20 02:07 maks