1
votes

After building a Google Dart web app in Dart Editor (the Pub Build (Generates JS) option) the folder layout is like this. My app imports both dart:html and dart:async but It seems I can upload everything but the $sdk folder to my server and the app will run fine in both Dartium and in other browsers. Is there some reason I need to upload the $sdk folder, and what is it for? Tried googling but I see no answer, thanks in advance!

Edit: Here's a working example of my project from DartEditor 1.5.8 and below is the code for it.

hexclock.dart:

import 'dart:html';
import 'dart:async';
DateTime theTime;
String theHour, theMinute, theSecond;
Timer theTimer;
void main() {
  theTimer = new Timer.periodic(new Duration(seconds: 1), getTime);
}

void updateColours(){
  String bgcol = "#" + theHour + theMinute + theSecond;
  querySelector("body").style.backgroundColor = bgcol;
}

void printTime() {
  querySelector("#hour").text = theHour;
  querySelector("#minute").text = theMinute;
  querySelector("#second").text = theSecond;
}

void getTimeInit(){
  theTime = new DateTime.now();
  theHour = "${checkZero(theTime.hour)}";
  theMinute = "${checkZero(theTime.minute)}";
  theSecond = "${checkZero(theTime.second)}";
  printTime();
  updateColours();
}

void getTime(Timer t){
  theTime = new DateTime.now();
  theHour = "${checkZero(theTime.hour)}";
  theMinute = "${checkZero(theTime.minute)}";
  theSecond = "${checkZero(theTime.second)}";
  querySelector("#title").style.opacity = "0";
  querySelector("#clock").style.opacity = "1";
  printTime();
  updateColours();
}

String checkZero(int anInt){
  if (anInt < 10)
    return "0${anInt}";
  else
    return "${anInt}";
}

hexclock.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>HexClock</title>
    <script async type="application/dart" src="hexclock.dart"></script>
    <script async src="packages/browser/dart.js"></script>
    <link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="hexclock.css">
  </head>
  <body> 
    <div id="title" class="centre">hexclock</div>
    <div id="clock" class="centre">#<span id="hour">&nbsp;&nbsp;</span><span id="minute">&nbsp;&nbsp;</span><span id="second">&nbsp;&nbsp;</span></div>
  </body>
</html>

pubspec.yaml:

name: HexClock
description: A sample web application
dependencies:
  browser: any
2
I don't have this folder. What Dart version are you using?Günter Zöchbauer
I have Dart Editor 1.5.8Chris

2 Answers

2
votes

In the pub source code I found this:

  // "$sdk" is a pseudo-package that allows the dart2js transformer to find
  // the Dart core libraries without hitting the file system directly. This
  // ensures they work with source maps.
  var libPath = path.join(sdk.rootDirectory, "lib");
  var sdkSources = listDir(libPath, recursive: true)
      .where((file) => path.extension(file) == ".dart")
      .map((file) {
    var idPath = path.join("lib",
        path.relative(file, from: sdk.rootDirectory));
    return new AssetId('\$sdk', path.toUri(idPath).toString());
  });

I don't know if this matches exactly what you're seeing, but my guess is that it's related. This would in theory allow client-side debugging even through SDK functions, which could be very useful.

1
votes

Basically the entire build folder is intended to be deployed.
There are some redundant files like the *.dart.pecompiled.js which are only necessary for CSP environments (Chrome App for example).
I think there was a recent change so that these files are not generated anymore.

There might be other things redundant too but I haven't seen any information about it yet.

You could try with a Dart 1.6 release (stable should be out) and check if this was dropped or if there has to be another explanation.
I use always bleeding_edge which is currently 1.7+.

Another explanation is that this is only created when you build in debug mode.
DartEditor does this by default.

Try pub build from the command line to see if it is still generated.