nikku / karma-browserify

A fast Browserify integration for Karma that handles large projects with ease
MIT License
321 stars 49 forks source link

Error: No element indexed by 0 for commented file #161

Closed justinwiley closed 8 years ago

justinwiley commented 8 years ago

I'm seeing a persistent error with latest karma-browserify when source maps are enabled (debug: true in the config file).

After throwing some debugging into Combiner.addFile, it's failing on a test file that is entirely commented out.

For example:

// foobar

Easy issue to correct once I figured out the issue, but the warning was pretty cryptic

Stacktrace

Error: No element indexed by 0
  at ArraySet_at [as at] (node_modules/karma-browserify/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/source-map/lib/source-map/array-set.js:93:11)
  at SourceMapConsumer.<anonymous> (node_modules/karma-browserify/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/source-map/lib/source-map/source-map-consumer.js:147:79)
  at Array.map (native)
  at SourceMapConsumer_eachMapping [as eachMapping] (node_modules/karma-browserify/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/source-map/lib/source-map/source-map-consumer.js:146:16)
  at module.exports (node_modules/karma-browserify/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/lib/mappings-from-map.js:13:12)
  at Combiner._addExistingMap (node_modules/karma-browserify/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/index.js:70:18)
  at Combiner.addFile (node_modules/karma-browserify/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/index.js:113:49)
  at DestroyableTransform.write [as _transform] (node_modules/karma-browserify/node_modules/browserify/node_modules/browser-pack/index.js:63:23)
  at DestroyableTransform.Transform._read (node_modules/karma-browserify/node_modules/browserify/node_modules/readable-stream/lib/_stream_transform.js:184:10)
  at DestroyableTransform.Transform._write (node_modules/karma-browserify/node_modules/browserify/node_modules/readable-stream/lib/_stream_transform.js:172:12)
  at doWrite (node_modules/karma-browserify/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:279:12)
  at writeOrBuffer (node_modules/karma-browserify/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:266:5)
  at DestroyableTransform.Writable.write (node_modules/karma-browserify/node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js:211:11)
  at DestroyableTransform.ondata (node_modules/karma-browserify/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:572:20)
  at DestroyableTransform.emit (events.js:107:17)
  at readableAddChunk (node_modules/karma-browserify/node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js:195:16)
nikku commented 8 years ago

We have no control over source map generation because it is handled by browserify and later processed by convert-source-map. You could try to reproduce this issue in the libraries to see if a bug needs to be filed for either of the libraries.

I do not see this as a huge issue for karma-browserify. Still I am happy to accept a PR if there is an easy fix, i.e. bumping up a dependency version.