anodynos / uRequire

The Ultimate JavaScript Module Builder & Automagical Task Runner. Convert AMD & CommonJS/NodeJS modules to UMD, AMD, CommonJS or bundle them as `combined.js` (rjs & almond, AMDclean soon) & automagically run/test/watch them on nodejs, Web/AMD or Web/Script. Declarative & DRY config with inheritance. Manipulate & inject dependencies, module code, banners, version etc while building with a single line. Support two kinds of plugins, ResourceConverter (i.e file level) and AfterBuilder (i.e the whole bundle). Transparent support for Coffeescript, IcedCoffeescript, Coco, LiveScript – they’re just JavaScript :-)
http://anodynos.github.io/uRequire
MIT License
265 stars 20 forks source link

Generate SourceMaps when converting Module with Template (UMD / AMD / nodejs / combined) #24

Open anodynos opened 11 years ago

anodynos commented 11 years ago

Generating SourceMaps when converting Modules with Template (UMD / AMD / nodejs / combined) would be very desirable in the future - there is no code that deals with it as of v0.6.

Currently you can only compile to .js (NOT template) and keep the SourceMaps info, with the help of a ResourceConverter.

This one for example finds and adjusts the build-in coffee-script RC :

          ->
             # The '#' flag in front of search, downgrades found RC to type:'text',
             # marking files it deals with as `TextResource`!
            (coffeeRC = @ '#coffee-script').convert = (r)->   
              compiled = (require 'coffee-script').compile r.source, {sourceMap:true}
              compiled.js + r.sourceMapInfo.sourceMappingURL
            return coffeeRC 

Changes are needed in Module + ModuleGeneratorTemplates.

sholladay commented 9 years ago

Hey @anodynos, I would like to adopt uRequire, but solid source maps support is a blocker for me. Any word on this? Is it just lack of time / priority or is this ticket really hard to do?

anodynos commented 9 years ago

Hey @sholladay - on v0.7.x (still beta, but very stable) there is some progress made on how the templates are rendered, but no actual work on SourceMaps. I guess there is quite a level of difficulty if we want to make transparent for the user, having all the involved parties (coffeescript, coco, livescript, uglify, esprima, escodegen & urequire's templating system - and soon es6 etc) all transforming and passing the relevant sourcemap down the line. But I haven't worked with any source maps libs yet, so it might be easier that I thought. I do hope I can work on this the next few months, but no guarantees! Surely you can adopt it as it is and see if it suit you - INMHO I think in 95% of the cases an average-and-above developer can understand where they are, without sourcemaps.

sholladay commented 9 years ago

Unfortunately, my use case is for 3rd party enterprise SaaS, meaning our product goes on other people's websites and has to be as small as possible, so we have to minify and debugging is already hard with that as is.

Would a bounty help?

anodynos commented 9 years ago

Oh, if you have to use minification only, then yes you're in a tough place. I was stating its easy to follow but for coffee compiled code or the template conversion / decoration etc, not the minification!

A bounty would perhaps help - I think I will post it as a bounty after I release v0.7.0 & improve the docs!

Regards

Regards