-
Notifications
You must be signed in to change notification settings - Fork 581
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
Need relative paths in source map #1676
Comments
What is your use case for relative sourceRoot? The whole point of sourceRoot is to set the root for the relative paths in the 'sources' property. |
According to source map spec sourceRoot is used to relocate sources on the server. Also traceur populates sourceContents source names are used only to resolve original file names used during compilation. IMO there are really no reason to use this excessive information, especially for the web facing scripts. For the same reason sourceMappingURL in the compiled script should be referencing source map with relative path, not the Also sourceRoot somehow breaks uglify-js2 intermediate sourcemap transformation (I'll fill issue there later), but that's not really related here. |
Now --source-root <false|string|default>. The default option is as before. Fixes google#1676
This is all the spec says about sourceroot:
|
@johnjbarton First of all, in the spec when they say "absolute URL" do they really mean that? E.g. Here's a summary of the issues (overlaps significantly if not completely with @tensai-cirno):
I think part of the problem is that traceur is currently munging 2 different things into the
|
PR #1686 is what I propose to do here. |
Please forgive me if I've missed something, but how does #1686 address the issues raised here? It still doesn't appear to be possible to achieve all of these things at once:
Say I have this dir structure:
And I want to compile {
sourceRoot: '/some/uri',
sources: ['js/sub/b.js]
} How could I achieve that? Currently I can only seem to get either the output I want for {in: '/some/local/path', out: '/some/uri'} |
Please point to the source where this is happening. I can't imagine how that can work, the input paths have to resolve to actual files. |
I mean in the spec it pertains to the paths in
Or do you mean that I'm wrong that the |
I mean that as far as I can tell the The In PR #1686 we allow the |
"Resolve paths" was a poor choice of words on my part.
Yes, this is what I was referring to (which was better worded when I described it as "it's currently used as a local path to generate relative paths for
The spec only references it in terms of applying it to the
That's my point -- you can choose to either generate the I believe that what the |
I can't see how that sourcemap could be useful. The combination of sourceRoot and sources does not exist in the file system. I think we should land PR #1686 and have you try the |
Now --source-root <false|string|default>. The default option is as before. Fixes google#1676
Exactly. How would absolute local file system paths from where traceur compiles be useful to a web browser receiving a source map from a server? My understanding is that the According to the spec:
Both values,
It would be useful if I have a source map at If I have a local file system
Then
I can tell you right now: if |
Couldn't you set |
Perhaps in some situation. I'm talking about making this a general purpose tool that allows the desired output to be generated and doesn't marry the output to a file structure that may or may not exist where traceur compiles. |
I have to agree with @jmm. In general it is not possible to duplicate the virtual path structure of a web application on the local file system of the machine used to build the images - nor is it desirable. |
Perhaps someone can help me understand why Traceur does such complicated (and, from my perspective both as a consumer and maintainer of a few tools built on top Traceur, nonsensical) things with source map filenames. Have you looked at how other tools such as 6to5 do it? Absolute file paths have no place in source map output... |
If you want something different just send a pull request. |
I'd like to understand the motivation behind the current setup first. |
The motivation is someone wanted sourcemaps then someone wanted sourceroot. And options setting in Traceur was such a nightmare, minimal changes were best. I think I've mostly solved this side problem. But work on sourcemaps is a bottomless pit in my experience. I think the best solution is relative I would like to return to the question of whether #1686 is a net improvement or should be dropped. |
I would like my question about |
There are several things called Maybe there are scenarios where |
Or set |
Wouldn't this mean that I have to create a file |
That's the one I'm referring to. What is
What do you mean? Scenarios where you want them to be absolute paths?
I don't understand the example. Can you please provide an example API call illustrating the input parameters, and the resulting output for |
Traceur misappropriates sourceRoot to apply to local input paths and that shouldn't be propagated to consumers of this package. See google/traceur-compiler#1676
As far as I know the only effect is if the
No, I wonder it happens but is not desired. |
You wonder if it happens? Yes, that's a big part of what this discussion has been about. I quote myself:
|
compile(
src,
path.relative('/whatever', sourceName),
outputName,
sourceRoot
) I'm not as familiar with the CLI, but perhaps it needs an additional flag like |
Yep, |
I changed PR #1686 to ensure that the 'sources' are relative and that they are not related to the |
What do you mean by that? The
Good, thank you. While checking out these changes I discovered a different problem: (new traceur.NodeCompiler({sourceMaps: 'inline'}))
.compile(';', '/a/b/c.js', '/x/y/z.js') Results in |
What's the rationale for automatically generating a |
I think I have addressed this issue raised here. If not we need to start fresh anyway. We may decide to default sourceRoot to |
Hi, is there anyway to generate source map without the aboslute path in the file field and without the sourceRoot field?
Are there any cases when full path to project's directory is needed inside sourceRoot?
I've tried some hacking, but no luck so far except breaking tests and sourcesContent field :)
The text was updated successfully, but these errors were encountered: