diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/handlebars/lib | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/handlebars/lib')
8 files changed, 49 insertions, 26 deletions
diff --git a/node_modules/handlebars/lib/handlebars/base.js b/node_modules/handlebars/lib/handlebars/base.js index d0ad13310..127be4b7e 100644 --- a/node_modules/handlebars/lib/handlebars/base.js +++ b/node_modules/handlebars/lib/handlebars/base.js @@ -4,7 +4,7 @@ import {registerDefaultHelpers} from './helpers'; import {registerDefaultDecorators} from './decorators'; import logger from './logger'; -export const VERSION = '4.0.10'; +export const VERSION = '4.0.12'; export const COMPILER_REVISION = 7; export const REVISION_CHANGES = { diff --git a/node_modules/handlebars/lib/handlebars/compiler/code-gen.js b/node_modules/handlebars/lib/handlebars/compiler/code-gen.js index 5ec052f77..43c0481bc 100644 --- a/node_modules/handlebars/lib/handlebars/compiler/code-gen.js +++ b/node_modules/handlebars/lib/handlebars/compiler/code-gen.js @@ -118,7 +118,7 @@ CodeGen.prototype = { .replace(/"/g, '\\"') .replace(/\n/g, '\\n') .replace(/\r/g, '\\r') - .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 + .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 .replace(/\u2029/g, '\\u2029') + '"'; }, diff --git a/node_modules/handlebars/lib/handlebars/compiler/compiler.js b/node_modules/handlebars/lib/handlebars/compiler/compiler.js index 47107cc5c..894f7a7c0 100644 --- a/node_modules/handlebars/lib/handlebars/compiler/compiler.js +++ b/node_modules/handlebars/lib/handlebars/compiler/compiler.js @@ -67,11 +67,11 @@ Compiler.prototype = { 'lookup': true }; if (knownHelpers) { + // the next line should use "Object.keys", but the code has been like this a long time and changing it, might + // cause backwards-compatibility issues... It's an old library... + // eslint-disable-next-line guard-for-in for (let name in knownHelpers) { - /* istanbul ignore else */ - if (name in knownHelpers) { this.options.knownHelpers[name] = knownHelpers[name]; - } } } diff --git a/node_modules/handlebars/lib/handlebars/compiler/helpers.js b/node_modules/handlebars/lib/handlebars/compiler/helpers.js index e09a08df9..432df877c 100644 --- a/node_modules/handlebars/lib/handlebars/compiler/helpers.js +++ b/node_modules/handlebars/lib/handlebars/compiler/helpers.js @@ -38,7 +38,7 @@ export function stripFlags(open, close) { } export function stripComment(comment) { - return comment.replace(/^\{\{~?\!-?-?/, '') + return comment.replace(/^\{\{~?!-?-?/, '') .replace(/-?-?~?\}\}$/, ''); } @@ -47,8 +47,7 @@ export function preparePath(data, parts, loc) { let original = data ? '@' : '', dig = [], - depth = 0, - depthString = ''; + depth = 0; for (let i = 0, l = parts.length; i < l; i++) { let part = parts[i].part, @@ -62,7 +61,6 @@ export function preparePath(data, parts, loc) { throw new Exception('Invalid path: ' + original, {loc}); } else if (part === '..') { depth++; - depthString += '../'; } } else { dig.push(part); diff --git a/node_modules/handlebars/lib/handlebars/compiler/javascript-compiler.js b/node_modules/handlebars/lib/handlebars/compiler/javascript-compiler.js index bf4be8af9..471144dd3 100644 --- a/node_modules/handlebars/lib/handlebars/compiler/javascript-compiler.js +++ b/node_modules/handlebars/lib/handlebars/compiler/javascript-compiler.js @@ -133,7 +133,7 @@ JavaScriptCompiler.prototype = { }; if (this.decorators) { - ret.main_d = this.decorators; // eslint-disable-line camelcase + ret.main_d = this.decorators; // eslint-disable-line camelcase ret.useDecorators = true; } @@ -209,7 +209,7 @@ JavaScriptCompiler.prototype = { // aliases will not be used, but this case is already being run on the client and // we aren't concern about minimizing the template size. let aliasCount = 0; - for (let alias in this.aliases) { // eslint-disable-line guard-for-in + for (let alias in this.aliases) { // eslint-disable-line guard-for-in let node = this.aliases[alias]; if (this.aliases.hasOwnProperty(alias) && node.children && node.referenceCount > 1) { @@ -776,12 +776,12 @@ JavaScriptCompiler.prototype = { for (let i = 0, l = children.length; i < l; i++) { child = children[i]; - compiler = new this.compiler(); // eslint-disable-line new-cap + compiler = new this.compiler(); // eslint-disable-line new-cap let existing = this.matchExistingProgram(child); if (existing == null) { - this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children + this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children let index = this.context.programs.length; child.index = index; child.name = 'program' + index; diff --git a/node_modules/handlebars/lib/handlebars/compiler/parser.js b/node_modules/handlebars/lib/handlebars/compiler/parser.js index 5b5ae2b20..cda230860 100644 --- a/node_modules/handlebars/lib/handlebars/compiler/parser.js +++ b/node_modules/handlebars/lib/handlebars/compiler/parser.js @@ -7,7 +7,7 @@ symbols_: {"error":2,"root":3,"program":4,"EOF":5,"program_repetition0":6,"state terminals_: {2:"error",5:"EOF",14:"COMMENT",15:"CONTENT",18:"END_RAW_BLOCK",19:"OPEN_RAW_BLOCK",23:"CLOSE_RAW_BLOCK",29:"OPEN_BLOCK",33:"CLOSE",34:"OPEN_INVERSE",39:"OPEN_INVERSE_CHAIN",44:"INVERSE",47:"OPEN_ENDBLOCK",48:"OPEN",51:"OPEN_UNESCAPED",54:"CLOSE_UNESCAPED",55:"OPEN_PARTIAL",60:"OPEN_PARTIAL_BLOCK",65:"OPEN_SEXPR",68:"CLOSE_SEXPR",72:"ID",73:"EQUALS",75:"OPEN_BLOCK_PARAMS",77:"CLOSE_BLOCK_PARAMS",80:"STRING",81:"NUMBER",82:"BOOLEAN",83:"UNDEFINED",84:"NULL",85:"DATA",87:"SEP"}, productions_: [0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[13,1],[10,3],[16,5],[9,4],[9,4],[24,6],[27,6],[38,6],[43,2],[45,3],[45,1],[26,3],[8,5],[8,5],[11,5],[12,3],[59,5],[63,1],[63,1],[64,5],[69,1],[71,3],[74,3],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[56,1],[56,1],[79,2],[78,1],[86,3],[86,1],[6,0],[6,2],[17,1],[17,2],[21,0],[21,2],[22,0],[22,1],[25,0],[25,1],[28,0],[28,1],[30,0],[30,2],[31,0],[31,1],[32,0],[32,1],[35,0],[35,2],[36,0],[36,1],[37,0],[37,1],[40,0],[40,2],[41,0],[41,1],[42,0],[42,1],[46,0],[46,1],[49,0],[49,2],[50,0],[50,1],[52,0],[52,2],[53,0],[53,1],[57,0],[57,2],[58,0],[58,1],[61,0],[61,2],[62,0],[62,1],[66,0],[66,2],[67,0],[67,1],[70,1],[70,2],[76,1],[76,2]], performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$ -/**/) { +/*``*/) { var $0 = $$.length - 1; switch (yystate) { @@ -472,7 +472,7 @@ pushState:function begin(condition) { }}); lexer.options = {}; lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START -/**/) { +/*``*/) { function strip(start, end) { diff --git a/node_modules/handlebars/lib/handlebars/logger.js b/node_modules/handlebars/lib/handlebars/logger.js index 1ab0051f5..1e916a995 100644 --- a/node_modules/handlebars/lib/handlebars/logger.js +++ b/node_modules/handlebars/lib/handlebars/logger.js @@ -24,10 +24,10 @@ let logger = { if (typeof console !== 'undefined' && logger.lookupLevel(logger.level) <= level) { let method = logger.methodMap[level]; - if (!console[method]) { // eslint-disable-line no-console + if (!console[method]) { // eslint-disable-line no-console method = 'log'; } - console[method](...message); // eslint-disable-line no-console + console[method](...message); // eslint-disable-line no-console } } }; diff --git a/node_modules/handlebars/lib/precompiler.js b/node_modules/handlebars/lib/precompiler.js index 6ba3800cb..ab3eb201d 100644 --- a/node_modules/handlebars/lib/precompiler.js +++ b/node_modules/handlebars/lib/precompiler.js @@ -4,7 +4,7 @@ import fs from 'fs'; import * as Handlebars from './handlebars'; import {basename} from 'path'; import {SourceMapConsumer, SourceNode} from 'source-map'; -import uglify from 'uglify-js'; + module.exports.loadTemplates = function(opts, callback) { loadStrings(opts, function(err, strings) { @@ -60,7 +60,7 @@ function loadStrings(opts, callback) { function loadFiles(opts, callback) { // Build file extension pattern - let extension = (opts.extension || 'handlebars').replace(/[\\^$*+?.():=!|{}\-\[\]]/g, function(arg) { return '\\' + arg; }); + let extension = (opts.extension || 'handlebars').replace(/[\\^$*+?.():=!|{}\-[\]]/g, function(arg) { return '\\' + arg; }); extension = new RegExp('\\.' + extension + '$'); let ret = [], @@ -235,7 +235,6 @@ module.exports.cli = function(opts) { } } - if (opts.map) { output.add('\n//# sourceMappingURL=' + opts.map + '\n'); } @@ -244,12 +243,7 @@ module.exports.cli = function(opts) { output.map = output.map + ''; if (opts.min) { - output = uglify.minify(output.code, { - fromString: true, - - outSourceMap: opts.map, - inSourceMap: JSON.parse(output.map) - }); + output = minify(output, opts.map); } if (opts.map) { @@ -271,3 +265,34 @@ function arrayCast(value) { } return value; } + +/** + * Run uglify to minify the compiled template, if uglify exists in the dependencies. + * + * We are using `require` instead of `import` here, because es6-modules do not allow + * dynamic imports and uglify-js is an optional dependency. Since we are inside NodeJS here, this + * should not be a problem. + * + * @param {string} output the compiled template + * @param {string} sourceMapFile the file to write the source map to. + */ +function minify(output, sourceMapFile) { + try { + // Try to resolve uglify-js in order to see if it does exist + require.resolve('uglify-js'); + } catch (e) { + if (e.code !== 'MODULE_NOT_FOUND') { + // Something else seems to be wrong + throw e; + } + // it does not exist! + console.error('Code minimization is disabled due to missing uglify-js dependency'); + return output; + } + return require('uglify-js').minify(output.code, { + sourceMap: { + content: output.map, + url: sourceMapFile + } + }); +} |