From 5f162f89665a01aa9911c5ebbf5d173c0fd09f95 Mon Sep 17 00:00:00 2001 From: Brian Donovan Date: Mon, 19 Nov 2018 09:15:55 -0500 Subject: [PATCH] fix(recast): always generate tokens This is now required for recast, as it'll othewise fall back on esprima which doesn't work for JSX. https://github.com/benjamn/recast/pull/537 --- src/BabelPluginTypes.ts | 1 + src/RecastPlugin.ts | 2 +- yarn.lock | 12 +++++------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/BabelPluginTypes.ts b/src/BabelPluginTypes.ts index 7f824cd3..3541e840 100644 --- a/src/BabelPluginTypes.ts +++ b/src/BabelPluginTypes.ts @@ -11,6 +11,7 @@ export interface ParseOptions { allowReturnOutsideFunction?: boolean; allowSuperOutsideMethod?: boolean; plugins?: Array; + tokens?: boolean; } export type AST = object; diff --git a/src/RecastPlugin.ts b/src/RecastPlugin.ts index b5ee152b..b656fa63 100644 --- a/src/RecastPlugin.ts +++ b/src/RecastPlugin.ts @@ -11,7 +11,7 @@ export function parse( return recast.parse(code, { parser: { parse(code: string) { - return parse(code, options); + return parse(code, { ...options, tokens: true }); } } }); diff --git a/yarn.lock b/yarn.lock index 9c59b73b..c6a4ab80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -894,7 +894,8 @@ assign-symbols@^1.0.0: ast-types@0.11.6: version "0.11.6" - resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.11.6.tgz#4e2266c2658829aef3b40cc33ad599c4e9eb89ef" + resolved "https://registry.npmjs.org/ast-types/-/ast-types-0.11.6.tgz#4e2266c2658829aef3b40cc33ad599c4e9eb89ef" + integrity sha512-nHiuV14upVGl7MWwFUYbzJ6YlfwWS084CU9EA8HajfYQjMSli5TQi3UTRygGF58LFWVkXxS1rbgRhROEqlQkXg== atob@^2.1.1: version "2.1.2" @@ -1369,14 +1370,10 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" -esprima@^4.0.0: +esprima@^4.0.0, esprima@~4.0.0: version "4.0.1" resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" -esprima@~4.0.0: - version "4.0.0" - resolved "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" - esutils@^2.0.2: version "2.0.2" resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -2795,7 +2792,8 @@ readable-stream@^2.0.0, readable-stream@^2.1.5: recast@^0.16.1: version "0.16.1" - resolved "https://registry.yarnpkg.com/recast/-/recast-0.16.1.tgz#865f1800ef76e42e5d0375763b80f4d6a05f2069" + resolved "https://registry.npmjs.org/recast/-/recast-0.16.1.tgz#865f1800ef76e42e5d0375763b80f4d6a05f2069" + integrity sha512-ZUQm94F3AHozRaTo4Vz6yIgkSEZIL7p+BsWeGZ23rx+ZVRoqX+bvBA8br0xmCOU0DSR4qYGtV7Y5HxTsC4V78A== dependencies: ast-types "0.11.6" esprima "~4.0.0"