esnow icon indicating copy to clipboard operation
esnow copied to clipboard

The -p option results in an invalid source map

Open lcrespom opened this issue 9 years ago • 5 comments

When I run esnow -e main.es6 -o ./ -f index.js, it generates a fully working source map. However, when I run esnow -e main.es6 -o ./ -f index.js -p, it generates an invalid source map where line numbers do not seem to correspond at all with the source files.

Specifically, when trying to debug index.js with Chrome dev tools, the source files are displayed correctly, but breakpoints and step-by-step debugging (by pressing F10) totally fail. For example:

  • Setting a breakpoint on some lines gets ignored by Chrome: no breakpoint mark is displayed.
  • On some other cases, breakpoint marks are displayed but when running, code stops at a totally different location.
  • Performing a step over a line can result in running the full code. Most probably this is because it will execute the line containing the full minified code.

These problems only manifest with the -p option. Everything works as expected when that option is not present and code is not minified.

Here is the content of minimal JS files used for testing:

main.es6:

import { hello } from './hello.es6';

let name = 'FooBar';
hello(name);

console.log('One');
console.log('Two');

console.log('Three');

hello.es6:

let hello = () => {
    console.log('Hello from main');
}

export { hello };

lcrespom avatar Oct 12 '15 14:10 lcrespom

Hey thanks for the report. Totally missed this. I'll look into it.

khalillechelt avatar Jan 05 '16 15:01 khalillechelt

Thank you! I still have not found any tool combination that transpiles AND minifies AND correctly preserves source maps...

lcrespom avatar Jan 05 '16 15:01 lcrespom

Haha, yeah, that's why I made this :smile:

khalillechelt avatar Jan 05 '16 15:01 khalillechelt

I tested it yesterday and had no problems. Can't reproduce.

khalillechelt avatar Jan 06 '16 12:01 khalillechelt

Will check it out and get back...

On Wed, Jan 6, 2016 at 1:23 PM, Kahlil Lechelt [email protected] wrote:

I tested it yesterday and had no problems. Can't reproduce.

— Reply to this email directly or view it on GitHub https://github.com/kahlil/esnow/issues/2#issuecomment-169311752.

lcrespom avatar Jan 06 '16 23:01 lcrespom