0

I would like to make sure that a class and all its members are not tree shaken when compiled with Dart2JS.

There used to be a MirrorsUsed annotation but that is long gone.

Anyway to do that nowadays without having to create an object of the class and using its members?

Maybe a Pragma annotation?

Jonathan
  • 4,724
  • 7
  • 45
  • 65
  • I still see the MirrorsUsed annotation in the docs for the latest version of Dart. May I ask what you're trying to achieve here? You could always just disable optimization if you don't want tree shaking. – Christopher Moore Feb 01 '22 at 14:11
  • Dart2JS doesn't compile the file if it sees the import of dart:mirrors. I am doing some tests with webcomponents and Dart – Jonathan Feb 01 '22 at 14:50
  • Ah yes, I see it's deprecated. Could you clarify what you're trying to achieve here? – Christopher Moore Feb 01 '22 at 14:58
  • I've found few ways to work with webcomponents and one of them I would need that some methods should not be tree shaken and also retain their original names. I thought there would be a pragma or another annotation for that – Jonathan Feb 01 '22 at 15:04
  • It seems like you want JS interop. Look into that instead. – Christopher Moore Feb 01 '22 at 15:23
  • unfortunately Dart is not ready for webcomponents with JS interop – Jonathan Feb 03 '22 at 14:30

0 Answers0