From ccb35cd4c2f87c7df5c145a096369e6da65917b6 Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 14:15:39 +0200 Subject: [PATCH 1/9] Outsourced the module-creator function Outsourced the module-creator function and added the estraverse-module as parameter so that we can use a different version as drop-in replacement. --- esquery_init | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 esquery_init diff --git a/esquery_init b/esquery_init new file mode 100644 index 0000000..4fb7411 --- /dev/null +++ b/esquery_init @@ -0,0 +1,335 @@ +/* vim: set sw=4 sts=4 : */ +(function () { + + function esqueryModule(estraverse) { + + var parser = require('./parser'); + + var isArray = Array.isArray || function isArray(array) { + return {}.toString.call(array) === '[object Array]'; + }; + + var LEFT_SIDE = {}; + var RIGHT_SIDE = {}; + + /** + * Get the value of a property which may be multiple levels down in the object. + */ + function getPath(obj, key) { + var i, keys = key.split("."); + for (i = 0; i < keys.length; i++) { + if (obj == null) { return obj; } + obj = obj[keys[i]]; + } + return obj; + } + + /** + * Determine whether `node` can be reached by following `path`, starting at `ancestor`. + */ + function inPath(node, ancestor, path) { + var field, remainingPath, i; + if (path.length === 0) { return node === ancestor; } + if (ancestor == null) { return false; } + field = ancestor[path[0]]; + remainingPath = path.slice(1); + if (isArray(field)) { + for (i = 0, l = field.length; i < l; ++i) { + if (inPath(node, field[i], remainingPath)) { return true; } + } + return false; + } else { + return inPath(node, field, remainingPath); + } + } + + /** + * Given a `node` and its ancestors, determine if `node` is matched by `selector`. + */ + function matches(node, selector, ancestry) { + var path, ancestor, i, l, p; + if (!selector) { return true; } + if (!node) { return false; } + if (!ancestry) { ancestry = []; } + + switch(selector.type) { + case 'wildcard': + return true; + + case 'identifier': + return selector.value.toLowerCase() === node.type.toLowerCase(); + + case 'field': + path = selector.name.split('.'); + ancestor = ancestry[path.length - 1]; + return inPath(node, ancestor, path); + + case 'matches': + for (i = 0, l = selector.selectors.length; i < l; ++i) { + if (matches(node, selector.selectors[i], ancestry)) { return true; } + } + return false; + + case 'compound': + for (i = 0, l = selector.selectors.length; i < l; ++i) { + if (!matches(node, selector.selectors[i], ancestry)) { return false; } + } + return true; + + case 'not': + for (i = 0, l = selector.selectors.length; i < l; ++i) { + if (matches(node, selector.selectors[i], ancestry)) { return false; } + } + return true; + + case 'has': + var a, collector = []; + for (i = 0, l = selector.selectors.length; i < l; ++i) { + a = []; + estraverse.traverse(node, { + enter: function (node, parent) { + if (parent != null) { a.unshift(parent); } + if (matches(node, selector.selectors[i], a)) { + collector.push(node); + } + }, + leave: function () { a.shift(); } + }); + } + return collector.length !== 0; + + case 'child': + if (matches(node, selector.right, ancestry)) { + return matches(ancestry[0], selector.left, ancestry.slice(1)); + } + return false; + + case 'descendant': + if (matches(node, selector.right, ancestry)) { + for (i = 0, l = ancestry.length; i < l; ++i) { + if (matches(ancestry[i], selector.left, ancestry.slice(i + 1))) { + return true; + } + } + } + return false; + + case 'attribute': + p = getPath(node, selector.name); + switch (selector.operator) { + case null: + case void 0: + return p != null; + case '=': + switch (selector.value.type) { + case 'regexp': return selector.value.value.test(p); + case 'literal': return '' + selector.value.value === '' + p; + case 'type': return selector.value.value === typeof p; + } + case '!=': + switch (selector.value.type) { + case 'regexp': return !selector.value.value.test(p); + case 'literal': return '' + selector.value.value !== '' + p; + case 'type': return selector.value.value !== typeof p; + } + case '<=': return p <= selector.value.value; + case '<': return p < selector.value.value; + case '>': return p > selector.value.value; + case '>=': return p >= selector.value.value; + } + + case 'sibling': + return matches(node, selector.right, ancestry) && + sibling(node, selector.left, ancestry, LEFT_SIDE) || + selector.left.subject && + matches(node, selector.left, ancestry) && + sibling(node, selector.right, ancestry, RIGHT_SIDE); + + case 'adjacent': + return matches(node, selector.right, ancestry) && + adjacent(node, selector.left, ancestry, LEFT_SIDE) || + selector.right.subject && + matches(node, selector.left, ancestry) && + adjacent(node, selector.right, ancestry, RIGHT_SIDE); + + case 'nth-child': + return matches(node, selector.right, ancestry) && + nthChild(node, ancestry, function (length) { + return selector.index.value - 1; + }); + + case 'nth-last-child': + return matches(node, selector.right, ancestry) && + nthChild(node, ancestry, function (length) { + return length - selector.index.value; + }); + + case 'class': + if(!node.type) return false; + switch(selector.name.toLowerCase()){ + case 'statement': + if(node.type.slice(-9) === 'Statement') return true; + // fallthrough: interface Declaration <: Statement { } + case 'declaration': + return node.type.slice(-11) === 'Declaration'; + case 'pattern': + if(node.type.slice(-7) === 'Pattern') return true; + // fallthrough: interface Expression <: Node, Pattern { } + case 'expression': + return node.type.slice(-10) === 'Expression' || + node.type === 'Literal' || + node.type === 'Identifier'; + case 'function': + return node.type.slice(0, 8) === 'Function' || + node.type === 'ArrowFunctionExpression'; + } + throw new Error('Unknown class name: ' + selector.name); + } + + throw new Error('Unknown selector type: ' + selector.type); + } + + /* + * Determines if the given node has a sibling that matches the given selector. + */ + function sibling(node, selector, ancestry, side) { + var parent = ancestry[0], listProp, startIndex, keys, i, l, k, lowerBound, upperBound; + if (!parent) { return false; } + keys = estraverse.VisitorKeys[parent.type]; + for (i = 0, l = keys.length; i < l; ++i) { + listProp = parent[keys[i]]; + if (isArray(listProp)) { + startIndex = listProp.indexOf(node); + if (startIndex < 0) { continue; } + if (side === LEFT_SIDE) { + lowerBound = 0; + upperBound = startIndex; + } else { + lowerBound = startIndex + 1; + upperBound = listProp.length; + } + for (k = lowerBound; k < upperBound; ++k) { + if (matches(listProp[k], selector, ancestry)) { + return true; + } + } + } + } + return false; + } + + /* + * Determines if the given node has an asjacent sibling that matches the given selector. + */ + function adjacent(node, selector, ancestry, side) { + var parent = ancestry[0], listProp, keys, i, l, idx; + if (!parent) { return false; } + keys = estraverse.VisitorKeys[parent.type]; + for (i = 0, l = keys.length; i < l; ++i) { + listProp = parent[keys[i]]; + if (isArray(listProp)) { + idx = listProp.indexOf(node); + if (idx < 0) { continue; } + if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) { + return true; + } + if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) { + return true; + } + } + } + return false; + } + + /* + * Determines if the given node is the nth child, determined by idxFn, which is given the containing list's length. + */ + function nthChild(node, ancestry, idxFn) { + var parent = ancestry[0], listProp, keys, i, l, idx; + if (!parent) { return false; } + keys = estraverse.VisitorKeys[parent.type]; + for (i = 0, l = keys.length; i < l; ++i) { + listProp = parent[keys[i]]; + if (isArray(listProp)) { + idx = listProp.indexOf(node); + if (idx >= 0 && idx === idxFn(listProp.length)) { return true; } + } + } + return false; + } + + /* + * For each selector node marked as a subject, find the portion of the selector that the subject must match. + */ + function subjects(selector, ancestor) { + var results, p; + if (selector == null || typeof selector != 'object') { return []; } + if (ancestor == null) { ancestor = selector; } + results = selector.subject ? [ancestor] : []; + for(p in selector) { + if(!{}.hasOwnProperty.call(selector, p)) { continue; } + [].push.apply(results, subjects(selector[p], p === 'left' ? selector[p] : ancestor)); + } + return results; + } + + /** + * From a JS AST and a selector AST, collect all JS AST nodes that match the selector. + */ + function match(ast, selector) { + var ancestry = [], results = [], altSubjects, i, l, k, m; + if (!selector) { return results; } + altSubjects = subjects(selector); + estraverse.traverse(ast, { + enter: function (node, parent) { + if (parent != null) { ancestry.unshift(parent); } + if (matches(node, selector, ancestry)) { + if (altSubjects.length) { + for (i = 0, l = altSubjects.length; i < l; ++i) { + if (matches(node, altSubjects[i], ancestry)) { results.push(node); } + for (k = 0, m = ancestry.length; k < m; ++k) { + if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) { + results.push(ancestry[k]); + } + } + } + } else { + results.push(node); + } + } + }, + leave: function () { ancestry.shift(); } + }); + return results; + } + + /** + * Parse a selector string and return its AST. + */ + function parse(selector) { + return parser.parse(selector); + } + + /** + * Query the code AST using the selector string. + */ + function query(ast, selector) { + return match(ast, parse(selector)); + } + + query.parse = parse; + query.match = match; + query.matches = matches; + return query.query = query; + } + + + if (typeof define === "function" && define.amd) { + define(function(){return esqueryModule;}); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = esqueryModule; + } else { + this.esquery = esqueryModule; + } + +})(); From 5af24b2664d1515d81fcb8baf34bcbb3ab2817f2 Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 14:21:17 +0200 Subject: [PATCH 2/9] Default script uses "normal" estraverse-module Changed default entry-point script so that its behaviour does not change in respect to the original esquery-module. Only change here is that it now calls the outsourced esquery module-creator function - but with the standard estraverse module as parameter. --- esquery.js | 330 +---------------------------------------------------- 1 file changed, 5 insertions(+), 325 deletions(-) diff --git a/esquery.js b/esquery.js index d4d9fea..6996166 100644 --- a/esquery.js +++ b/esquery.js @@ -1,336 +1,16 @@ /* vim: set sw=4 sts=4 : */ (function () { - var estraverse = require('estraverse'); - var parser = require('./parser'); - - var isArray = Array.isArray || function isArray(array) { - return {}.toString.call(array) === '[object Array]'; - }; - - var LEFT_SIDE = {}; - var RIGHT_SIDE = {}; - - function esqueryModule() { - - /** - * Get the value of a property which may be multiple levels down in the object. - */ - function getPath(obj, key) { - var i, keys = key.split("."); - for (i = 0; i < keys.length; i++) { - if (obj == null) { return obj; } - obj = obj[keys[i]]; - } - return obj; - } - - /** - * Determine whether `node` can be reached by following `path`, starting at `ancestor`. - */ - function inPath(node, ancestor, path) { - var field, remainingPath, i; - if (path.length === 0) { return node === ancestor; } - if (ancestor == null) { return false; } - field = ancestor[path[0]]; - remainingPath = path.slice(1); - if (isArray(field)) { - for (i = 0, l = field.length; i < l; ++i) { - if (inPath(node, field[i], remainingPath)) { return true; } - } - return false; - } else { - return inPath(node, field, remainingPath); - } - } - - /** - * Given a `node` and its ancestors, determine if `node` is matched by `selector`. - */ - function matches(node, selector, ancestry) { - var path, ancestor, i, l, p; - if (!selector) { return true; } - if (!node) { return false; } - if (!ancestry) { ancestry = []; } - - switch(selector.type) { - case 'wildcard': - return true; - - case 'identifier': - return selector.value.toLowerCase() === node.type.toLowerCase(); - - case 'field': - path = selector.name.split('.'); - ancestor = ancestry[path.length - 1]; - return inPath(node, ancestor, path); - - case 'matches': - for (i = 0, l = selector.selectors.length; i < l; ++i) { - if (matches(node, selector.selectors[i], ancestry)) { return true; } - } - return false; - - case 'compound': - for (i = 0, l = selector.selectors.length; i < l; ++i) { - if (!matches(node, selector.selectors[i], ancestry)) { return false; } - } - return true; - - case 'not': - for (i = 0, l = selector.selectors.length; i < l; ++i) { - if (matches(node, selector.selectors[i], ancestry)) { return false; } - } - return true; - - case 'has': - var a, collector = []; - for (i = 0, l = selector.selectors.length; i < l; ++i) { - a = []; - estraverse.traverse(node, { - enter: function (node, parent) { - if (parent != null) { a.unshift(parent); } - if (matches(node, selector.selectors[i], a)) { - collector.push(node); - } - }, - leave: function () { a.shift(); } - }); - } - return collector.length !== 0; - - case 'child': - if (matches(node, selector.right, ancestry)) { - return matches(ancestry[0], selector.left, ancestry.slice(1)); - } - return false; - - case 'descendant': - if (matches(node, selector.right, ancestry)) { - for (i = 0, l = ancestry.length; i < l; ++i) { - if (matches(ancestry[i], selector.left, ancestry.slice(i + 1))) { - return true; - } - } - } - return false; - - case 'attribute': - p = getPath(node, selector.name); - switch (selector.operator) { - case null: - case void 0: - return p != null; - case '=': - switch (selector.value.type) { - case 'regexp': return selector.value.value.test(p); - case 'literal': return '' + selector.value.value === '' + p; - case 'type': return selector.value.value === typeof p; - } - case '!=': - switch (selector.value.type) { - case 'regexp': return !selector.value.value.test(p); - case 'literal': return '' + selector.value.value !== '' + p; - case 'type': return selector.value.value !== typeof p; - } - case '<=': return p <= selector.value.value; - case '<': return p < selector.value.value; - case '>': return p > selector.value.value; - case '>=': return p >= selector.value.value; - } - - case 'sibling': - return matches(node, selector.right, ancestry) && - sibling(node, selector.left, ancestry, LEFT_SIDE) || - selector.left.subject && - matches(node, selector.left, ancestry) && - sibling(node, selector.right, ancestry, RIGHT_SIDE); - - case 'adjacent': - return matches(node, selector.right, ancestry) && - adjacent(node, selector.left, ancestry, LEFT_SIDE) || - selector.right.subject && - matches(node, selector.left, ancestry) && - adjacent(node, selector.right, ancestry, RIGHT_SIDE); - - case 'nth-child': - return matches(node, selector.right, ancestry) && - nthChild(node, ancestry, function (length) { - return selector.index.value - 1; - }); - - case 'nth-last-child': - return matches(node, selector.right, ancestry) && - nthChild(node, ancestry, function (length) { - return length - selector.index.value; - }); - - case 'class': - if(!node.type) return false; - switch(selector.name.toLowerCase()){ - case 'statement': - if(node.type.slice(-9) === 'Statement') return true; - // fallthrough: interface Declaration <: Statement { } - case 'declaration': - return node.type.slice(-11) === 'Declaration'; - case 'pattern': - if(node.type.slice(-7) === 'Pattern') return true; - // fallthrough: interface Expression <: Node, Pattern { } - case 'expression': - return node.type.slice(-10) === 'Expression' || - node.type === 'Literal' || - node.type === 'Identifier'; - case 'function': - return node.type.slice(0, 8) === 'Function' || - node.type === 'ArrowFunctionExpression'; - } - throw new Error('Unknown class name: ' + selector.name); - } - - throw new Error('Unknown selector type: ' + selector.type); - } - - /* - * Determines if the given node has a sibling that matches the given selector. - */ - function sibling(node, selector, ancestry, side) { - var parent = ancestry[0], listProp, startIndex, keys, i, l, k, lowerBound, upperBound; - if (!parent) { return false; } - keys = estraverse.VisitorKeys[parent.type]; - for (i = 0, l = keys.length; i < l; ++i) { - listProp = parent[keys[i]]; - if (isArray(listProp)) { - startIndex = listProp.indexOf(node); - if (startIndex < 0) { continue; } - if (side === LEFT_SIDE) { - lowerBound = 0; - upperBound = startIndex; - } else { - lowerBound = startIndex + 1; - upperBound = listProp.length; - } - for (k = lowerBound; k < upperBound; ++k) { - if (matches(listProp[k], selector, ancestry)) { - return true; - } - } - } - } - return false; - } - - /* - * Determines if the given node has an asjacent sibling that matches the given selector. - */ - function adjacent(node, selector, ancestry, side) { - var parent = ancestry[0], listProp, keys, i, l, idx; - if (!parent) { return false; } - keys = estraverse.VisitorKeys[parent.type]; - for (i = 0, l = keys.length; i < l; ++i) { - listProp = parent[keys[i]]; - if (isArray(listProp)) { - idx = listProp.indexOf(node); - if (idx < 0) { continue; } - if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) { - return true; - } - if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) { - return true; - } - } - } - return false; - } - - /* - * Determines if the given node is the nth child, determined by idxFn, which is given the containing list's length. - */ - function nthChild(node, ancestry, idxFn) { - var parent = ancestry[0], listProp, keys, i, l, idx; - if (!parent) { return false; } - keys = estraverse.VisitorKeys[parent.type]; - for (i = 0, l = keys.length; i < l; ++i) { - listProp = parent[keys[i]]; - if (isArray(listProp)) { - idx = listProp.indexOf(node); - if (idx >= 0 && idx === idxFn(listProp.length)) { return true; } - } - } - return false; - } - - /* - * For each selector node marked as a subject, find the portion of the selector that the subject must match. - */ - function subjects(selector, ancestor) { - var results, p; - if (selector == null || typeof selector != 'object') { return []; } - if (ancestor == null) { ancestor = selector; } - results = selector.subject ? [ancestor] : []; - for(p in selector) { - if(!{}.hasOwnProperty.call(selector, p)) { continue; } - [].push.apply(results, subjects(selector[p], p === 'left' ? selector[p] : ancestor)); - } - return results; - } - - /** - * From a JS AST and a selector AST, collect all JS AST nodes that match the selector. - */ - function match(ast, selector) { - var ancestry = [], results = [], altSubjects, i, l, k, m; - if (!selector) { return results; } - altSubjects = subjects(selector); - estraverse.traverse(ast, { - enter: function (node, parent) { - if (parent != null) { ancestry.unshift(parent); } - if (matches(node, selector, ancestry)) { - if (altSubjects.length) { - for (i = 0, l = altSubjects.length; i < l; ++i) { - if (matches(node, altSubjects[i], ancestry)) { results.push(node); } - for (k = 0, m = ancestry.length; k < m; ++k) { - if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) { - results.push(ancestry[k]); - } - } - } - } else { - results.push(node); - } - } - }, - leave: function () { ancestry.shift(); } - }); - return results; - } - - /** - * Parse a selector string and return its AST. - */ - function parse(selector) { - return parser.parse(selector); - } - - /** - * Query the code AST using the selector string. - */ - function query(ast, selector) { - return match(ast, parse(selector)); - } - - query.parse = parse; - query.match = match; - query.matches = matches; - return query.query = query; - } + var esquery = require("./esquery_init"); + var estraverse = require("estraverse"); if (typeof define === "function" && define.amd) { - define(esqueryModule); + define(esquery(estraverse)); } else if (typeof module !== 'undefined' && module.exports) { - module.exports = esqueryModule(); + module.exports = esquery(estraverse); } else { - this.esquery = esqueryModule(); + this.esquery = esquery(estraverse); } })(); From 8a21ecfc7f9718b72ebab105ecfdcba5731f0b59 Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 14:24:57 +0200 Subject: [PATCH 3/9] Optional init-script for JSX-Support require("esquery/jsx") now loads this script which creates the module with the estraverse-fb module instead of the original one. This adds support for JSX-Nodes in a "plug-in" way because estraverse-fb also just extends the estraverse module and this way the most up to date estraverse module can always be used. --- jsx.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 jsx.js diff --git a/jsx.js b/jsx.js new file mode 100644 index 0000000..1512bb5 --- /dev/null +++ b/jsx.js @@ -0,0 +1,16 @@ +/* vim: set sw=4 sts=4 : */ +(function () { + + var esquery = require("./esquery_init"); + var estraverse_jsx = require("estraverse-fb"); + + + if (typeof define === "function" && define.amd) { + define(esquery(estraverse_jsx)); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = esquery(estraverse_jsx); + } else { + this.esquery = esquery(estraverse_jsx); + } + +})(); From 57d50fe3bcc945786b2b4965b3a9f343e7fba69d Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 14:26:46 +0200 Subject: [PATCH 4/9] Create esquery_init.js --- esquery_init => esquery_init.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename esquery_init => esquery_init.js (100%) diff --git a/esquery_init b/esquery_init.js similarity index 100% rename from esquery_init rename to esquery_init.js From 770ba3e459e26e542201c775f4cea377b8243e0c Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 14:29:33 +0200 Subject: [PATCH 5/9] Create package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e5644d..dbec8e4 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "node": ">=0.6" }, "dependencies": { - "estraverse": "^4.0.0" + "estraverse": "^4.0.0", + "estraverse-fb": "*" } } From f5ce547136fd20048b7fed2dc898deb520810f2e Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 14:32:19 +0200 Subject: [PATCH 6/9] Create package.json --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index dbec8e4..b4626a8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "description": "A query library for ECMAScript AST using a CSS selector like query language.", "main": "esquery.js", "files": [ + "esquery_init.js", "esquery.js", + "jsx.js", "parser.js", "license.txt", "README.md" From 5296cc3a92305086aa4d80100e68c7408d4e8e50 Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 14:39:30 +0200 Subject: [PATCH 7/9] Create README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a3ee334..b029583 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,14 @@ The following selectors are supported: * [subject indicator](http://dev.w3.org/csswg/selectors4/#subject): `!IfStatement > [name="foo"]` * class of AST node: `:statement`, `:expression`, `:declaration`, `:function`, or `:pattern` +For JSX-Support use: + +`var esquery = require("esquery/jsx");` + +instead of: + +`var esquery = require("esquery");` + +(Note the '/jsx' part) + [![Build Status](https://travis-ci.org/estools/esquery.png?branch=master)](https://travis-ci.org/estools/esquery) From adb954559b6c5d4bc04de1ed5224da29c4411837 Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 18:52:11 +0200 Subject: [PATCH 8/9] fixing wrong define-"export" --- esquery.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esquery.js b/esquery.js index 6996166..19c0d08 100644 --- a/esquery.js +++ b/esquery.js @@ -6,7 +6,7 @@ if (typeof define === "function" && define.amd) { - define(esquery(estraverse)); + define(function(){return esquery(estraverse);}); } else if (typeof module !== 'undefined' && module.exports) { module.exports = esquery(estraverse); } else { From 11c7e6f34292c657f3d0fc755c6661817a6b220c Mon Sep 17 00:00:00 2001 From: allesklarbeidir Date: Mon, 12 Jun 2017 18:52:56 +0200 Subject: [PATCH 9/9] fixing wrong define-"export" --- jsx.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsx.js b/jsx.js index 1512bb5..d249850 100644 --- a/jsx.js +++ b/jsx.js @@ -6,7 +6,7 @@ if (typeof define === "function" && define.amd) { - define(esquery(estraverse_jsx)); + define(function(){return esquery(estraverse_jsx);}); } else if (typeof module !== 'undefined' && module.exports) { module.exports = esquery(estraverse_jsx); } else {