-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Extraction of AST Logic (#15892)
* POC for Shared AST Logic using Yarn Symlinks * fix: preinstall script for bundling shared packages * Merge commit * fix: updated the script to link, unlink the package as shared dep * fix: updated dependencies * Add a post-install script and fix yarn.lock file * Remove commented code * fix: added verification script, readme, moved scripts to shared * Extraction of AST Logic into shared/ast folder * Add jest test script * Replace hardcoded ast Logic use with Shared AST module * Replace parse code with getAST Co-authored-by: Aman Agarwal <[email protected]>
- Loading branch information
1 parent
5cf06cd
commit 3de00c6
Showing
15 changed files
with
1,035 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
ObjectExpression, | ||
PropertyNode, | ||
isIdentifierNode, | ||
isVariableDeclarator, | ||
isObjectExpression, | ||
isLiteralNode, | ||
isPropertyNode, | ||
isPropertyAFunctionNode, | ||
getAST, | ||
extractIdentifiersFromCode, | ||
getFunctionalParamsFromNode, | ||
isTypeOfFunction, | ||
} from "./src/index"; | ||
|
||
// constants | ||
import { ECMA_VERSION, SourceType, NodeTypes } from "./src/constants"; | ||
|
||
// JSObjects | ||
import { parseJSObjectWithAST } from "./src/jsObject"; | ||
|
||
// types or intefaces should be exported with type keyword, while enums can be exported like normal functions | ||
export type { ObjectExpression, PropertyNode }; | ||
|
||
export { | ||
isIdentifierNode, | ||
isVariableDeclarator, | ||
isObjectExpression, | ||
isLiteralNode, | ||
isPropertyNode, | ||
isPropertyAFunctionNode, | ||
getAST, | ||
extractIdentifiersFromCode, | ||
getFunctionalParamsFromNode, | ||
isTypeOfFunction, | ||
parseJSObjectWithAST, | ||
ECMA_VERSION, | ||
SourceType, | ||
NodeTypes, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export const ECMA_VERSION = 11; | ||
|
||
/* Indicates the mode the code should be parsed in. | ||
This influences global strict mode and parsing of import and export declarations. | ||
*/ | ||
export enum SourceType { | ||
script = "script", | ||
module = "module", | ||
} | ||
|
||
// Each node has an attached type property which further defines | ||
// what all properties can the node have. | ||
// We will just define the ones we are working with | ||
export enum NodeTypes { | ||
Identifier = "Identifier", | ||
AssignmentPattern = "AssignmentPattern", | ||
Literal = "Literal", | ||
Property = "Property", | ||
// Declaration - https://github.com/estree/estree/blob/master/es5.md#declarations | ||
FunctionDeclaration = "FunctionDeclaration", | ||
ExportDefaultDeclaration = "ExportDefaultDeclaration", | ||
VariableDeclarator = "VariableDeclarator", | ||
// Expression - https://github.com/estree/estree/blob/master/es5.md#expressions | ||
MemberExpression = "MemberExpression", | ||
FunctionExpression = "FunctionExpression", | ||
ArrowFunctionExpression = "ArrowFunctionExpression", | ||
ObjectExpression = "ObjectExpression", | ||
ArrayExpression = "ArrayExpression", | ||
ThisExpression = "ThisExpression", | ||
} |
Oops, something went wrong.