From 99233c44cc125fa1a96a47b863dbfb3ec0c3fadc Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Thu, 24 Sep 2015 17:57:47 +0300 Subject: No longer use `vm` to load code. Improves performance 2x on node > 0.10. Ref #636 --- tools/node.js | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'tools/node.js') diff --git a/tools/node.js b/tools/node.js index eba2bc1d..f6048661 100644 --- a/tools/node.js +++ b/tools/node.js @@ -1,26 +1,5 @@ var path = require("path"); var fs = require("fs"); -var vm = require("vm"); - -var UglifyJS = vm.createContext({ - console : console, - process : process, - Buffer : Buffer, - MOZ_SourceMap : require("source-map") -}); - -function load_global(file) { - file = path.resolve(path.dirname(module.filename), file); - try { - var code = fs.readFileSync(file, "utf8"); - return vm.runInContext(code, UglifyJS, file); - } catch(ex) { - // XXX: in case of a syntax error, the message is kinda - // useless. (no location information). - console.log("ERROR in file: " + file + " / " + ex); - process.exit(1); - } -}; var FILES = exports.FILES = [ "../lib/utils.js", @@ -32,24 +11,25 @@ var FILES = exports.FILES = [ "../lib/compress.js", "../lib/sourcemap.js", "../lib/mozilla-ast.js", - "../lib/propmangle.js" + "../lib/propmangle.js", + "./exports.js", ].map(function(file){ return fs.realpathSync(path.join(path.dirname(__filename), file)); }); -FILES.forEach(load_global); +var UglifyJS = exports; + +new Function("MOZ_SourceMap", "exports", FILES.map(function(file){ + return fs.readFileSync(file, "utf8"); +}).join("\n\n"))( + require("source-map"), + UglifyJS +); UglifyJS.AST_Node.warn_function = function(txt) { console.error("WARN: %s", txt); }; -// XXX: perhaps we shouldn't export everything but heck, I'm lazy. -for (var i in UglifyJS) { - if (UglifyJS.hasOwnProperty(i)) { - exports[i] = UglifyJS[i]; - } -} - exports.minify = function(files, options) { options = UglifyJS.defaults(options, { spidermonkey : false, -- cgit v1.2.3 x/log/po/packages?id=2383e145185efb2e6f99931707ec93d65d166432'>packages
AgeCommit message (Expand)Author
2022-10-06nls: Update translations.Julien Lepiller
2022-09-04nls: Update translations.Julien Lepiller
2022-08-16ui: Describe package outputs....Liliana Marie Prikler
2022-08-10nls: Update translations....Julien Lepiller
2022-07-09nls: Update translations....Julien Lepiller
2022-06-04nls: Update translations....Julien Lepiller
2022-05-01nls: Update translations....Julien Lepiller
2022-04-02nls: Update translations....Julien Lepiller
2022-03-01nls: Update translations....Julien Lepiller
2022-02-04nls: Update translations....Julien Lepiller
2022-01-09nls: Update translations....Julien Lepiller
2021-12-04nls: Update translations.Julien Lepiller
2021-11-06nls: Update translations....Julien Lepiller
2021-10-17nls: Update translations.Julien Lepiller
2021-09-02nls: Update translations....Julien Lepiller
2021-08-04nls: Update translations....Julien Lepiller
2021-05-10nls: Update translations.Maxim Cournoyer
2021-05-10nls: New nl and oc translations for the 'packages' component....Maxim Cournoyer
2021-05-03nls: Do not update po files on first make invocation....Julien Lepiller
2021-04-18nls: Remove 'vi' in LINGUAS...Julien Lepiller
2021-04-18nls: Add Korean translation....Julien Lepiller
2021-04-18nls: Add Persian translation....Julien Lepiller
2021-04-18nls: Add Slovak translation....Julien Lepiller
2021-04-18nls: Update 'pt_BR' translation.Julien Lepiller
2021-04-18nls: Remove Vietnamese translations of packages....Julien Lepiller
2021-04-18nls: Update 'zh_CN' translations.Julien Lepiller
2021-04-18nls: Update 'sr' translations.Julien Lepiller
2021-04-18nls: Update 'pl' translations.Julien Lepiller
2021-04-18nls: Update 'hu' translations.Julien Lepiller
2021-04-18nls: Update 'da' translations.Julien Lepiller
2021-04-18nls: Update 'eo' translations.Julien Lepiller
2021-04-18nls: Update 'es' translations.Julien Lepiller
2021-04-18nls: Update 'de' translations.Julien Lepiller
2021-04-18nls: Update 'fr' translations.Julien Lepiller
2021-02-12services: Add transmission-daemon service....Simon South
2021-01-28nls: Update 'fr' translation.Julien Lepiller
2020-11-12nls: Update string translations.Ludovic Courtès
2020-10-27nls: Update.Ludovic Courtès
2020-10-16nls: Update.Ludovic Courtès
2020-09-29nls: Fix copyright and bug address in pot files....Julien Lepiller
2020-04-14nls: Update.Ludovic Courtès
2020-04-12nls: Update.Ludovic Courtès
2020-03-23nls: Update.Ludovic Courtès