mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
PR-URL: https://github.com/nodejs/node/pull/39094 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
40 lines
878 B
JavaScript
40 lines
878 B
JavaScript
const babel = require("./babel-core.cjs");
|
|
|
|
const maybeParse = require("./maybeParse.cjs");
|
|
|
|
const {
|
|
getVisitorKeys,
|
|
getTokLabels
|
|
} = require("./ast-info.cjs");
|
|
|
|
const normalizeBabelParseConfig = require("./configuration.cjs");
|
|
|
|
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 maybeParse(payload.code, normalizeBabelParseConfig(payload.options));
|
|
}
|
|
}
|
|
|
|
throw new Error(`Unknown internal parser worker action: ${action}`);
|
|
}
|
|
|
|
{
|
|
module.exports = handleMessage;
|
|
} |