Le jeudi 01 mai 2014 à 22:49 +0200, Jonas Smedegaard a écrit : > Quoting Jérémy Lal (2014-05-01 21:57:48) > >>>>>> About node-source-map: > >>>>>> It build-depends on dryice (>=0.4.8). You can find a pre-release > >>>>>> package in pkg-javascript/node-dryice.git repository. > >>>>>> Once it done/uploaded to unstable, we will be able to build > >>>>>> source-map. > > >>> We could patch a little dryice so that it doesn't Depends uglify-js > >>> but only Recommends or Suggests it. Do i remember well ? would that > >>> be enough ? > >> > >> Sounds good. > > > > My mistake, dryice is tied to uglify too much - it uses uglify's > > Abstract Syntax Tree to walk the code and find 'require("module")'. > > I cannot make that optional without cutting dryice legs. > > > > On the other hand, uglifyjs2 only needs source-map for the cases where > > one uses --source-map, something that is not used by source-map > > (pardon the tautology). > > > > I'll push this evening a patch on the master-experimental branch of > > uglifyjs, just tell me if that's not right. > > That's perfect :-)
There. Jérémy.
Description: break dependency loop by making source-map module optional Forwarded: https://github.com/mishoo/UglifyJS2/pull/477 Author: Jérémy Lal <kapo...@melix.org> Last-Update: 2014-05-02 --- a/package.json +++ b/package.json @@ -16,10 +16,12 @@ }, "dependencies": { "async" : "~0.2.6", - "source-map" : "~0.1.33", "optimist" : "~0.3.5", "uglify-to-browserify": "~1.0.0" }, + "optionalDependencies": { + "source-map" : "~0.1.33" + }, "browserify": { "transform": [ "uglify-to-browserify" ] }, --- a/tools/node.js +++ b/tools/node.js @@ -2,11 +2,16 @@ var fs = require("fs"); var vm = require("vm"); var sys = require("util"); +var sourceMap; +try { + sourceMap = require("source-map"); +} catch(e) { +} var UglifyJS = vm.createContext({ sys : sys, console : console, - MOZ_SourceMap : require("source-map") + MOZ_SourceMap : sourceMap }); function load_global(file) { @@ -107,17 +112,21 @@ inMap = fs.readFileSync(options.inSourceMap, "utf8"); } if (options.outSourceMap) { - output.source_map = UglifyJS.SourceMap({ - file: options.outSourceMap, - orig: inMap, - root: options.sourceRoot - }); - if (options.sourceMapIncludeSources) { - for (var file in sourcesContent) { - if (sourcesContent.hasOwnProperty(file)) { - options.source_map.get().setSourceContent(file, sourcesContent[file]); + if (sourceMap) { + output.source_map = UglifyJS.SourceMap({ + file: options.outSourceMap, + orig: inMap, + root: options.sourceRoot + }); + if (options.sourceMapIncludeSources) { + for (var file in sourcesContent) { + if (sourcesContent.hasOwnProperty(file)) { + options.source_map.get().setSourceContent(file, sourcesContent[file]); + } } } + } else { + console.error("source-map module is missing and needed by outSourceMap option"); } }