babel-plugin-syntax-hermes-parser 0.18.0 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -24,15 +24,23 @@ function BabelPluginSyntaxHermesParser( // $FlowExpectedError[unclear-type] We d
24
24
  api) {
25
25
  api.assertVersion(7);
26
26
  let curParserOpts = {};
27
+ let curFilename = null;
27
28
  return {
28
29
  name: 'syntax-hermes-parser',
29
30
 
30
31
  manipulateOptions(opts) {
31
32
  curParserOpts = opts.parserOpts;
33
+ curFilename = opts.filename;
32
34
  },
33
35
 
34
36
  // API suggested via https://babeljs.io/docs/babel-parser#will-the-babel-parser-support-a-plugin-system
35
37
  parserOverride(code) {
38
+ const filename = curFilename;
39
+
40
+ if (filename != null && (filename.endsWith('.ts') || filename.endsWith('.tsx'))) {
41
+ return;
42
+ }
43
+
36
44
  const opts = {};
37
45
 
38
46
  for (const [key, value] of Object.entries(curParserOpts)) {
@@ -21,16 +21,27 @@ export default function BabelPluginSyntaxHermesParser(
21
21
  api.assertVersion(7);
22
22
 
23
23
  let curParserOpts: ParserOptions = {};
24
+ let curFilename: ?string = null;
24
25
 
25
26
  return {
26
27
  name: 'syntax-hermes-parser',
27
28
 
28
- manipulateOptions(opts: $ReadOnly<{parserOpts: ParserOptions}>) {
29
+ manipulateOptions(
30
+ opts: $ReadOnly<{parserOpts: ParserOptions, filename?: ?string}>,
31
+ ) {
29
32
  curParserOpts = opts.parserOpts;
33
+ curFilename = opts.filename;
30
34
  },
31
35
 
32
36
  // API suggested via https://babeljs.io/docs/babel-parser#will-the-babel-parser-support-a-plugin-system
33
37
  parserOverride(code: string) {
38
+ const filename = curFilename;
39
+ if (
40
+ filename != null &&
41
+ (filename.endsWith('.ts') || filename.endsWith('.tsx'))
42
+ ) {
43
+ return;
44
+ }
34
45
  const opts: ParserOptions = {};
35
46
  for (const [key, value] of Object.entries(curParserOpts)) {
36
47
  if (HermesParser.ParserOptionsKeys.has(key)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-syntax-hermes-parser",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "Babel plugin which switches Babel to use the Hermes parser.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "url": "git@github.com:facebook/hermes.git"
10
10
  },
11
11
  "dependencies": {
12
- "hermes-parser": "0.18.0"
12
+ "hermes-parser": "0.18.2"
13
13
  },
14
14
  "files": [
15
15
  "dist",