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

Adding Source Map causes code to become mangled #1782

Closed
mystor opened this Issue Jan 24, 2014 · 7 comments

Comments

Projects
None yet
3 participants
@mystor

mystor commented Jan 24, 2014

I have compiled some source code with only simple compression using clojurescript. This leads to a rather large source file with source maps. Using a package, I am trying to associate a source map with the source file, but when I do so, it causes the original source to become mangled, causing some random characters to be lost (unsurprisingly causing errors).

Reproduction here: https://github.com/mystor/meteor-sourcemap-bug

To reproduce, run the meteor app, and visit it on the client, you will see an error in the log, and the javascript will be malformed. If you remove the code in packages/mypackage/plugin/compile.js to add a source map, you will see that the code is not mangled and works fine.

@n1mmy

This comment has been minimized.

Member

n1mmy commented Feb 10, 2014

Thanks for the clear reproduction. We've repro'd the problem and will look into more.

@glasser

This comment has been minimized.

Member

glasser commented Feb 11, 2014

The problem is that this source map seems to have its mappings out of order (some of the relative generated column indices are negative). The library we use to process source maps (mozilla's library) assumes this isn't the case, and croaks. The Source Map spec is vague enough that I can't tell if this is a valid file or not.

How did you actually generate this file? With Clojurescript? Looking at https://github.com/clojure/clojurescript/blob/7c7fec5c056012c4d922727596d44389972147e7/src/clj/cljs/source_map.clj#L10 it sure looks like they expect the columns to be sorted.

@mystor

This comment has been minimized.

mystor commented Feb 11, 2014

Ive added a branch to the reproduction to demonstrate how I created the files:
https://github.com/mystor/meteor-sourcemap-bug/tree/compiled

@glasser

This comment has been minimized.

Member

glasser commented Feb 11, 2014

Hmm, I think your demonstration requires me to know a little more about ClojureScript than I do to actually play with it.

But the good news is that the source-map maintainers think that your map is legitimate, and they accepted my PR to process it correctly. I'll do a new build and get this into the next release.

@mystor

This comment has been minimized.

mystor commented Feb 11, 2014

Awesome, thanks. Looking forward to the changes.

If you want to compile it, you have to install leiningen, and run lein cljsbuild once (or auto, if you want to keep the compilation running). If you change the project.clj file, you have to restart the leiningen process (and probably clean the build artifacts by running lein cljsbuild clean).

glasser added a commit that referenced this issue Feb 12, 2014

new dev bundle (0.3.31) with newer source-map
Fixes #1782.

This dev bundle also drops optimist from the dev bundle (previously
committed, not built until now).
@glasser

This comment has been minimized.

Member

glasser commented Feb 12, 2014

OK, I think this is now fixed on the sso branch. (sso should get merged to devel pretty soon; because the fix was in the dev bundle it made more sense to do it on this branch which already has dev bundle changes rather than build a new one just for devel.) Thanks for the report, and I hope you get clojurescript working with meteor!

@glasser glasser closed this Feb 12, 2014

@mystor

This comment has been minimized.

mystor commented Feb 12, 2014

Thanks, Its coming along well, other than the source-map problems, I mostly need to create some clojurescript interfaces to Meteor (and externs files for meteor so that google's closure advanced compilation doesn't mangle the names).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment