Add node modules and new code for release (#39)

Co-authored-by: tbarnes94 <tbarnes94@users.noreply.github.com>
This commit is contained in:
github-actions[bot] 2022-01-05 11:26:06 -05:00 committed by GitHub
parent a10d84bc2e
commit 7ad2aa66bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7655 changed files with 1763577 additions and 14 deletions

22
node_modules/babel-preset-current-node-syntax/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2020 Nicolò Ribaudo and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,30 @@
# `babel-preset-current-node-syntax`
> A Babel preset that enables parsing of proposals supported by the current Node.js version.
## Installation
If you are using yarn:
```
yarn add --dev babel-preset-current-node-syntax
```
If you are using npm:
```
npm install --save-dev babel-preset-current-node-syntax
```
## Contributing
PRs are welcome! The codebase is so small that I didn't setup a linter, but try
to match the style of the existing code.
You can run tests with the following command:
```
yarn node test/index.js
```
The `test/fixtures.json` file contains a bunch of syntax tests, alongside with
the minimum supported node version for each of them. Babel should throw on
older versions, without support for that given syntax.
All the tests are run using `@babel/parser@7.0.0`.

View file

@ -0,0 +1,40 @@
{
"name": "babel-preset-current-node-syntax",
"version": "0.1.3",
"description": "A Babel preset that enables parsing of proposals supported by the current Node.js version.",
"main": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/nicolo-ribaudo/babel-preset-current-node-syntax.git"
},
"author": {
"name": "Nicolò Ribaudo",
"url": "https://github.com/nicolo-ribaudo"
},
"scripts": {
"test": "node ./test/index.js"
},
"dependencies": {
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-bigint": "^7.8.3",
"@babel/plugin-syntax-class-properties": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.8.3",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-logical-assignment-operators": "^7.8.3",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@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"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
"devDependencies": {
"@babel/core": "7.0.0"
},
"resolutions": {
"@babel/parser": "7.0.0"
},
"license": "MIT"
}

View file

@ -0,0 +1,52 @@
const tests = {
// ECMAScript 2018
"object-rest-spread": ["({ ...{} })", "({ ...x } = {})"], // Babel 7.2.0
"async-generators": ["async function* f() {}"], // Babel 7.2.0
// ECMAScript 2019
"optional-catch-binding": ["try {} catch {}"], // Babel 7.2.0
"json-strings": ["'\\u2028'"], // Babel 7.2.0
// ECMAScript 2020
"bigint": ["1n"], // Babel 7.8.0
"optional-chaining": ["a?.b"], // Babel 7.9.0
"nullish-coalescing-operator": ["a ?? b"], // Babel 7.9.0
// import.meta is handled manually
// Stage 3
"numeric-separator": ["1_2"],
"class-properties": [
"(class { x = 1 })",
"(class { #x = 1 })",
"(class { #x() {} })",
],
"logical-assignment-operators": ["a ||= b", "a &&= b", "a ??= c"],
};
const plugins = [];
const works = (test) => {
try {
// Wrap the test in a function to only test the syntax, without executing it
(0, eval)(`(() => { ${test} })`);
return true;
} catch (_error) {
return false;
}
};
for (const [name, cases] of Object.entries(tests)) {
if (cases.some(works)) {
plugins.push(require.resolve(`@babel/plugin-syntax-${name}`));
}
}
// import.meta is only allowed in modules, and modules can only be evaluated
// synchronously. For this reason, we cannot detect import.meta support at
// 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)) {
plugins.push(require.resolve("@babel/plugin-syntax-import-meta"));
}
module.exports = () => ({ plugins });