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 provides wrong URIs for source maps #17460

Closed
johnniwinther opened this issue Mar 13, 2014 · 15 comments
Closed

Pub provides wrong URIs for source maps #17460

johnniwinther opened this issue Mar 13, 2014 · 15 comments
Assignees
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures

Comments

@johnniwinther
Copy link
Member

Running

  pub build --mode=debug

generates a source map file using the wrong URIs for the --out and --source-map options. The parsed values are 'web/foo.dart.js' and 'web/foo.dart.js.map' but since the output is generated in 'build/web' the values should have been 'build/web/foo.dart.js' and 'build/web/foo.dart.js.map'.

In the current state the URIs in the "sources" attribute of the source map file don't point currently the source file.

@munificent
Copy link
Member

Strange, they should be just "foo.dart.js". and "foo.dart.js.map". I'll look into it.


Added Accepted label.

@munificent
Copy link
Member

I can't reproduce this locally on bleeding edge.

If you have more precise repro steps, let me know and I'll see what's going on.


Added CannotReproduce label.

@johnniwinther
Copy link
Member Author

Run

  pub build --mode=debug

from 'samples/sunflower/'. In the generated 'samples/sunflower/build/web/sunflower.dart.js.map' the "sources" attribute starts with

"sources": ["../../../sdk/lib/_internal/lib/interceptors.dart","../../../sdk/lib/_internal/lib/js_array.dart","../../../sdk/lib/

This instructs the reader of the source map that the source files are

samples/sunflower/build/web/../../../sdk/lib/_internal/lib/interceptors.dart = samples/sdk/lib/_internal/lib/interceptors.dart
samples/sunflower/build/web/../../../sdk/lib/_internal/lib/js_array.dart =
samples/sdk/lib/_internal/lib/js_array.dart
...

These files don't exist and the path are off-by-one since the source map was told that it would be generated into 'web/sunflower.dart.js.map' and not (correctly) into 'build/web/sunflower.dart.js.map'.

(The "file" attribute in the source map file and the sourceMappingURL attribute in the .js file correctly point to each other.)

@nex3
Copy link
Member

nex3 commented Mar 17, 2014

Set owner to @nex3.
Added Started label.

@nex3
Copy link
Member

nex3 commented Mar 17, 2014

These URLs aren't very robust as they stand; there's no way they'll work as-is in "pub serve", no matter where we tell dart2js that its output is going. It seems like the best solution here is for dart2js to emit absolute "file:" URIs for the Dart SDK sources.

Since this already doesn't work for "pub serve", which is the primary way users will do debugging, I'm going to mark this blocked on a bug for dart2js to generate absolute "file:" URIs.


Added Accepted label.
Marked this as being blocked by #17544.

@johnniwinther
Copy link
Member Author

Only 'pub serve' is blocked on 17544.

Why doesn't 'pub build' produce source maps currently?

@DartBot
Copy link

DartBot commented Mar 19, 2014

This comment was originally written by @zoechi


pub build actually creates source maps (at least it did when I tried recently) but they are not usable for the same reason

@nex3
Copy link
Member

nex3 commented Mar 19, 2014

Why doesn't 'pub build' produce source maps currently?

"pub build" is intended primarily for building deployable apps, not for active development. By default it doesn't include any Dart source files, so there's nothing for a source map to link to anyway.

If you run it with "--mode=debug", it will generate source maps in the same way as "pub serve". We still expect users to run their app in the context of a server, though, so having relative source map paths reaching out of the application aren't feasible.

@munificent
Copy link
Member

Set owner to @munificent.
Added Started label.

@johnniwinther
Copy link
Member Author

@rnystrom: What do you need from dart2js to fix this?

@munificent
Copy link
Member

I'm still working on this, but I think dart2js gives me all I need as far as I can tell. Pub passes its own CompilerProvider to dart2js, so we have a lot of flexibility over what URLs are used.

The main thing we need to fix is that the dart core library sources are not served/built by pub because they aren't in any package. That means there's no valid URL for the source map to point to it.

If we do want source maps to support debugging the Dart core libraries themselves (which I'm assuming we do since that's what this bug is about), Pub will have to make them appear to be more package-like, which is what I'm doing now.

@munificent
Copy link
Member

@munificent
Copy link
Member

I think I have this working now.

Source maps already worked for sources in your application and its dependencies. The broken part was the Dart code library sources. Since those weren't built with the application, there was no meaningful URL that the source map could use to point to.

With this change, pub serve and debug builds in pub build will include the full Dart core library sources as an automatic dependency on a magic "$sdk" package. This means we can make the source map point to "packages/$sdk/lib/_internal/lib/interceptors.dart", etc.

The downside, of course, is that a debug build now includes an extra 700 or so Dart files.

@munificent
Copy link
Member

Added Fixed label.

@johnniwinther johnniwinther added Type-Defect P1 A high priority bug; for example, a single project is unusable or has many test failures labels Mar 25, 2014
@DartBot
Copy link

DartBot commented Jun 5, 2015

This issue has been moved to dart-lang/pub#915.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

4 participants