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

Single character segment compatibility (needed for traceur) #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

conartist6
Copy link

Sorcery wasn't working with Traceur because Traceur's sourcemaps sometimes omit segment bytes when they are 0. A valid sourcemap segment as output by traceur (and permitted by the v3 spec) is `A', however sorcery chokes on this.

I didn't write the slash function, it's just what the newest babel generated when I installed and built with npm.

@Rich-Harris
Copy link
Owner

Thanks for the PR! Have you tried using the most recent version of sorcery (0.6.2)? I added this commit yesterday which is similar (see #10) - though rather than filling in the blanks as 0, it basically treats 1-length segments as junk (since AFAICT they don't contains any useful information). Looking at your commit b127aac, the code on lines 136-139 of Node.js won't run because of line 134 (though you've made me realise that I didn't implement the same logic for line mappings). Let me know if 0.6.2 still fails with Traceur.

The slash stuff is probably just because the most up-to-date dist files weren't in the repo (they get rebuilt on npm publish, sometimes I forget to commit them :S). In fact it's probably best to exclude dist files from PRs (I would remove them from the repo altogether but that's inconvenient for some people), I should really add a CONTRIBUTING.md to that effect, sorry

@conartist6
Copy link
Author

You're quite right. Great! I love the tool, there's really no comparable substitute for what I need to do.

@conartist6 conartist6 closed this Jun 8, 2015
@conartist6
Copy link
Author

Well, looking again at the code, it does seem to be the case that sorcery would stop trying to map further back if it encountered a short form segment. It seemed to me like a short form segment expresses exactly the same information doesn't it, so why would it be handled differently?

@conartist6
Copy link
Author

I just got back to working on my code that uses sorcery and my code is still broken. If you'd like I can provide you my use case for testing.

One problem is that the line mapping fallback section still doesn't have any logic, but also your logic is still incorrect. If you create an empty source map it's default meaning is not that all lines in the file map directly to the corresponding lines in the source. By default all lines in the file with the map are new/generated, and have no relation to the original. Therefore the segment A is not junk information, it means "Line 0 in this file is identical to line 0 in the source file of index 0." This is the same meaning as the segment AAAA which your code does not discard.

@conartist6 conartist6 reopened this Jun 22, 2015
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

Successfully merging this pull request may close these issues.

None yet

2 participants