Which dart2js command is launched by DartEditor?


After reading article found at https://www.dartlang.org/articles/web-ui/tools.html, I tried to compile my application by following it.

My application stored in web/app.html can be successfully compiled to Javascript under DartEditor by using “Run as Javascript” command.

When I try to use following command lines to perform a compilation for deploying in production, I encounter an issue on uncopied package part file.

$ dart --package-root=packages/ packages/web_ui/dwc.dart --out /tmp/dart/ --no-rewrite-urls web/app.html
$ ls lib/app/
model_browser.dart    model_server.dart
$ ls lib/app/src/model/
model_browser.dart    model_server.dart    model_shared.dart
$ cd /tmp/dart
$ dart2js -v app.html_bootstrap.dart --package-root=packages/ -oapp.html_bootstrap.dart.js
info: scanning library file:///private/tmp/dart/_from_packages/bm/model_browser.dart
_from_packages/app/model_browser.dart:12:1: Error: Cannot read "_from_packages/app/src/model/model_shared.dart" (OS Error: No such file or directory, errno = 2).
part 'src/model/model_shared.dart';
info: Error: compiler cancelled: Error: Cannot read "_from_packages/app/src/model/model_shared.dart" (OS Error: No such file or directory, errno = 2).
$ ls _from_packages/app/
model_browser.dart     model_browser.dart.map
$ ls _from_packages/app/src/model/
model_browser.dart     model_browser.dart.map

In fact, “model_shared.dart” file isn’t copied into /tmp/dart/_from_packages/app/src/model/model_shared.dart.
The content of model_browser.dart is following

library model;
import 'dart:json' as json;
import 'package:bm/i18n.dart' as i18n;
import 'package:logging/logging.dart';
import 'package:web_ui/web_ui.dart';
part 'src/model/model_shared.dart';
part 'src/model/model_browser.dart';

DartEditor can launch my application as Javascript. What is the right command line for launching dart2js in order to take into account the “part” statements of my “model” library ?


The issue is linked to “–no-rewrite-urls” option and the absolute path in –out option.
If I remove the “–no-rewrite-urls” option and put a relative path in –out option, the dart2js compilation is successfully done.

Answered By – sestegra

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.