From fefd8961c29def89353712611359fd7fd800deb0 Mon Sep 17 00:00:00 2001 From: Thibault Vilon Date: Fri, 20 Oct 2017 18:22:03 +0200 Subject: [PATCH] add support for object spread --- lib/jsxgettext.js | 11 ++++++++--- package.json | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) mode change 100644 => 100755 lib/jsxgettext.js diff --git a/lib/jsxgettext.js b/lib/jsxgettext.js old mode 100644 new mode 100755 index 7eef48e..37b4e08 --- a/lib/jsxgettext.js +++ b/lib/jsxgettext.js @@ -7,7 +7,8 @@ var fs = require('fs'); var path = require('path'); -var parser = require('acorn-jsx'); +var acorn = require('acorn-object-spread'); +var parser = require('acorn-jsx/inject')(acorn); var walk = require('acorn/dist/walk'); var gettextParser = require('gettext-parser'); var regExpEscape = require('escape-string-regexp'); @@ -41,7 +42,11 @@ var walkBase = Object.assign({}, walk.base, { JSXText: function () {}, - JSXEmptyExpression: function () {} + JSXEmptyExpression: function () {}, + + SpreadProperty: function (node, st, c) { + c(node.argument, st); + }, }); function isStringLiteral(node) { @@ -172,7 +177,7 @@ function parse(sources, options) { var parserOptions = Object.assign({}, { ecmaVersion: 8, sourceType: 'module', - plugins: { jsx: { allowNamespaces: false } }, + plugins: { jsx: { allowNamespaces: false }, objectSpread: true }, onComment: function (block, text, start, end, line/*, column*/) { text = text.match(commentRegex) && text.replace(/^\//, '').trim(); diff --git a/package.json b/package.json index 2d6a16b..1f613f3 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "Gero Takke ", "Michael Weibel (https://github.com/mweibel)", "Yasu (https://github.com/mahata)", - "Marcus (https://github.com/mphasize)" + "Marcus (https://github.com/mphasize)", + "Thibault (https://github.com/tvilon)" ], "name": "jsxgettext", "version": "0.10.2", @@ -49,6 +50,7 @@ "dependencies": { "acorn": "^5.1.2", "acorn-jsx": "^4.0.1", + "acorn-object-spread": "^1.0.0", "commander": "^2.11.0", "escape-string-regexp": "^1.0.5", "gettext-parser": "^1.3.0",