-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Comments
Strange, they should be just "foo.dart.js". and "foo.dart.js.map". I'll look into it. Added Accepted label. |
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. |
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 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.) |
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. |
Only 'pub serve' is blocked on 17544. Why doesn't 'pub build' produce source maps currently? |
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 |
"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. |
Set owner to @munificent. |
@rnystrom: What do you need from dart2js to fix this? |
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. |
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. |
Added Fixed label. |
This issue has been moved to dart-lang/pub#915. |
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.
The text was updated successfully, but these errors were encountered: