@react-native/babel-plugin-codegen 0.72.1 → 0.72.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/index.js +12 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -9,21 +9,28 @@
|
|
|
9
9
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
let
|
|
12
|
+
let FlowParser, TypeScriptParser, RNCodegen;
|
|
13
13
|
|
|
14
14
|
const {basename} = require('path');
|
|
15
15
|
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
FlowParser =
|
|
18
|
+
require('@react-native/codegen/src/parsers/flow/parser').FlowParser;
|
|
19
|
+
TypeScriptParser =
|
|
20
|
+
require('@react-native/codegen/src/parsers/typescript/parser').TypeScriptParser;
|
|
19
21
|
RNCodegen = require('@react-native/codegen/src/generators/RNCodegen');
|
|
20
22
|
} catch (e) {
|
|
21
23
|
// Fallback to lib when source doesn't exit (e.g. when installed as a dev dependency)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
FlowParser =
|
|
25
|
+
require('@react-native/codegen/lib/parsers/flow/parser').FlowParser;
|
|
26
|
+
TypeScriptParser =
|
|
27
|
+
require('@react-native/codegen/lib/parsers/typescript/parser').TypeScriptParser;
|
|
24
28
|
RNCodegen = require('@react-native/codegen/lib/generators/RNCodegen');
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
const flowParser = new FlowParser();
|
|
32
|
+
const typeScriptParser = new TypeScriptParser();
|
|
33
|
+
|
|
27
34
|
function parseFile(filename, code) {
|
|
28
35
|
if (filename.endsWith('js')) {
|
|
29
36
|
return flowParser.parseString(code);
|
package/package.json
CHANGED