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

Allow source maps for non-preprocessed files #893

Open
vojtajina opened this issue Jan 20, 2014 · 4 comments
Open

Allow source maps for non-preprocessed files #893

vojtajina opened this issue Jan 20, 2014 · 4 comments

Comments

@vojtajina
Copy link
Contributor

Based on discussion in #594.

We could add sourceMap attr to file patterns, true.
Also a default preprocessor might check for in-lined source map.

@evillemez
Copy link

Would this be different than this preprocessor?

https://github.com/demerzel3/karma-sourcemap-loader

@JeroMiya
Copy link

+1 for allowing source maps for non-preprocessed files. I typically have my editor compile the output javascript files on save, which is typically much faster than running the preprocessor during a karma run as it can do incremental compilation (and a compile server to keep the compiler 'hot' in the JIT runtime).

However, I would prefer this stack-trace rewriting to simply work without a sourceMap attribute on the output file pattern. Otherwise I would end up being forced to define ALL my file patterns that way, where currently I have just a list of string files and file patterns in the included files.

My alternative:
Have a global setting to turn on automatic source mapping support. When enabled, for each included/served file that uses the standard sourcemap annotation, karma would automatically rewrite stack traces using information from the source map. Additionally, source map files and the original input files should automatically be served but not included, so that for example when I run the dot debug runner I automatically have those files available from the browser debugger. This would greatly reduce noise in my karma config and I think it should be the default behavior given that it's a common use case and doesn't require knowledge of each individual tool (TypeScript, CoffeeScript, etc...) to implement.

@OverZealous
Copy link

:+1

This would really help making TDD/BDD more effective in our build process.

@tschaub
Copy link

tschaub commented Jan 2, 2015

I put together a source-map-support plugin that improves stack traces in Chrome with inline source maps (like those produced from Browserify with the debug option).

Here's a comparison of a stack without/with this plugin.

--- stack-without   2015-01-02 15:02:55.000000000 -0700
+++ stack-with  2015-01-02 15:03:12.000000000 -0700
@@ -1,11 +1,11 @@
 AssertionError: case 2: expected [ 0, 0.6666666666666666 ] to deeply equal [ 0, 0.5 ]
-    at Function.assert.deepEqual (http://localhost:9876/absolute/var/folders/6m/3grlt52x7w3047wy0n6j7dr00000gn/T/2d4c510ad9122153a42db199d1cc8e9553208184.browserify:1848:32)
-    at Context.<anonymous> (http://localhost:9876/absolute/var/folders/6m/3grlt52x7w3047wy0n6j7dr00000gn/T/2d4c510ad9122153a42db199d1cc8e9553208184.browserify:6061:14)
+    at Function.assert.deepEqual (node_modules/chai/lib/chai/interface/assert.js:205:1)
+    at Context.<anonymous> (src/scenes/util/geom.test.js:27:1)
     at callFn (http://localhost:9876/base/node_modules/mocha/mocha.js:4496:21)
     at Test.Runnable.run (http://localhost:9876/base/node_modules/mocha/mocha.js:4489:7)
     at Runner.runTest (http://localhost:9876/base/node_modules/mocha/mocha.js:4892:10)
     at http://localhost:9876/base/node_modules/mocha/mocha.js:4970:12
     at next (http://localhost:9876/base/node_modules/mocha/mocha.js:4817:14)
     at http://localhost:9876/base/node_modules/mocha/mocha.js:4827:7
     at next (http://localhost:9876/base/node_modules/mocha/mocha.js:4766:23)
     at http://localhost:9876/base/node_modules/mocha/mocha.js:4794:5

The plugin simply delegates to the source-map-support package.

Things are still less than ideal. The debugger doesn't generate clickable links for compiled sources. I'll see if there's a way to address this.

Not sure if this will work for other cases, but it is working well for me when using karma-browserify to generate bundles before tests run.

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

No branches or pull requests

6 participants