crisper icon indicating copy to clipboard operation
crisper copied to clipboard

Add sourcemap generation

Open nicolasgarnier opened this issue 10 years ago • 9 comments
trafficstars

It would be great to add support for sourcemaps generation.

nicolasgarnier avatar Aug 24 '15 16:08 nicolasgarnier

@azakus this would help for the ES6 stuff we're doing for the Summit. WDYT?

ebidel avatar Aug 24 '15 16:08 ebidel

Hmm, adding sourcemaps to crisper can't quite work if you use vulcanize, because any inlined scripts will lose their original file locations.

At best I could use source-map-concat to keep any existing sourcemaps.

dfreedm avatar Aug 24 '15 17:08 dfreedm

I think at this point we just need Crisper to output the sourcemaps for the transformation it's doing.

Concatenating the sourcemaps when processing a file with multiple tools (e.g. with Vulcanize) is up to the developer or the build pipeline. For instance in gulp when using gulp-sourcemaps the concatenation is done automatically as long as the tool (and plugin) supports outputing a sourcemap.

I'm just saying: You don't have to care about concatenation of sourcemaps :) Simply output the sourcemap for the transform that Crisper does. Developers already have tools/build processes to take care of piping multiple tools that outputs sourcemaps.

Also there are other use for Crisper than using it after Vulcanize. For instance it's also useful with Babel (for ES6 transpilation). In one of the codelabs we're building we'll do:

  1. Extract JS from HTML files using Crisper
  2. Transpile the JS files from ES6 to ES5 using Babel

We need to do this because Babel does't support transpiling JS that's inline HTML directly. But then unfortunately when doing this we're loosing sourcemaps support because of Crisper.

nicolasgarnier avatar Aug 24 '15 18:08 nicolasgarnier

What do you expect the sourcemaps of formerly inline scripts to point to? The HTML file the file was in, or an embedded copy of the original source lines?

dfreedm avatar Aug 24 '15 18:08 dfreedm

Quite often the tools have the 2 options. For instance Traceur has the following option: --source-maps [file|inline] (embedded or as a separate file). But if that's too much work I personally prefer a separate file :) That's usually what's used in prod anyways because inline makes the file huge and most website visitors don't need to sourcemap.

nicolasgarnier avatar Aug 24 '15 19:08 nicolasgarnier

+1 tracking bugs in production is a PITA without sourcemaps.

indolering avatar Dec 17 '15 23:12 indolering

+1

ronnyroeller avatar Jul 21 '16 10:07 ronnyroeller

+1

tylerthehaas avatar Dec 05 '16 16:12 tylerthehaas

Any progress in this item? To many web devs, a framework that doesn't allow source mapping to the origin is an absolute no-fly zone

chajath avatar Oct 19 '17 21:10 chajath