Skip to content

Built-in dart2js transformer seems to run with '--categories=all' #1201

Closed
@DartBot

Description

@DartBot

<img src="https://avatars.githubusercontent.com/u/5757092?v=3" align="left" width="96" height="96"hspace="10"> Issue by mkustermann
Originally opened as dart-lang/sdk#21786


This can be highly confusing for users who accidentally import 'dart:io' in a web application.

$ cat pubspec.yaml
name: foo
version: 0.1.0

$ cat web/foo.dart
import 'dart:io';
import 'dart:html';

main() {
  query('#foobar');
  stdout.writeln('hello world');
}

$ pub build
Loading source assets...
Building foo...
[Info from Dart2JS]:
Compiling foo|web/foo.dart...
[Info from Dart2JS]:
Took 0:00:05.293322 to compile foo|web/foo.dart.
Built 1 file to "build".

=> It compiles without any warning or error!

Whereas if I run dart2js manually it gives me a proper error message:
$ dart2js web/foo.dart
web/foo.dart:1:8:
Error: Library not found 'dart:io'.
import 'dart:io';
       ^^^^^^^^^
Error: Compilation failed.

I'm not sure if this is intentionally or not, but e.g. for automated scripts which run "pub build" and check for successful building of the application, this can hide errors IMHO.

We should give users warnings/errors as early as possible and never suppress them by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed-not-plannedClosed as we don't intend to take action on the reported issuetype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions