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

sourceMap issues #2109

Open
guybedford opened this issue Apr 26, 2016 · 6 comments
Open

sourceMap issues #2109

guybedford opened this issue Apr 26, 2016 · 6 comments

Comments

@guybedford
Copy link
Contributor

It seems that the inputSourceMap feature may been broken at some point in the last few releases. I'm still working on isolating the exact behaviour, but it seems that the offsets output an invalid source map when using the inputSourceMap (although it can be tricky to catch as the offset issues only arise on larger transpilations from what I've seen).

I will see if I can provide more info soon on this, just to put a placeholder here for now. If there are any ideas what might have caused this do let me know too.

Tracking from systemjs/builder#542.

@guybedford guybedford changed the title Potential inputSourceMap issues sourceMap issues Apr 26, 2016
@johnjbarton
Copy link
Contributor

@guybedford do you know for sure this is only for inputSourceMap? I've thought there may be some problems in our sourcemaps but did not investigate.

@guybedford
Copy link
Contributor Author

Yes it does seem like it is a little more general actually, I'm still working on refining the exact edge cases. Currently what I have is that:

export function f() {
  return 'asdf';
}
f();

works fine, while:

export async function f() {
  return 'asdf';
}
f();

suddenly seems to invalidate the source map. Still investigating exactly what these edge cases are to report back further.

@guybedford
Copy link
Contributor Author

This does seem to be a general issue. I can recreate it in the following cases:

  • Instantiate transformer on a simple function - works fine
  • Instantiate transformer + async transformer an async function - fails
  • Instantiate transformer on more complex code case like the one below - fails
import _classCallCheck from 'npm:[email protected]/babel-helpers/classCallCheck.js';
export function asdf() {
  return 'hello world';
}

asdf([1, 2].concat([]));

export var p = function p() {
  _classCallCheck(this, p);

  console.log('hello world');
};

new p();

@guybedford
Copy link
Contributor Author

So yes this is not related to inputSourceMap actually at all. Also I have a few custom transformers that all work fine. It seems that it is larger code position changes in the instantiate that cause issues here somehow. I haven't checked if it affects other transformers besides the instantiate transformer.

@johnjbarton
Copy link
Contributor

If we can reproduce this w/o modules it is a lot easier to debug. When I try this case:

https://google.github.io/traceur-compiler/demo/repl.html#%2F%2F%20Options%3A%20--source-maps%20%0Afunction%20aClass()%20%7B%7D%0Aexport%20function%20asdf()%20%7B%0A%20%20return%20'hello%20world'%3B%0A%7D%0A%0Aasdf(%5B1%2C%202%5D.concat(%5B%5D))%3B%0A%0Aexport%20var%20p%20%3D%20function%20p()%20%7B%0A%20%20aClass(this%2C%20p)%3B%0A%0A%20%20console.log('hello%20world')%3B%0A%7D%3B%0A%0Anew%20p()%3B

and use Options > SourceMaps the ranges are shown on the repl. The lines look correct but the columns are off.

Is this what you are seeing? How would you describe the problem?

@johnjbarton
Copy link
Contributor

I investigated your case without instantiate and I see some problems with column offsets and with the beginning and end of files (export keyword). But debuggers mostly work on lines so I don't think this explains any significant issue.

I guess I need to figure out how to dynamically compile with instantiate so I can see the sourcemaps in our repl with that option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants