Skip to content

Commit

Permalink
Merge pull request #641 from OpenFn/bump-compiler-js-version
Browse files Browse the repository at this point in the history
Compiler: bump js version
  • Loading branch information
josephjclark authored Mar 22, 2024
2 parents b77cd85 + 3e4d9c1 commit 66fd7da
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-geese-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openfn/compiler': minor
---

Support latest ecmascript version
5 changes: 2 additions & 3 deletions packages/compiler/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ export default function parse(source: string) {
range: true,
parser: {
parse: (source: string) =>
// TODO this can't parse nullish coalescence, so maybe we just need a more modern ecma version!
acorn.parse(source, {
sourceType: 'module', // Note: this is different to v1 (but back compatible I think)
ecmaVersion: 10,
sourceType: 'module',
ecmaVersion: 'latest',
allowHashBang: true,
locations: true,
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/test/asts/cjs.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"program":{"type":"Program","start":0,"end":20,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":20,"token":6},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"indent":0,"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}]},"body":[{"type":"ExpressionStatement","start":0,"end":20,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":20,"token":6},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"expression":{"type":"AssignmentExpression","start":0,"end":19,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":19,"token":5},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"operator":"=","left":{"type":"MemberExpression","start":0,"end":14,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":14,"token":3},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"object":{"type":"Identifier","start":0,"end":6,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":6,"token":1},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"name":"module"},"property":{"type":"Identifier","start":7,"end":14,"loc":{"start":{"line":1,"column":7,"token":2},"end":{"line":1,"column":14,"token":3},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"name":"exports"},"computed":false},"right":{"type":"Literal","start":17,"end":19,"loc":{"start":{"line":1,"column":17,"token":4},"end":{"line":1,"column":19,"token":5},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"value":10,"raw":"10"}}}],"sourceType":"module","errors":[]},"name":null,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":20,"token":6},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"indent":0,"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}]},"type":"File","comments":null,"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}]}
{"program":{"type":"Program","start":0,"end":20,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":20,"token":6},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"indent":0,"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}]},"body":[{"type":"ExpressionStatement","start":0,"end":20,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":20,"token":6},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"expression":{"type":"AssignmentExpression","start":0,"end":19,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":19,"token":5},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"operator":"=","left":{"type":"MemberExpression","start":0,"end":14,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":14,"token":3},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"object":{"type":"Identifier","start":0,"end":6,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":6,"token":1},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"name":"module"},"property":{"type":"Identifier","start":7,"end":14,"loc":{"start":{"line":1,"column":7,"token":2},"end":{"line":1,"column":14,"token":3},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"name":"exports"},"computed":false,"optional":false},"right":{"type":"Literal","start":17,"end":19,"loc":{"start":{"line":1,"column":17,"token":4},"end":{"line":1,"column":19,"token":5},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}],"indent":0},"value":10,"raw":"10"}}}],"sourceType":"module","errors":[]},"name":null,"loc":{"start":{"line":1,"column":0,"token":0},"end":{"line":1,"column":20,"token":6},"lines":{"infos":[{"line":"module.exports = 10;","indent":0,"locked":false,"sliceStart":0,"sliceEnd":20}],"mappings":[],"cachedSourceMap":null,"length":1,"name":null},"indent":0,"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}]},"type":"File","comments":null,"tokens":[{"type":"Identifier","value":"module","loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":6}}},{"type":"Punctuator","value":".","loc":{"start":{"line":1,"column":6},"end":{"line":1,"column":7}}},{"type":"Identifier","value":"exports","loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":14}}},{"type":"Punctuator","value":"=","loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":16}}},{"type":"Numeric","value":"10","loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":19}}},{"type":"Punctuator","value":";","loc":{"start":{"line":1,"column":19},"end":{"line":1,"column":20}}}]}
2 changes: 1 addition & 1 deletion packages/compiler/test/asts/multiple-operations.json

Large diffs are not rendered by default.

Loading

0 comments on commit 66fd7da

Please sign in to comment.