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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| ```dependencies```传入文件的内部依赖 ```code```转译成一般js的当前文件代码
通过```fs.readFileSync```读取文件,```babylon.parse()```转换为```AST```语法树
```json // example/entry.js转译为Node Node { type: 'File', start: 0, end: 57, loc: SourceLocation { start: Position { line: 1, column: 0 }, end: Position { line: 3, column: 21 } }, program: Node { type: 'Program', start: 0, end: 57, loc: SourceLocation { start: [Position], end: [Position] }, sourceType: 'module', body: [ [Node], [Node] ], directives: [] }, comments: [], tokens: [ Token { type: [KeywordTokenType], value: 'import', start: 0, end: 6, loc: [SourceLocation] }, Token { type: [TokenType], value: 'message', start: 7, end: 14, loc: [SourceLocation] }, Token { type: [TokenType], value: 'from', start: 15, end: 19, loc: [SourceLocation] }, Token { type: [TokenType], value: './message.js', start: 20, end: 34, loc: [SourceLocation] }, Token { type: [TokenType], value: 'console', start: 36, end: 43, loc: [SourceLocation] }, Token { type: [TokenType], value: undefined, start: 43, end: 44, loc: [SourceLocation] }, Token { type: [TokenType], value: 'log', start: 44, end: 47, loc: [SourceLocation] }, Token { type: [TokenType], value: undefined, start: 47, end: 48, loc: [SourceLocation] }, Token { type: [TokenType], value: 'message', start: 48, end: 55, loc: [SourceLocation] }, Token { type: [TokenType], value: undefined, start: 55, end: 56, loc: [SourceLocation] }, Token { type: [TokenType], value: undefined, start: 56, end: 57, loc: [SourceLocation] }, Token { type: [TokenType], value: undefined, start: 57, end: 57, loc: [SourceLocation] } ] }
|