0
votes

When I add simple dart files anywhere in my existing Eclipse project, what do I have to do and what will be the limitiations and work arounds in order to make it work.

Update:

Some additional information might be helpful. What I use is a custom web server serving dart and js as simple files (dynamically on request). So I can not simply follow the dart way of things. The dart files would be rather sources only being used during development and converted to js files before the actual check in of the new version.

Therefore I would like to add the dart files in exactly the same mannor I add my other source. So i would love to have something like src/main/dart and src/test/dart or something.

I would also like being able to run dart in the stand alone vm (stand alone application) instead of the web / browser to simplify some development steps like the development of the model / business layer and add simplified testing. Also we want to evaluate if there is the possibility to start dart side processes on the server for additional simplification.

So the scenario is:

  1. Put dart files anywhere (especially in the source tree)
  2. The web framework is non-standard programmer friendly, we can simply add resources from anywhere under virtual directories (src/main/dart -> localhost/dart/)
  3. The dart files will be converted to js prior to checkin
  4. Dart should be able to pickup the right files on debug
  5. Testing and debugging should be possible in standalone mode and in using Dartium

So how can I do this what should I be able to configure.

Update2:

Dart will be used as a JavaScript replacement here. So in the end this is a mid-size web project where the JS/Dart code provides the glue to make the pages functional. It also will drive the backend application which might be single paged but its not decided yet. Best would be to see the dart application as of two applications at once where the backedn application is distinct from the front end functionality that is dynamically added as needed.

For the compilation process to JS I would not mind to create a simple program copying files, compile and recopy files and done. Wouldnt take that long since it would be only needed once or twice a day.

1
I assume this is for Dart in a single page application for the browser (Dart also can run on the server). Of course you can put Dart files everywhere you want but where it makes sense depends on what you want Dart to do for you ;-). Your question contains no information about that. - Günter Zöchbauer
Thanks for the hint. I have updated the question. - Martin Kersten
You still didn't say what you want Dart do for you. - Günter Zöchbauer

1 Answers

0
votes

You need to create a Dart pub package.
That is a directory containing the file pubspec.yaml.
You can put the Dart script and HTML files in the web and or lib subdirectory of the Dart package.
When you run pub build the deployable output is generated in the build/web subdirectory.
This deployable files can be served by your web server like any other static web content like HTML, CSS, JavaScript files.

update

  1. I can't think of a way doing this
    Dart isn't like JavaScript where you add some event handler script here and there. I can't see how this would make sense anyway. More information about what you want Dart do for you is necessary to answer this - see my comment above.

  2. You need the build step prior to serve generated JavaScript. A Dart app is built entirely at once not file by file.

  3. this is what pub build does. The output is written to my_dart_package/build/web

  4. You can debug Dart as Dart (in Dartium, DartEditor or any other IDE that supports debugging Dart code) or after the build step using source maps in a browser like Chrome, FireFox, ...

  5. You can debug non-web code standalone using the debugger of DartEditor, WebStorm, ... You can create unit tests that invoke methods on Dart classes (model classes, PODO, ...) without a browser.
    When you want to debug code that depends on the dart:html package you can only do it using a browser.

update2

You could create three packages - server - client - shared

Dynamically loading functionality is already supported. The functionality has to be available at build time but can be loaded 'deferred' at first access or on request but this has nothing to do with the server part of Dart this is client-only functionality. Any web server can be used for that (for example Apache).

The server usually provided some data APIs (HTTP, REST, WebSocket, ...) for the client.