Remove dynamic imports (#14369)
This commit is contained in:
1 parent
be474c7891
commit
4fb03a7f2a
15 files changed
+130
-181
No files matched your search
Vendored
+25
-17
@@ -1,31 +1,39 @@
|
||||
import {
|
||||
parseAction,
|
||||
parseBinding,
|
||||
parseInterpolationExpression,
|
||||
parseTemplateBindings,
|
||||
} from "angular-estree-parser";
|
||||
import { locStart, locEnd } from "../loc.js";
|
||||
|
||||
/**
|
||||
* @param {"parseAction" | "parseBinding" | "parseInterpolationExpression" | "parseTemplateBindings"} parseMethod
|
||||
* @param {parseAction | parseBinding | parseInterpolationExpression | parseTemplateBindings} parseMethod
|
||||
*/
|
||||
function createParser(parseMethod) {
|
||||
const parse = async (text) => {
|
||||
const { [parseMethod]: parse } = await import("angular-estree-parser");
|
||||
const node = parse(text);
|
||||
return {
|
||||
astFormat: "estree",
|
||||
parse(text) {
|
||||
const node = parseMethod(text);
|
||||
|
||||
return {
|
||||
type: "NGRoot",
|
||||
node:
|
||||
parseMethod === "parseAction" && node.type !== "NGChainedExpression"
|
||||
? { ...node, type: "NGChainedExpression", expressions: [node] }
|
||||
: node,
|
||||
};
|
||||
return {
|
||||
type: "NGRoot",
|
||||
node:
|
||||
parseMethod === parseAction && node.type !== "NGChainedExpression"
|
||||
? { ...node, type: "NGChainedExpression", expressions: [node] }
|
||||
: node,
|
||||
};
|
||||
},
|
||||
locStart,
|
||||
locEnd,
|
||||
};
|
||||
|
||||
return { astFormat: "estree", parse, locStart, locEnd };
|
||||
}
|
||||
|
||||
const parser = {
|
||||
parsers: {
|
||||
__ng_action: createParser("parseAction"),
|
||||
__ng_binding: createParser("parseBinding"),
|
||||
__ng_interpolation: createParser("parseInterpolationExpression"),
|
||||
__ng_directive: createParser("parseTemplateBindings"),
|
||||
__ng_action: createParser(parseAction),
|
||||
__ng_binding: createParser(parseBinding),
|
||||
__ng_interpolation: createParser(parseInterpolationExpression),
|
||||
__ng_directive: createParser(parseTemplateBindings),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user