dart2js --output-type=dart --categories=Server path/to/my/small/app
As ignorant end-user it also wasn't intuitive for me that I have to specify 'Server' as category here.Error: Library not found 'dart:io'.
import 'dart:io';
With that knowledge I did expect that I can use the same settings in pubspec.yaml (see https://code.google.com/p/dart/issues/detail?id=19978)--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.
I've written a hop (https://github.com/kevmoo/hop) powered command line toolthat I would like to 'give/distribute' to end users.Use-caseIt is a command line tool that can do various dev related things like building stuff, starting processes etc.It is used inside of a linux virtual machine (our dev environment set up using vagrant).=> I want my end users to be able to just 'use' it like it was self-contained without needing to know anythingabout dart, pub or how to build dart projects and so on.
dart2dart to the rescueIf I understand it correctly the thing I need to do to pull this off is to transpile (?) my dart projectinto a dart file that is self-contained with all its dependencies inlined.
It took me quite some time to figure out that 'dart2dart' as command line tool does not really exist
but that it is a rather oddly named option for the 'dart2js' command line tool (this was not intuitive to me).
I learned that I also need to call it like this:dart2js --output-type=dart --categories=Server path/to/my/small/app
As ignorant end-user it also wasn't intuitive for me that I have to specify 'Server' as category here.The output I got before I did this wasn't very clear:
With that knowledge I did expect that I can use the same settings in pubspec.yaml (see https://code.google.com/p/dart/issues/detail?id=19978)
so I can get the same result by just executing 'pub build tool'.
Maybe I've overlooked something but I was not able to get to that behaviourusing the following settings added to my pubspec.yaml:transformers:
- $dart2js:
minify: true
commandLineOptions: ['--output-type=dart', '--categories=Server']
Am I using the right tools here for what I want to achieve? (being able to distribute a self-contained command line tool)or am I going about it the wrong way?
Is there a way to rename/rearrange dart2js and the dart2dart story to make it a bit less confusing?
(I absolutely understand that the command line tool functionality grew and evolved over time)StrawmanI understand that there might not be an easy solution to this as many use-cases have to be kept in mindand I certainly don't see the whole picture here but here are some thoughts re what I'd naively expect as a user:One command line tool 'dart' to rule them all
* without options => an awesome REPL (see python)* a/file/path => runs / executes the file/app (+ options)* build => generate js or dart files, (+ options like category/context/environment (?), minification, …)* analyze => dart analyzer output (+ options)* fmt/format => formating* version => …
Here I would expect/dream that since pub knows more about the context (directory name convention, pubspec file, …)
and what sensible defaults might be I'd basically just would execute pub build and 'the right thing' (heh)happens depending on what kind of app I have (web, bin, tool — or a combination of them).
Great answers Bob. Thank you.Without having thought this through much I'd expect `pub build` (or maybe explicitly call it like `pub build all`)to look at my directory structure and create:build/web/build/bin/build/tool/(depending on what directories I have (I think this is already the current behaviour))
and by default put an `out.dart` as well as an `out.js` file into each of them.Those files would be self-sustaining (?) and have all their dependencies inlined.
I'd like things in 'build' as simple and self-contained by default as possible.No 'packages' directories (also no symlinks etc). It gets more complicated with assets obviously,I don't have strong opinions about those yet (still need to look into transformers more).
If I only want to build a specific directory (like bin) I'd explicitly call it like 'pub build bin'.
In pubspec.yaml I'd expect that I can add build options (and/or/equal to various transformers?)
like minification, or in the 'command line use case' maybe an option/transformer to declarethat not only do I want out.dart to include all dependencies inlined but also include (?) the vm itself (gen_snapshot (?)).
Ideally I could give a certain set/configuration of transformers a name so I can refer to the specific build I want to do.
This way I can have builds like 'release/production' that might take more time but create an optimized outputvs builds that are fast and more suited for development.
Right now it feels a bit odd to only be able to specify _one_ specific set of transformers (or am I missing something?).
(OT: pub serve seems like a kind of pub build --watch (+ simple server) (?) => awesome)