$ in '–global-js-name==', JQuery compatibility and Sublime Text – Build Systems

Issue

By default JS script generated by dart2js has global name $ same as JQuery so it can be problematic to use both simultaneously.
To solve this problem dart2js has parameter –global-js-name=={GLOBAL NAME} but {GLOBAL NAME} must match \$[a-z]* (example: $dart). In the Sublime Text – Build Systems, $ must be escaped with ‘\\’

Working parameter example:

"--global-js-name=\\$dart"

Resulting JS will start with something like:

// Generated by dart2js, the Dart to JavaScript compiler.
(function($dart){var A={}
delete A.x
var B={}
delete B.x
var C={}

Solution

I posted this “Answer Question” for those who might have same problem. It took me reasonably long time to figure out.

Answered By – JAre

Answer Checked By – Clifford M. (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.