1
votes

I created a new project in Dart Editor with the template that prints "Your Dart app is running." to the page and compiled it to js. I put it to my localhost wamp server and it works fine.

However, when I deploy and upload this dart web app to my web server, it doesn't even enter the main() method and errors out with the following

Uncaught ReferenceError: Invalid left-hand side in assignment

Compiled with debug mode enabled, the source maps allow me to see which line causes this, but it appears to be pointing at line 8 which is the closing bracket for the main method.

What the hell is happening here? Why would this compiled dart run fine on my own local web server but completely breaks when hosted on my website? This has been puzzling me for the past few hours and has stopped me from deploying my real application.

Here is a link for a live example of the issue http://pokesharp.com/error/

1
What kind of application is it. Did you use some frameworks like Angular.dart, Polymer, others with transformers, how do your script tags in the index.html page look like (which do you have in which order), how does your main() method look like? - Günter Zöchbauer
As I found out, it isn't only my web app but even the simplest barebone dart app created from the template in Dart Editor, the one that prints "Your Dart app is running" to the page. It uses no library, beside dart:html to access the dom and inject "Your Dart app is running" to a div. - Nicolas Martel
You build it using pub build and deploy the build/web directory? - Günter Zöchbauer
yes, this is simply the content of build/web - Nicolas Martel
What OSes are you using for development and the server it is deployed to? - Günter Zöchbauer

1 Answers

1
votes

The problem were line endings.

This is the original code, executed on my local machine

When uploading this file to my remote host and downloading it back, this is what I found

(With the comments further into the line, commenting out important code)

The problem lies within the line endings. Dart2JS seems to be mixing line endings and these characters were being dropped when uploading to my host with FileZilla. Setting the transfer type to binary will keep the endings and all is good.

The question however is why does Dart2JS mixes line endings? It seems to in CR and LF and certain places.