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

When composing source maps, utilize source content provided in an input map #2921

Closed

Conversation

ChadKillingsworth
Copy link
Collaborator

I discovered that with the JS version, source maps are not composed. This turned out to be from a bug where we only use the sourcesContent from an input source map to display errors and we only load the content from disk.

In addition, we only composed source maps if the content of the original file could be loaded. This wasn't needed.

Adds support to source maps where content provided in an input source map can be forwarded to the output source map. Also allows the GWT version to compose source maps when the input source map provides the original content in the sourcesContent field.


private static String resolveSibling(String path1, String path2) {
List<String> path1Parts = new ArrayList(Arrays.asList(path1.split("/")));
List<String> path2Parts = new ArrayList(Arrays.asList(path2.split("/")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add diamond operators.

Compiler compiler = new Compiler();
Result result = compiler.compile(externs, ImmutableList.copyOf(sources), options);
assertTrue(result.success);
assertEquals(result.errors.length, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we get a little better error message if we reword as:
assertThat(result.errors).isEmpty();

Compiler compiler = new Compiler();
Result result = compiler.compile(externs, ImmutableList.copyOf(sources), options);
assertTrue(result.success);
assertEquals(result.errors.length, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

path2Parts.remove(path2Pos);
} else if (path2Parts.get(path2Pos).equals("..")) {
path2Parts.remove(path2Pos);
path1Parts.remove(path1Parts.size() - 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing crashes on this loop like:

java.lang.IndexOutOfBoundsException: Index -1 out-of-bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.remove(ArrayList.java:517)
at com.google.javascript.jscomp.Compiler.resolveSibling(Compiler.java:3730)
at com.google.javascript.jscomp.Compiler.getSourceMapping(Compiler.java:2931)
at com.google.javascript.jscomp.LightweightMessageFormatter.format(LightweightMessageFormatter.java:96)
at com.google.javascript.jscomp.LightweightMessageFormatter.formatWarning(LightweightMessageFormatter.java:80)
at com.google.javascript.jscomp.JSError.format(JSError.java:174)

@ChadKillingsworth
Copy link
Collaborator Author

Fixed. Let me know if you want me to squash the commits.

@blickly
Copy link
Contributor

blickly commented May 18, 2018

LGTM, let's squash and I'll bring it in! Thanks Chad

@ChadKillingsworth
Copy link
Collaborator Author

Hmm 2008247 did some of the same work. I'll have to see what of my changes still needs applied.

@ChadKillingsworth
Copy link
Collaborator Author

@blickly squashed. This is significantly simpler due to 2008247 handling many of the same concerns.

@blickly
Copy link
Contributor

blickly commented May 22, 2018

OK, looks good. Was dropping the unit tests intentional?

@ChadKillingsworth
Copy link
Collaborator Author

@blickly I prefer to have the tests, but they were not actually failing (at least when I ran it). I'm not sure why. A lot of things changed with the other commit and I haven't had a chance to fully understand the implications.

@brad4d brad4d closed this in 8013b23 May 22, 2018
@ChadKillingsworth ChadKillingsworth deleted the source-maps-content branch June 4, 2018 11:23
Yannic pushed a commit to Yannic/com_google_closure_compiler that referenced this pull request Jul 16, 2018
…ce file cannot be located

Closes google#2921

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=197595899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants