dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

Add annotation to configure how libraries generated by DDC are exported to JavaScript. #27823

Open jacob314 opened 8 years ago

jacob314 commented 8 years ago

In DCC, exports are currently resolved and substituted at compile time just like imports. The only re-export exposed to JS is the main() method.

We should add library level annotations specifying that a library should be fully re-exported to JavaScript to give authors the option of fully exporting certain libraries to JS. In the future, this annotation could impact dart2js codegen as well, exposing the full contents of the specified libraries to JS.

Background: DDC previously attempted to expose all re-exported members to JS but the code was never used internally by DDC so had bugs (JS interop was broken and top level fields behavior was incorrect). Additionally, exposing all exports to JS even though they were never used by Dart code resulted in 6.5% larger code for typical Angular2 applications.

jmesserly commented 6 years ago

moving to area-js_interop for design work; presumably this needs to be done for DDC and dart2js