Skip to content

Commit

Permalink
feat: add suppotr for TLA on node 14.3 and newer
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and nicolo-ribaudo committed Oct 31, 2020
1 parent 33768e4 commit f3f2f9e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [10.19, 12.4, 12.8, 13.11, 14]
node-version: [10.19, 12.4, 12.8, 13.11, 14.3, 14, 15]

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"@babel/plugin-syntax-numeric-separator": "^7.8.3",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3",
"@babel/plugin-syntax-optional-chaining": "^7.8.3"
"@babel/plugin-syntax-optional-chaining": "^7.8.3",
"@babel/plugin-syntax-top-level-await": "^7.8.3"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,13 @@ for (const [name, cases] of Object.entries(tests)) {
// runtime. It is supported starting from 10.4, so we can check the version.
const major = parseInt(process.versions.node, 10);
const minor = parseInt(process.versions.node.match(/^\d+\.(\d+)/)[1], 10);
if (major > 10 || (major === 10 && minor > 4)) {
if (major > 10 || (major === 10 && minor >= 4)) {
plugins.push(require.resolve("@babel/plugin-syntax-import-meta"));
}
// Same for top level await - it is only supported in modules. It is supported
// from 14.3.0
if (major > 14 || (major === 14 && minor >= 3)) {
plugins.push(require.resolve("@babel/plugin-syntax-top-level-await"));
}

module.exports = () => ({ plugins });
3 changes: 2 additions & 1 deletion test/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"numeric separators": [12.7, "1_2"],
"optional chaining": [14.0, "a?.b"],
"nullish coalescing": [14.0, "a ?? b"],
"import.meta": [10.4, "import.meta"]
"import.meta": [10.4, "import.meta"],
"top level await": [14.3, "await Promise.resolve()"]
}
20 changes: 16 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ __metadata:
languageName: node
linkType: hard

"@babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3":
version: 7.8.3
resolution: "@babel/helper-plugin-utils@npm:7.8.3"
checksum: 56f09626f24511aadd36a96aacd8658274ededc2e94f5e85bb6e51c9e6ad72eb1dd9f9a28a4ee5a8691de7601cf2a8e63ce235db01dda8964779940281f2787f
"@babel/helper-plugin-utils@npm:^7.10.4, @babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3":
version: 7.10.4
resolution: "@babel/helper-plugin-utils@npm:7.10.4"
checksum: 9f617e619a3557cb5fae8885e91cd94ba4ee16fb345e0360de0d7dc037efb10cc604939ecc1038ccdb71aa37e7e78f20133d7bbbebecb8f6dcdb557650366d92
languageName: node
linkType: hard

Expand Down Expand Up @@ -243,6 +243,17 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-syntax-top-level-await@npm:^7.8.3":
version: 7.12.1
resolution: "@babel/plugin-syntax-top-level-await@npm:7.12.1"
dependencies:
"@babel/helper-plugin-utils": ^7.10.4
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: 9767e46ddc1add9133a21f5d6c4452e9a62f891fe1db5d8291f62f9036f9e697bc118adad43109a8740ac15769e9489d68d134b17cfe9f3bdf06d2c50c9c6dce
languageName: node
linkType: hard

"@babel/template@npm:^7.0.0, @babel/template@npm:^7.8.3":
version: 7.8.6
resolution: "@babel/template@npm:7.8.6"
Expand Down Expand Up @@ -307,6 +318,7 @@ __metadata:
"@babel/plugin-syntax-object-rest-spread": ^7.8.3
"@babel/plugin-syntax-optional-catch-binding": ^7.8.3
"@babel/plugin-syntax-optional-chaining": ^7.8.3
"@babel/plugin-syntax-top-level-await": ^7.8.3
peerDependencies:
"@babel/core": ^7.0.0
languageName: unknown
Expand Down

0 comments on commit f3f2f9e

Please sign in to comment.