Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pub build fails if project has been "Run as JavaScript" #704

Closed
DartBot opened this issue Jun 5, 2015 · 14 comments
Closed

Pub build fails if project has been "Run as JavaScript" #704

DartBot opened this issue Jun 5, 2015 · 14 comments
Assignees
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

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


What steps will reproduce the problem?

  1. Take a small sample project.
  2. Right click the index.html file and click 'run as javascript'
  3. Run pub build without deleting the previous javascript assets

What is the expected output? What do you see instead?
Expect that the project is built into the build/ directory. Instead it fails with an error:
"Transforms {Dart2JS on myproject|web/myproject.dart} all emitted asset myproject|web/myproject.dart.js."

It appears pub build does't know how to deal with already built javascript files.

What version of the product are you using? On what operating system?
Ubuntu 13.10 64-bit
Dart Editor version 0.8.7_r29341 (64-bit)
Dart SDK version 0.8.7.0_r29341

Please provide any additional information below.
Deleting the javascript files (.dart.js, .dart.precompiled.js, .dart.js.map, .dart.js.deps) and running pub build works correctly.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/2108507?v=3" align="left" width="48" height="48"hspace="10"> Comment by dgrove


cc @sigmundch.
Added Area-Pub, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/2049220?v=3" align="left" width="48" height="48"hspace="10"> Comment by sigmundch


Thanks Matt for the error report!

Seems like this is exactly the kind of conflicts mentioned in issue dart-archive/barback#18.

Bob/Nathan - I'm not marking this yet as a duplicate with that issue because this might be a very common scenario and we might don't want to nag users with an error message all the time. Some alternatives could be:
 - switch the editor to stop calling dart2js and call pub-build always when you say "Run as Javascript", maybe even pass extra arguments to pub-build to let you know which transformer and asset we are interested in building.
 - add some extra logic in pub for this particular scenario.

Thoughts?


cc @nex3.
cc @munificent.
Marked this as being blocked by dart-archive/barback#18.

@DartBot DartBot added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) Fixed labels Jun 5, 2015
@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


I'm not a big fan of adding extra logic to silently ignore this case. We don't really have a good way of knowing whether it's okay to overwrite the existing JS file when running "pub build", and we don't want to silently do it if it's not okay.

I think the ideal final state here is for the editor to do all its compilation stuff through pub/barback. That's a ways away at the moment, though.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


We should definitely do something better here in the short term.

Once #­14554 is fixed, we could workaround this by having the dart2js transformer in pub try to read the existing .dart.js file as a secondary input. (Although getting that to gracefully handle the JS file not existing will be tricky.)

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Issue dart-lang/sdk#15664 has been merged into this issue.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Issue dart-lang/sdk#15823 has been merged into this issue.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Added Started label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Removed Priority-Unassigned label.
Added Priority-High label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Set owner to @munificent.
Added Fixed label.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/5479?v=3" align="left" width="48" height="48"hspace="10"> Comment by sethladd


Thanks! What's the resolution? That is, how was it fixed?

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


The problem is that barback will rightfully complain if it sees a file collision: if two transformers try to generate a file with the same path, or if a transformer generates a file that collides with a source file already on disk. In this case, it's the latter. There's already a foo.dart.js file on disk, so when the dart2js transformer tries to create that too, pub raises an error.

The solution is pretty simple. In pub build, if we see a file in your package named ".dart.js", we assume it was created by dart2js and just pretend it doesn't exist since pub's own dart2js transformer will be creating it.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Issue #819 has been merged into this issue.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

This comment was originally written by Splakta...@gmail.com


I was running into this tonight, after seeing this issue I checked for an update, updated, and the issue was resolved.

Thank you!

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://avatars.githubusercontent.com/u/46275?v=3" align="left" width="48" height="48"hspace="10"> Comment by munificent


Woo-hoo! \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants