Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for TLA on node 14.3 and newer #7

Merged
merged 2 commits into from Oct 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
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]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess 15 doesn't matter, but anyways


steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion package.json
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
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)) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug fix looking at the comment above

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
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
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