handle-message.cjs
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const babel = require("./babel-core.cjs");
const maybeParse = require("./maybeParse.cjs");
const {
getVisitorKeys,
getTokLabels
} = require("./ast-info.cjs");
const {
normalizeBabelParseConfig,
normalizeBabelParseConfigSync
} = require("./configuration.cjs");
module.exports = function handleMessage(action, payload) {
switch (action) {
case "GET_VERSION":
return babel.version;
case "GET_TYPES_INFO":
return {
FLOW_FLIPPED_ALIAS_KEYS: babel.types.FLIPPED_ALIAS_KEYS.Flow,
VISITOR_KEYS: babel.types.VISITOR_KEYS
};
case "GET_TOKEN_LABELS":
return getTokLabels();
case "GET_VISITOR_KEYS":
return getVisitorKeys();
case "MAYBE_PARSE":
return normalizeBabelParseConfig(payload.options).then(options => maybeParse(payload.code, options));
case "MAYBE_PARSE_SYNC":
{
return maybeParse(payload.code, normalizeBabelParseConfigSync(payload.options));
}
}
throw new Error(`Unknown internal parser worker action: ${action}`);
};
//# sourceMappingURL=handle-message.cjs.map