Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Error in array-set when producing source maps. #76

Closed
thlorenz opened this Issue · 9 comments

3 participants

@thlorenz

I created a repo to reproduce the issue here, but here is the stack trace, it basically breaks in ./lib/array-set.js.

/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/source-map/lib/source-map/array-set.js:83
    throw new Error('No element indexed by ' + aIdx);
          ^
Error: No element indexed by 1
    at ArraySet_at [as at] (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/source-map/lib/source-map/array-set.js:83:11)
    at SourceMapConsumer_parseMappings [as _parseMappings] (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/source-map/lib/source-map/source-map-consumer.js:158:44)
    at new SourceMapConsumer (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/node_modules/source-map/lib/source-map/source-map-consumer.js:100:10)
    at module.exports (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/lib/mappings-from-map.js:10:18)
    at Combiner._addExistingMap (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/index.js:28:18)
    at Combiner.addFile (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/node_modules/combine-source-map/index.js:58:12)
    at Stream.write (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/browser-pack/index.js:42:23)
    at Stream.stream.write (/Users/thlorenz/dev/js/projects/es6ify/tmp/node_modules/browserify/node_modules/through/index.js:26:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.EventEmitter.emit (events.js:95:17)
@fitzgen
Owner

The source map we are trying to parse only has one source listed, but there is a mapping that refers to a second source (at index 1, presumably supposed to be bar.js). This is a bad source map. Looking into which library generates the bad source map (using this lib perhaps?).

{ version: 3,
  file: '/Users/fitzgen/src/repro-sourcemap-issue/foo.js.es6',
  sources: [ '/Users/fitzgen/src/repro-sourcemap-issue/foo.js' ],
  names: [],
  mappings: 'uBAAA,SAAA,CAAS,MAAA,CAAQ;AACL,KAAA,YAAA,EAAc,EAAA,CAAA,CAAI,KAAA,CAAM,MAAA,EAAQ,OAAA,CAAA,mBAA0B,CAAC,MAAA,CAAA;AAC/D,KAAA,EAAS,GAAA,EAAA,EAAI,EAAA,CAAG,EAAA,EAAI,MAAA,CAAA,MAAA,CAAc,EAAA,EAAA,CAAK;AACjC,OAAA,KAAA,EAAO,MAAA,CAAM,CAAA,CAAA;AACjB,eAAA,CAAY,IAAA,CAAA,EAAQ,OAAA,CAAA,wBAA+B,CAAC,MAAA,CAAQ,KAAA,CAAA;AAAA;AAE9D,QAAO,YAAA;AAAA,CAAA,2BCNf,SAAA,CAAS,MAAA,CAAQ,aAAA,CAAc;AACrB,KAAA,KAAA,EAAO,OAAA,CAAA,WAAA;AACX,QAAA,CAAA,cAAqB,CAAC,MAAA,CAAQ,cAAA,CAAe,EAAC,UAAA,CAAY,MAAA,CAAA,CAAA;AAC1D,MAAA,CAAA,SAAA,EAAiB,OAAA;AACjB,QAAA,CAAA,gBAAuB,CAAC,IAAA,CAAM,kBAAiB,CAAC,YAAA,CAAA,CAAA;AAChD,QAAO,KAAA;AAAA,CAAA;GCLP,MAAA,ECAN,SAAA,CAAS;AACH,cAAA;AACI,cAAoB,0BAAmB;AAFjD,eAAA,CAAa,SAAA,CAAS,CAAE,EAAA,CAAA;UDCpB,SAAA,CAAM,CAAE;AACJ,YAAO,KAAA;AAAA;AAAA,GAAA;ACET;CACD,CAAA,CAAA;ADAL,MAAA,CAAA,OAAA,EAAiB,MAAA',
  sourcesContent: [ 'class Hello {\n    greet() {\n        return "me";\n    }\n}\nmodule.exports = Hello;\n' ] }
@thlorenz

Oh so maybe the combined-source-map module is using source-map generator incorrectly. This may be related to the latest change to that module.

@ben-ng do you have an idea what could be going wrong here?

@fitzgen
Owner

Aside: the combine-source-map module can get a lot smaller and dumber once we make progress with issue(s) 16/69

@thlorenz thlorenz referenced this issue in thlorenz/combine-source-map
Closed

Switch to source-map package #6

@thlorenz

@fitzgen Yeah those pieces in the works look interesting. combine-source-map will most likely just have to be a rather simple wrapper at that point.

I rolled back the change that caused the problem for now and am waiting for feedback from the author of that PR to see how to proceed. How long do you think until those mentioned changes land? Possibly we should wait with the combine-source-map migration to use this module until then?

@thlorenz thlorenz closed this
@fitzgen
Owner

@thlorenz It is fairly low priority on my TODO list; I'm spending 99% of my hack time on new features for firefox's debugger. If you want to take a crack at it, I will provide speedy review of pull requests :) We did end up deciding on an API in issue 16.

I am flying back to SF from Paris on Saturday, maybe I can take a crack at it then.

@thlorenz

Somewhat swamped myself here, but for me personally this is not such high priority either. As far as I understand the original change was attempted to fix problems with source-maps of minified code that @ben-ng ran into.
If this is more important for his module I'll leave this up to him ;)

@ben-ng

I've been on a road trip through the midwest, finally got back on the internet today.

Yes, this change is very important for my module so i'll fix this one. Thanks for helping with the repro case @thlorenz.

@ben-ng

Okay, this issue is definitely in es6ify. I'll take care of it and send a PR now. Thank you for the repro case!

@ben-ng ben-ng referenced this issue in thlorenz/es6ify
Closed

es6ify generates invalid sourcemaps #9

@MohammadYounes MohammadYounes referenced this issue from a commit in am11/WebEssentials2013
@am11 am11 srv-rtlcss: Prevent from throwing.
The problem is, when both rtlcss and autoprefixer
are enabled, it works fine with SCSS, but throws
with LESS.

When the code is too complicated,
the `result` object seems to have problem with
returning `result.css` member. When the code is
comparatively straight-forward, it throws a
slightly lenient error.

/cc @MohammadYounes
5a8aec1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.