From 0c1bc3270340a84101d12dbee50631bc3a7dc64b Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 4 Jul 2019 15:48:08 -0400 Subject: [PATCH] Remove tolerantParse workaround from parser.js. Now that @babel/parser@7.5.0 is out, we no longer need to simulate the effect of https://github.com/babel/babel/pull/9864. See also https://github.com/benjamn/reify/pull/230. --- parser.js | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/parser.js b/parser.js index 759b709..17cc6fe 100644 --- a/parser.js +++ b/parser.js @@ -1,30 +1,10 @@ "use strict"; const babelParser = require("@babel/parser"); -const babelParserVersion = require("@babel/parser/package.json").version; const defaultParserOptions = require("reify/lib/parsers/babel.js").options; function parse(code, parserOptions) { return babelParser.parse(code, parserOptions || defaultParserOptions); } -function tolerantParse(code, parserOptions) { - const arrayFrom = Array.from; - // There is only one use of Array.from in the @babel/parser@7.4.x code, - // Array.from(this.scope.undefinedExports), which determines whether the - // parser complains prematurely about exporting identifiers that were - // not declared in the current module scope. By returning an empty array - // when the source argument is a Map, we can effectively disable that - // error behavior, until https://github.com/babel/babel/pull/9864 is - // released in @babel/parser@7.5.0. - Array.from = function (source) { - return source instanceof Map ? [] : arrayFrom.apply(this, arguments); - }; - try { - return parse(code, parserOptions); - } finally { - Array.from = arrayFrom; - } -} - -exports.parse = babelParserVersion.startsWith("7.4.") ? tolerantParse : parse; +exports.parse = parse;