diff --git a/.browserslistrc b/.browserslistrc new file mode 100644 index 0000000..496d1ef --- /dev/null +++ b/.browserslistrc @@ -0,0 +1 @@ +defaults \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3121e34..9f88f55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change log ## [Unreleased] +### Added + * Make the Hermes parser optional and disabled by default. + It can now be activated by setting hte `parser` option + `[["@gandi/gandi", { "parser": "hermes" }]]`. ## 6.1.0 - 2024-07-29 ### Changed diff --git a/index.js b/index.js index df55b44..ce3e95b 100644 --- a/index.js +++ b/index.js @@ -29,9 +29,11 @@ */ module.exports = (context, options = {}) => { + let { parser = 'babel', ...envOptions } = options; + let envOpts = { bugfixes: true, - ...options, + ...envOptions, }; let reactOpts = { @@ -53,7 +55,7 @@ module.exports = (context, options = {}) => { ]; let plugins = [ - 'babel-plugin-syntax-hermes-parser', + ...(parser === 'hermes' ? ['babel-plugin-syntax-hermes-parser'] : []), ['@babel/plugin-transform-runtime', runtimeOpts], ]; diff --git a/test/__file_snapshots__/cjsm--Array.flatMap-0 b/test/__file_snapshots__/babel-cjsm---ES--Array.flatMap-0 similarity index 100% rename from test/__file_snapshots__/cjsm--Array.flatMap-0 rename to test/__file_snapshots__/babel-cjsm---ES--Array.flatMap-0 diff --git a/test/__file_snapshots__/cjsm--Object.entries-0 b/test/__file_snapshots__/babel-cjsm---ES--Object.entries-0 similarity index 100% rename from test/__file_snapshots__/cjsm--Object.entries-0 rename to test/__file_snapshots__/babel-cjsm---ES--Object.entries-0 diff --git a/test/__file_snapshots__/cjsm--Promise.allSettled-0 b/test/__file_snapshots__/babel-cjsm---ES--Promise.allSettled-0 similarity index 100% rename from test/__file_snapshots__/cjsm--Promise.allSettled-0 rename to test/__file_snapshots__/babel-cjsm---ES--Promise.allSettled-0 diff --git a/test/__file_snapshots__/cjsm--Runtime-ponyfills-0 b/test/__file_snapshots__/babel-cjsm---ES--Runtime-ponyfills-0 similarity index 100% rename from test/__file_snapshots__/cjsm--Runtime-ponyfills-0 rename to test/__file_snapshots__/babel-cjsm---ES--Runtime-ponyfills-0 diff --git a/test/__file_snapshots__/cjsm--async-await-0 b/test/__file_snapshots__/babel-cjsm---ES--async-await-0 similarity index 100% rename from test/__file_snapshots__/cjsm--async-await-0 rename to test/__file_snapshots__/babel-cjsm---ES--async-await-0 diff --git a/test/__file_snapshots__/cjsm--class-properties-0 b/test/__file_snapshots__/babel-cjsm---ES--class-properties-0 similarity index 100% rename from test/__file_snapshots__/cjsm--class-properties-0 rename to test/__file_snapshots__/babel-cjsm---ES--class-properties-0 diff --git a/test/__file_snapshots__/cjsm--dynamic-imports-0 b/test/__file_snapshots__/babel-cjsm---ES--dynamic-imports-0 similarity index 100% rename from test/__file_snapshots__/cjsm--dynamic-imports-0 rename to test/__file_snapshots__/babel-cjsm---ES--dynamic-imports-0 diff --git a/test/__file_snapshots__/cjsm--nullish-coalescing-0 b/test/__file_snapshots__/babel-cjsm---ES--nullish-coalescing-0 similarity index 100% rename from test/__file_snapshots__/cjsm--nullish-coalescing-0 rename to test/__file_snapshots__/babel-cjsm---ES--nullish-coalescing-0 diff --git a/test/__file_snapshots__/cjsm--object-rest-spread-0 b/test/__file_snapshots__/babel-cjsm---ES--object-rest-spread-0 similarity index 100% rename from test/__file_snapshots__/cjsm--object-rest-spread-0 rename to test/__file_snapshots__/babel-cjsm---ES--object-rest-spread-0 diff --git a/test/__file_snapshots__/babel-cjsm---ES--optional-chaining-0 b/test/__file_snapshots__/babel-cjsm---ES--optional-chaining-0 new file mode 100644 index 0000000..15f72a2 --- /dev/null +++ b/test/__file_snapshots__/babel-cjsm---ES--optional-chaining-0 @@ -0,0 +1,12 @@ +"use strict"; + +let obj = { + foo: { + bar: { + baz: 42 + } + } +}; +let baz = obj?.foo?.bar?.baz; // 42 + +let safe = obj?.qux?.baz; // undefined \ No newline at end of file diff --git a/test/__file_snapshots__/cjsm--static-class-properties-0 b/test/__file_snapshots__/babel-cjsm---ES--static-class-properties-0 similarity index 100% rename from test/__file_snapshots__/cjsm--static-class-properties-0 rename to test/__file_snapshots__/babel-cjsm---ES--static-class-properties-0 diff --git a/test/__file_snapshots__/cjsm--flow-0 b/test/__file_snapshots__/babel-cjsm---Flow--Types-0 similarity index 100% rename from test/__file_snapshots__/cjsm--flow-0 rename to test/__file_snapshots__/babel-cjsm---Flow--Types-0 diff --git a/test/__file_snapshots__/cjsm--React-class-component-0 b/test/__file_snapshots__/babel-cjsm---React--class-component-0 similarity index 100% rename from test/__file_snapshots__/cjsm--React-class-component-0 rename to test/__file_snapshots__/babel-cjsm---React--class-component-0 diff --git a/test/__file_snapshots__/cjsm--React-function-component-0 b/test/__file_snapshots__/babel-cjsm---React--function-component-0 similarity index 100% rename from test/__file_snapshots__/cjsm--React-function-component-0 rename to test/__file_snapshots__/babel-cjsm---React--function-component-0 diff --git a/test/__file_snapshots__/cjsm--jsx-0 b/test/__file_snapshots__/babel-cjsm---React--jsx-0 similarity index 100% rename from test/__file_snapshots__/cjsm--jsx-0 rename to test/__file_snapshots__/babel-cjsm---React--jsx-0 diff --git a/test/__file_snapshots__/cjsm--jsx-spread-0 b/test/__file_snapshots__/babel-cjsm---React--jsx-spread-0 similarity index 100% rename from test/__file_snapshots__/cjsm--jsx-spread-0 rename to test/__file_snapshots__/babel-cjsm---React--jsx-spread-0 diff --git a/test/__file_snapshots__/cjsm--Regression--Flow-void-class-properties-0 b/test/__file_snapshots__/babel-cjsm---Regression--Flow-void-class-properties-0 similarity index 100% rename from test/__file_snapshots__/cjsm--Regression--Flow-void-class-properties-0 rename to test/__file_snapshots__/babel-cjsm---Regression--Flow-void-class-properties-0 diff --git a/test/__file_snapshots__/babel-cjsm---Regression--Webpack-magic-comments-0 b/test/__file_snapshots__/babel-cjsm---Regression--Webpack-magic-comments-0 new file mode 100644 index 0000000..5efbc05 --- /dev/null +++ b/test/__file_snapshots__/babel-cjsm---Regression--Webpack-magic-comments-0 @@ -0,0 +1,5 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default; +var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/interopRequireWildcard")); +Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require( /* webpackChunkName: foo */'bar'))); \ No newline at end of file diff --git a/test/__file_snapshots__/babel-cjsm---Regression--react-docgen-comments-0 b/test/__file_snapshots__/babel-cjsm---Regression--react-docgen-comments-0 new file mode 100644 index 0000000..934c616 --- /dev/null +++ b/test/__file_snapshots__/babel-cjsm---Regression--react-docgen-comments-0 @@ -0,0 +1,4 @@ +"use strict"; + +/** @component */ +function Foo() {} \ No newline at end of file diff --git a/test/__file_snapshots__/esm--Array.flatMap-0 b/test/__file_snapshots__/babel-esm---ES--Array.flatMap-0 similarity index 100% rename from test/__file_snapshots__/esm--Array.flatMap-0 rename to test/__file_snapshots__/babel-esm---ES--Array.flatMap-0 diff --git a/test/__file_snapshots__/esm--Object.entries-0 b/test/__file_snapshots__/babel-esm---ES--Object.entries-0 similarity index 100% rename from test/__file_snapshots__/esm--Object.entries-0 rename to test/__file_snapshots__/babel-esm---ES--Object.entries-0 diff --git a/test/__file_snapshots__/esm--Promise.allSettled-0 b/test/__file_snapshots__/babel-esm---ES--Promise.allSettled-0 similarity index 100% rename from test/__file_snapshots__/esm--Promise.allSettled-0 rename to test/__file_snapshots__/babel-esm---ES--Promise.allSettled-0 diff --git a/test/__file_snapshots__/esm--Runtime-ponyfills-0 b/test/__file_snapshots__/babel-esm---ES--Runtime-ponyfills-0 similarity index 100% rename from test/__file_snapshots__/esm--Runtime-ponyfills-0 rename to test/__file_snapshots__/babel-esm---ES--Runtime-ponyfills-0 diff --git a/test/__file_snapshots__/esm--async-await-0 b/test/__file_snapshots__/babel-esm---ES--async-await-0 similarity index 100% rename from test/__file_snapshots__/esm--async-await-0 rename to test/__file_snapshots__/babel-esm---ES--async-await-0 diff --git a/test/__file_snapshots__/esm--class-properties-0 b/test/__file_snapshots__/babel-esm---ES--class-properties-0 similarity index 100% rename from test/__file_snapshots__/esm--class-properties-0 rename to test/__file_snapshots__/babel-esm---ES--class-properties-0 diff --git a/test/__file_snapshots__/esm--dynamic-imports-0 b/test/__file_snapshots__/babel-esm---ES--dynamic-imports-0 similarity index 100% rename from test/__file_snapshots__/esm--dynamic-imports-0 rename to test/__file_snapshots__/babel-esm---ES--dynamic-imports-0 diff --git a/test/__file_snapshots__/esm--nullish-coalescing-0 b/test/__file_snapshots__/babel-esm---ES--nullish-coalescing-0 similarity index 100% rename from test/__file_snapshots__/esm--nullish-coalescing-0 rename to test/__file_snapshots__/babel-esm---ES--nullish-coalescing-0 diff --git a/test/__file_snapshots__/esm--object-rest-spread-0 b/test/__file_snapshots__/babel-esm---ES--object-rest-spread-0 similarity index 100% rename from test/__file_snapshots__/esm--object-rest-spread-0 rename to test/__file_snapshots__/babel-esm---ES--object-rest-spread-0 diff --git a/test/__file_snapshots__/babel-esm---ES--optional-chaining-0 b/test/__file_snapshots__/babel-esm---ES--optional-chaining-0 new file mode 100644 index 0000000..36499ca --- /dev/null +++ b/test/__file_snapshots__/babel-esm---ES--optional-chaining-0 @@ -0,0 +1,10 @@ +let obj = { + foo: { + bar: { + baz: 42 + } + } +}; +let baz = obj?.foo?.bar?.baz; // 42 + +let safe = obj?.qux?.baz; // undefined \ No newline at end of file diff --git a/test/__file_snapshots__/esm--static-class-properties-0 b/test/__file_snapshots__/babel-esm---ES--static-class-properties-0 similarity index 100% rename from test/__file_snapshots__/esm--static-class-properties-0 rename to test/__file_snapshots__/babel-esm---ES--static-class-properties-0 diff --git a/test/__file_snapshots__/esm--flow-0 b/test/__file_snapshots__/babel-esm---Flow--Types-0 similarity index 100% rename from test/__file_snapshots__/esm--flow-0 rename to test/__file_snapshots__/babel-esm---Flow--Types-0 diff --git a/test/__file_snapshots__/esm--React-class-component-0 b/test/__file_snapshots__/babel-esm---React--class-component-0 similarity index 100% rename from test/__file_snapshots__/esm--React-class-component-0 rename to test/__file_snapshots__/babel-esm---React--class-component-0 diff --git a/test/__file_snapshots__/esm--React-function-component-0 b/test/__file_snapshots__/babel-esm---React--function-component-0 similarity index 100% rename from test/__file_snapshots__/esm--React-function-component-0 rename to test/__file_snapshots__/babel-esm---React--function-component-0 diff --git a/test/__file_snapshots__/esm--jsx-0 b/test/__file_snapshots__/babel-esm---React--jsx-0 similarity index 100% rename from test/__file_snapshots__/esm--jsx-0 rename to test/__file_snapshots__/babel-esm---React--jsx-0 diff --git a/test/__file_snapshots__/esm--jsx-spread-0 b/test/__file_snapshots__/babel-esm---React--jsx-spread-0 similarity index 100% rename from test/__file_snapshots__/esm--jsx-spread-0 rename to test/__file_snapshots__/babel-esm---React--jsx-spread-0 diff --git a/test/__file_snapshots__/esm--Regression--Flow-void-class-properties-0 b/test/__file_snapshots__/babel-esm---Regression--Flow-void-class-properties-0 similarity index 100% rename from test/__file_snapshots__/esm--Regression--Flow-void-class-properties-0 rename to test/__file_snapshots__/babel-esm---Regression--Flow-void-class-properties-0 diff --git a/test/__file_snapshots__/babel-esm---Regression--Webpack-magic-comments-0 b/test/__file_snapshots__/babel-esm---Regression--Webpack-magic-comments-0 new file mode 100644 index 0000000..c48b052 --- /dev/null +++ b/test/__file_snapshots__/babel-esm---Regression--Webpack-magic-comments-0 @@ -0,0 +1 @@ +import( /* webpackChunkName: foo */'bar'); \ No newline at end of file diff --git a/test/__file_snapshots__/babel-esm---Regression--react-docgen-comments-0 b/test/__file_snapshots__/babel-esm---Regression--react-docgen-comments-0 new file mode 100644 index 0000000..5a57e1e --- /dev/null +++ b/test/__file_snapshots__/babel-esm---Regression--react-docgen-comments-0 @@ -0,0 +1,2 @@ +/** @component */ +function Foo() {} \ No newline at end of file diff --git a/test/__file_snapshots__/node--Array.flatMap-0 b/test/__file_snapshots__/babel-node---ES--Array.flatMap-0 similarity index 100% rename from test/__file_snapshots__/node--Array.flatMap-0 rename to test/__file_snapshots__/babel-node---ES--Array.flatMap-0 diff --git a/test/__file_snapshots__/node--Object.entries-0 b/test/__file_snapshots__/babel-node---ES--Object.entries-0 similarity index 100% rename from test/__file_snapshots__/node--Object.entries-0 rename to test/__file_snapshots__/babel-node---ES--Object.entries-0 diff --git a/test/__file_snapshots__/node--Promise.allSettled-0 b/test/__file_snapshots__/babel-node---ES--Promise.allSettled-0 similarity index 100% rename from test/__file_snapshots__/node--Promise.allSettled-0 rename to test/__file_snapshots__/babel-node---ES--Promise.allSettled-0 diff --git a/test/__file_snapshots__/node--Runtime-ponyfills-0 b/test/__file_snapshots__/babel-node---ES--Runtime-ponyfills-0 similarity index 100% rename from test/__file_snapshots__/node--Runtime-ponyfills-0 rename to test/__file_snapshots__/babel-node---ES--Runtime-ponyfills-0 diff --git a/test/__file_snapshots__/node--async-await-0 b/test/__file_snapshots__/babel-node---ES--async-await-0 similarity index 100% rename from test/__file_snapshots__/node--async-await-0 rename to test/__file_snapshots__/babel-node---ES--async-await-0 diff --git a/test/__file_snapshots__/node--class-properties-0 b/test/__file_snapshots__/babel-node---ES--class-properties-0 similarity index 100% rename from test/__file_snapshots__/node--class-properties-0 rename to test/__file_snapshots__/babel-node---ES--class-properties-0 diff --git a/test/__file_snapshots__/node--dynamic-imports-0 b/test/__file_snapshots__/babel-node---ES--dynamic-imports-0 similarity index 100% rename from test/__file_snapshots__/node--dynamic-imports-0 rename to test/__file_snapshots__/babel-node---ES--dynamic-imports-0 diff --git a/test/__file_snapshots__/node--nullish-coalescing-0 b/test/__file_snapshots__/babel-node---ES--nullish-coalescing-0 similarity index 100% rename from test/__file_snapshots__/node--nullish-coalescing-0 rename to test/__file_snapshots__/babel-node---ES--nullish-coalescing-0 diff --git a/test/__file_snapshots__/node--object-rest-spread-0 b/test/__file_snapshots__/babel-node---ES--object-rest-spread-0 similarity index 100% rename from test/__file_snapshots__/node--object-rest-spread-0 rename to test/__file_snapshots__/babel-node---ES--object-rest-spread-0 diff --git a/test/__file_snapshots__/babel-node---ES--optional-chaining-0 b/test/__file_snapshots__/babel-node---ES--optional-chaining-0 new file mode 100644 index 0000000..15f72a2 --- /dev/null +++ b/test/__file_snapshots__/babel-node---ES--optional-chaining-0 @@ -0,0 +1,12 @@ +"use strict"; + +let obj = { + foo: { + bar: { + baz: 42 + } + } +}; +let baz = obj?.foo?.bar?.baz; // 42 + +let safe = obj?.qux?.baz; // undefined \ No newline at end of file diff --git a/test/__file_snapshots__/node--static-class-properties-0 b/test/__file_snapshots__/babel-node---ES--static-class-properties-0 similarity index 100% rename from test/__file_snapshots__/node--static-class-properties-0 rename to test/__file_snapshots__/babel-node---ES--static-class-properties-0 diff --git a/test/__file_snapshots__/node--flow-0 b/test/__file_snapshots__/babel-node---Flow--Types-0 similarity index 100% rename from test/__file_snapshots__/node--flow-0 rename to test/__file_snapshots__/babel-node---Flow--Types-0 diff --git a/test/__file_snapshots__/node--React-class-component-0 b/test/__file_snapshots__/babel-node---React--class-component-0 similarity index 100% rename from test/__file_snapshots__/node--React-class-component-0 rename to test/__file_snapshots__/babel-node---React--class-component-0 diff --git a/test/__file_snapshots__/node--React-function-component-0 b/test/__file_snapshots__/babel-node---React--function-component-0 similarity index 100% rename from test/__file_snapshots__/node--React-function-component-0 rename to test/__file_snapshots__/babel-node---React--function-component-0 diff --git a/test/__file_snapshots__/node--jsx-0 b/test/__file_snapshots__/babel-node---React--jsx-0 similarity index 100% rename from test/__file_snapshots__/node--jsx-0 rename to test/__file_snapshots__/babel-node---React--jsx-0 diff --git a/test/__file_snapshots__/node--jsx-spread-0 b/test/__file_snapshots__/babel-node---React--jsx-spread-0 similarity index 100% rename from test/__file_snapshots__/node--jsx-spread-0 rename to test/__file_snapshots__/babel-node---React--jsx-spread-0 diff --git a/test/__file_snapshots__/node--Regression--Flow-void-class-properties-0 b/test/__file_snapshots__/babel-node---Regression--Flow-void-class-properties-0 similarity index 100% rename from test/__file_snapshots__/node--Regression--Flow-void-class-properties-0 rename to test/__file_snapshots__/babel-node---Regression--Flow-void-class-properties-0 diff --git a/test/__file_snapshots__/babel-node---Regression--Webpack-magic-comments-0 b/test/__file_snapshots__/babel-node---Regression--Webpack-magic-comments-0 new file mode 100644 index 0000000..5efbc05 --- /dev/null +++ b/test/__file_snapshots__/babel-node---Regression--Webpack-magic-comments-0 @@ -0,0 +1,5 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default; +var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/interopRequireWildcard")); +Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require( /* webpackChunkName: foo */'bar'))); \ No newline at end of file diff --git a/test/__file_snapshots__/babel-node---Regression--react-docgen-comments-0 b/test/__file_snapshots__/babel-node---Regression--react-docgen-comments-0 new file mode 100644 index 0000000..934c616 --- /dev/null +++ b/test/__file_snapshots__/babel-node---Regression--react-docgen-comments-0 @@ -0,0 +1,4 @@ +"use strict"; + +/** @component */ +function Foo() {} \ No newline at end of file diff --git a/test/__file_snapshots__/esmodules--Flow-Conditional-Types-0 b/test/__file_snapshots__/esmodules--Flow-Conditional-Types-0 deleted file mode 100644 index 2923aee..0000000 --- a/test/__file_snapshots__/esmodules--Flow-Conditional-Types-0 +++ /dev/null @@ -1,2 +0,0 @@ -class Vehicle {} -class Car {} \ No newline at end of file diff --git a/test/__file_snapshots__/esmodules--Flow-Type-Guards-0 b/test/__file_snapshots__/esmodules--Flow-Type-Guards-0 deleted file mode 100644 index 27d3e2b..0000000 --- a/test/__file_snapshots__/esmodules--Flow-Type-Guards-0 +++ /dev/null @@ -1 +0,0 @@ -function foo(node) {} \ No newline at end of file diff --git a/test/__file_snapshots__/esmodules--optional-chaining-0 b/test/__file_snapshots__/esmodules--optional-chaining-0 deleted file mode 100644 index ae802b4..0000000 --- a/test/__file_snapshots__/esmodules--optional-chaining-0 +++ /dev/null @@ -1,9 +0,0 @@ -let obj = { - foo: { - bar: { - baz: 42 - } - } -}; -let baz = obj?.foo?.bar?.baz; -let safe = obj?.qux?.baz; \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--Array.flatMap-0 b/test/__file_snapshots__/hermes-cjsm---ES--Array.flatMap-0 new file mode 100644 index 0000000..28704f9 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--Array.flatMap-0 @@ -0,0 +1,3 @@ +"use strict"; + +[1, 2].flatMap(x => [x * 2]); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--Object.entries-0 b/test/__file_snapshots__/hermes-cjsm---ES--Object.entries-0 new file mode 100644 index 0000000..6b918f8 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--Object.entries-0 @@ -0,0 +1,5 @@ +"use strict"; + +Object.entries({ + a: 1 +}); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--Promise.allSettled-0 b/test/__file_snapshots__/hermes-cjsm---ES--Promise.allSettled-0 new file mode 100644 index 0000000..53523ce --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--Promise.allSettled-0 @@ -0,0 +1,3 @@ +"use strict"; + +Promise.allSettled([Promise.resolve(1), Promise.resolve(2)]).then(rs => rs.forEach(r => console.log(r.status))); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--Runtime-ponyfills-0 b/test/__file_snapshots__/hermes-cjsm---ES--Runtime-ponyfills-0 new file mode 100644 index 0000000..702793a --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--Runtime-ponyfills-0 @@ -0,0 +1,5 @@ +"use strict"; + +new Map(); +new Set(); +new Promise(); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--async-await-0 b/test/__file_snapshots__/hermes-cjsm---ES--async-await-0 new file mode 100644 index 0000000..1441db4 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--async-await-0 @@ -0,0 +1,5 @@ +"use strict"; + +(async function () { + await foo(); +})(); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--class-properties-0 b/test/__file_snapshots__/hermes-cjsm---ES--class-properties-0 new file mode 100644 index 0000000..5b37c3f --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--class-properties-0 @@ -0,0 +1,5 @@ +"use strict"; + +class A { + a = () => 'hello'; +} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--dynamic-imports-0 b/test/__file_snapshots__/hermes-cjsm---ES--dynamic-imports-0 new file mode 100644 index 0000000..31eafbf --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--dynamic-imports-0 @@ -0,0 +1,5 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default; +var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/interopRequireWildcard")); +Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('./a'))); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--nullish-coalescing-0 b/test/__file_snapshots__/hermes-cjsm---ES--nullish-coalescing-0 new file mode 100644 index 0000000..f038f1a --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--nullish-coalescing-0 @@ -0,0 +1,4 @@ +"use strict"; + +let obj = {}; +let foo = obj.foo ?? 'default'; \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---ES--object-rest-spread-0 b/test/__file_snapshots__/hermes-cjsm---ES--object-rest-spread-0 new file mode 100644 index 0000000..804b456 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--object-rest-spread-0 @@ -0,0 +1,5 @@ +"use strict"; + +let b = { + ...a +}; \ No newline at end of file diff --git a/test/__file_snapshots__/cjsm--optional-chaining-0 b/test/__file_snapshots__/hermes-cjsm---ES--optional-chaining-0 similarity index 100% rename from test/__file_snapshots__/cjsm--optional-chaining-0 rename to test/__file_snapshots__/hermes-cjsm---ES--optional-chaining-0 diff --git a/test/__file_snapshots__/hermes-cjsm---ES--static-class-properties-0 b/test/__file_snapshots__/hermes-cjsm---ES--static-class-properties-0 new file mode 100644 index 0000000..3b35c7b --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---ES--static-class-properties-0 @@ -0,0 +1,5 @@ +"use strict"; + +class A { + static a = 'hello'; +} \ No newline at end of file diff --git a/test/__file_snapshots__/cjsm--Flow-Conditional-Types-0 b/test/__file_snapshots__/hermes-cjsm---Flow--Conditional-Types-0 similarity index 100% rename from test/__file_snapshots__/cjsm--Flow-Conditional-Types-0 rename to test/__file_snapshots__/hermes-cjsm---Flow--Conditional-Types-0 diff --git a/test/__file_snapshots__/hermes-cjsm---Flow--Mapped-Types-0 b/test/__file_snapshots__/hermes-cjsm---Flow--Mapped-Types-0 new file mode 100644 index 0000000..9a390c3 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---Flow--Mapped-Types-0 @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---Flow--Type-Casting-0 b/test/__file_snapshots__/hermes-cjsm---Flow--Type-Casting-0 new file mode 100644 index 0000000..133c211 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---Flow--Type-Casting-0 @@ -0,0 +1,7 @@ +"use strict"; + +let val = value; +let obj = { + prop: value +}; +let arr = [value, value]; \ No newline at end of file diff --git a/test/__file_snapshots__/cjsm--Flow-Type-Guards-0 b/test/__file_snapshots__/hermes-cjsm---Flow--Type-Guards-0 similarity index 100% rename from test/__file_snapshots__/cjsm--Flow-Type-Guards-0 rename to test/__file_snapshots__/hermes-cjsm---Flow--Type-Guards-0 diff --git a/test/__file_snapshots__/hermes-cjsm---Flow--Types-0 b/test/__file_snapshots__/hermes-cjsm---Flow--Types-0 new file mode 100644 index 0000000..d26d019 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---Flow--Types-0 @@ -0,0 +1,3 @@ +"use strict"; + +let a = 'hello'; \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---React--class-component-0 b/test/__file_snapshots__/hermes-cjsm---React--class-component-0 new file mode 100644 index 0000000..d059f30 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---React--class-component-0 @@ -0,0 +1,23 @@ +"use strict"; + +var _react = require("react"); +var _jsxRuntime = require("react/jsx-runtime"); +class Button extends _react.Component { + handleClick = async evt => { + evt.preventDefault(); + await fetch('/foo'); + }; + render() { + const { + type = 'button', + children, + ...extraProps + } = this.props; + return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { + type: type, + onClick: this.handleClick, + ...extraProps, + children: children + }); + } +} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---React--function-component-0 b/test/__file_snapshots__/hermes-cjsm---React--function-component-0 new file mode 100644 index 0000000..999ce46 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---React--function-component-0 @@ -0,0 +1,14 @@ +"use strict"; + +var _jsxRuntime = require("react/jsx-runtime"); +function Button({ + type = 'button', + children, + ...extraProps +}) { + return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { + type: type, + ...extraProps, + children: children + }); +} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---React--jsx-0 b/test/__file_snapshots__/hermes-cjsm---React--jsx-0 new file mode 100644 index 0000000..326c48d --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---React--jsx-0 @@ -0,0 +1,6 @@ +"use strict"; + +var _jsxRuntime = require("react/jsx-runtime"); +let A = () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { + children: "hello" +}); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---React--jsx-spread-0 b/test/__file_snapshots__/hermes-cjsm---React--jsx-spread-0 new file mode 100644 index 0000000..2df9341 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---React--jsx-spread-0 @@ -0,0 +1,8 @@ +"use strict"; + +var _jsxRuntime = require("react/jsx-runtime"); +/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { + a: true, + ...b, + children: "hello" +}); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---Regression--Flow-void-class-properties-0 b/test/__file_snapshots__/hermes-cjsm---Regression--Flow-void-class-properties-0 new file mode 100644 index 0000000..d9c55f7 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---Regression--Flow-void-class-properties-0 @@ -0,0 +1,3 @@ +"use strict"; + +class C {} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---Regression--Webpack-magic-comments-0 b/test/__file_snapshots__/hermes-cjsm---Regression--Webpack-magic-comments-0 new file mode 100644 index 0000000..66cd87e --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---Regression--Webpack-magic-comments-0 @@ -0,0 +1,5 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default; +var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/interopRequireWildcard")); +Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('bar'))); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-cjsm---Regression--react-docgen-comments-0 b/test/__file_snapshots__/hermes-cjsm---Regression--react-docgen-comments-0 new file mode 100644 index 0000000..02cb984 --- /dev/null +++ b/test/__file_snapshots__/hermes-cjsm---Regression--react-docgen-comments-0 @@ -0,0 +1,3 @@ +"use strict"; + +function Foo() {} \ No newline at end of file diff --git a/test/__file_snapshots__/esmodules--Array.flatMap-0 b/test/__file_snapshots__/hermes-esm---ES--Array.flatMap-0 similarity index 100% rename from test/__file_snapshots__/esmodules--Array.flatMap-0 rename to test/__file_snapshots__/hermes-esm---ES--Array.flatMap-0 diff --git a/test/__file_snapshots__/esmodules--Object.entries-0 b/test/__file_snapshots__/hermes-esm---ES--Object.entries-0 similarity index 100% rename from test/__file_snapshots__/esmodules--Object.entries-0 rename to test/__file_snapshots__/hermes-esm---ES--Object.entries-0 diff --git a/test/__file_snapshots__/esmodules--Promise.allSettled-0 b/test/__file_snapshots__/hermes-esm---ES--Promise.allSettled-0 similarity index 100% rename from test/__file_snapshots__/esmodules--Promise.allSettled-0 rename to test/__file_snapshots__/hermes-esm---ES--Promise.allSettled-0 diff --git a/test/__file_snapshots__/esmodules--Runtime-ponyfills-0 b/test/__file_snapshots__/hermes-esm---ES--Runtime-ponyfills-0 similarity index 100% rename from test/__file_snapshots__/esmodules--Runtime-ponyfills-0 rename to test/__file_snapshots__/hermes-esm---ES--Runtime-ponyfills-0 diff --git a/test/__file_snapshots__/esmodules--async-await-0 b/test/__file_snapshots__/hermes-esm---ES--async-await-0 similarity index 100% rename from test/__file_snapshots__/esmodules--async-await-0 rename to test/__file_snapshots__/hermes-esm---ES--async-await-0 diff --git a/test/__file_snapshots__/esmodules--class-properties-0 b/test/__file_snapshots__/hermes-esm---ES--class-properties-0 similarity index 100% rename from test/__file_snapshots__/esmodules--class-properties-0 rename to test/__file_snapshots__/hermes-esm---ES--class-properties-0 diff --git a/test/__file_snapshots__/esmodules--dynamic-imports-0 b/test/__file_snapshots__/hermes-esm---ES--dynamic-imports-0 similarity index 100% rename from test/__file_snapshots__/esmodules--dynamic-imports-0 rename to test/__file_snapshots__/hermes-esm---ES--dynamic-imports-0 diff --git a/test/__file_snapshots__/esmodules--nullish-coalescing-0 b/test/__file_snapshots__/hermes-esm---ES--nullish-coalescing-0 similarity index 100% rename from test/__file_snapshots__/esmodules--nullish-coalescing-0 rename to test/__file_snapshots__/hermes-esm---ES--nullish-coalescing-0 diff --git a/test/__file_snapshots__/esmodules--object-rest-spread-0 b/test/__file_snapshots__/hermes-esm---ES--object-rest-spread-0 similarity index 100% rename from test/__file_snapshots__/esmodules--object-rest-spread-0 rename to test/__file_snapshots__/hermes-esm---ES--object-rest-spread-0 diff --git a/test/__file_snapshots__/esm--optional-chaining-0 b/test/__file_snapshots__/hermes-esm---ES--optional-chaining-0 similarity index 100% rename from test/__file_snapshots__/esm--optional-chaining-0 rename to test/__file_snapshots__/hermes-esm---ES--optional-chaining-0 diff --git a/test/__file_snapshots__/esmodules--static-class-properties-0 b/test/__file_snapshots__/hermes-esm---ES--static-class-properties-0 similarity index 100% rename from test/__file_snapshots__/esmodules--static-class-properties-0 rename to test/__file_snapshots__/hermes-esm---ES--static-class-properties-0 diff --git a/test/__file_snapshots__/esm--Flow-Conditional-Types-0 b/test/__file_snapshots__/hermes-esm---Flow--Conditional-Types-0 similarity index 100% rename from test/__file_snapshots__/esm--Flow-Conditional-Types-0 rename to test/__file_snapshots__/hermes-esm---Flow--Conditional-Types-0 diff --git a/test/__file_snapshots__/hermes-esm---Flow--Mapped-Types-0 b/test/__file_snapshots__/hermes-esm---Flow--Mapped-Types-0 new file mode 100644 index 0000000..e69de29 diff --git a/test/__file_snapshots__/hermes-esm---Flow--Type-Casting-0 b/test/__file_snapshots__/hermes-esm---Flow--Type-Casting-0 new file mode 100644 index 0000000..b33e5a7 --- /dev/null +++ b/test/__file_snapshots__/hermes-esm---Flow--Type-Casting-0 @@ -0,0 +1,5 @@ +let val = value; +let obj = { + prop: value +}; +let arr = [value, value]; \ No newline at end of file diff --git a/test/__file_snapshots__/esm--Flow-Type-Guards-0 b/test/__file_snapshots__/hermes-esm---Flow--Type-Guards-0 similarity index 100% rename from test/__file_snapshots__/esm--Flow-Type-Guards-0 rename to test/__file_snapshots__/hermes-esm---Flow--Type-Guards-0 diff --git a/test/__file_snapshots__/esmodules--flow-0 b/test/__file_snapshots__/hermes-esm---Flow--Types-0 similarity index 100% rename from test/__file_snapshots__/esmodules--flow-0 rename to test/__file_snapshots__/hermes-esm---Flow--Types-0 diff --git a/test/__file_snapshots__/esmodules--React-class-component-0 b/test/__file_snapshots__/hermes-esm---React--class-component-0 similarity index 100% rename from test/__file_snapshots__/esmodules--React-class-component-0 rename to test/__file_snapshots__/hermes-esm---React--class-component-0 diff --git a/test/__file_snapshots__/esmodules--React-function-component-0 b/test/__file_snapshots__/hermes-esm---React--function-component-0 similarity index 100% rename from test/__file_snapshots__/esmodules--React-function-component-0 rename to test/__file_snapshots__/hermes-esm---React--function-component-0 diff --git a/test/__file_snapshots__/esmodules--jsx-0 b/test/__file_snapshots__/hermes-esm---React--jsx-0 similarity index 100% rename from test/__file_snapshots__/esmodules--jsx-0 rename to test/__file_snapshots__/hermes-esm---React--jsx-0 diff --git a/test/__file_snapshots__/esmodules--jsx-spread-0 b/test/__file_snapshots__/hermes-esm---React--jsx-spread-0 similarity index 100% rename from test/__file_snapshots__/esmodules--jsx-spread-0 rename to test/__file_snapshots__/hermes-esm---React--jsx-spread-0 diff --git a/test/__file_snapshots__/esmodules--Regression--Flow-void-class-properties-0 b/test/__file_snapshots__/hermes-esm---Regression--Flow-void-class-properties-0 similarity index 100% rename from test/__file_snapshots__/esmodules--Regression--Flow-void-class-properties-0 rename to test/__file_snapshots__/hermes-esm---Regression--Flow-void-class-properties-0 diff --git a/test/__file_snapshots__/hermes-esm---Regression--Webpack-magic-comments-0 b/test/__file_snapshots__/hermes-esm---Regression--Webpack-magic-comments-0 new file mode 100644 index 0000000..603181a --- /dev/null +++ b/test/__file_snapshots__/hermes-esm---Regression--Webpack-magic-comments-0 @@ -0,0 +1 @@ +import('bar'); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-esm---Regression--react-docgen-comments-0 b/test/__file_snapshots__/hermes-esm---Regression--react-docgen-comments-0 new file mode 100644 index 0000000..e49bbd7 --- /dev/null +++ b/test/__file_snapshots__/hermes-esm---Regression--react-docgen-comments-0 @@ -0,0 +1 @@ +function Foo() {} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--Array.flatMap-0 b/test/__file_snapshots__/hermes-node---ES--Array.flatMap-0 new file mode 100644 index 0000000..28704f9 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--Array.flatMap-0 @@ -0,0 +1,3 @@ +"use strict"; + +[1, 2].flatMap(x => [x * 2]); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--Object.entries-0 b/test/__file_snapshots__/hermes-node---ES--Object.entries-0 new file mode 100644 index 0000000..6b918f8 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--Object.entries-0 @@ -0,0 +1,5 @@ +"use strict"; + +Object.entries({ + a: 1 +}); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--Promise.allSettled-0 b/test/__file_snapshots__/hermes-node---ES--Promise.allSettled-0 new file mode 100644 index 0000000..53523ce --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--Promise.allSettled-0 @@ -0,0 +1,3 @@ +"use strict"; + +Promise.allSettled([Promise.resolve(1), Promise.resolve(2)]).then(rs => rs.forEach(r => console.log(r.status))); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--Runtime-ponyfills-0 b/test/__file_snapshots__/hermes-node---ES--Runtime-ponyfills-0 new file mode 100644 index 0000000..702793a --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--Runtime-ponyfills-0 @@ -0,0 +1,5 @@ +"use strict"; + +new Map(); +new Set(); +new Promise(); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--async-await-0 b/test/__file_snapshots__/hermes-node---ES--async-await-0 new file mode 100644 index 0000000..1441db4 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--async-await-0 @@ -0,0 +1,5 @@ +"use strict"; + +(async function () { + await foo(); +})(); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--class-properties-0 b/test/__file_snapshots__/hermes-node---ES--class-properties-0 new file mode 100644 index 0000000..5b37c3f --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--class-properties-0 @@ -0,0 +1,5 @@ +"use strict"; + +class A { + a = () => 'hello'; +} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--dynamic-imports-0 b/test/__file_snapshots__/hermes-node---ES--dynamic-imports-0 new file mode 100644 index 0000000..31eafbf --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--dynamic-imports-0 @@ -0,0 +1,5 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default; +var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/interopRequireWildcard")); +Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('./a'))); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--nullish-coalescing-0 b/test/__file_snapshots__/hermes-node---ES--nullish-coalescing-0 new file mode 100644 index 0000000..f038f1a --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--nullish-coalescing-0 @@ -0,0 +1,4 @@ +"use strict"; + +let obj = {}; +let foo = obj.foo ?? 'default'; \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---ES--object-rest-spread-0 b/test/__file_snapshots__/hermes-node---ES--object-rest-spread-0 new file mode 100644 index 0000000..804b456 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--object-rest-spread-0 @@ -0,0 +1,5 @@ +"use strict"; + +let b = { + ...a +}; \ No newline at end of file diff --git a/test/__file_snapshots__/node--optional-chaining-0 b/test/__file_snapshots__/hermes-node---ES--optional-chaining-0 similarity index 100% rename from test/__file_snapshots__/node--optional-chaining-0 rename to test/__file_snapshots__/hermes-node---ES--optional-chaining-0 diff --git a/test/__file_snapshots__/hermes-node---ES--static-class-properties-0 b/test/__file_snapshots__/hermes-node---ES--static-class-properties-0 new file mode 100644 index 0000000..3b35c7b --- /dev/null +++ b/test/__file_snapshots__/hermes-node---ES--static-class-properties-0 @@ -0,0 +1,5 @@ +"use strict"; + +class A { + static a = 'hello'; +} \ No newline at end of file diff --git a/test/__file_snapshots__/node--Flow-Conditional-Types-0 b/test/__file_snapshots__/hermes-node---Flow--Conditional-Types-0 similarity index 100% rename from test/__file_snapshots__/node--Flow-Conditional-Types-0 rename to test/__file_snapshots__/hermes-node---Flow--Conditional-Types-0 diff --git a/test/__file_snapshots__/hermes-node---Flow--Mapped-Types-0 b/test/__file_snapshots__/hermes-node---Flow--Mapped-Types-0 new file mode 100644 index 0000000..9a390c3 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---Flow--Mapped-Types-0 @@ -0,0 +1 @@ +"use strict"; \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---Flow--Type-Casting-0 b/test/__file_snapshots__/hermes-node---Flow--Type-Casting-0 new file mode 100644 index 0000000..133c211 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---Flow--Type-Casting-0 @@ -0,0 +1,7 @@ +"use strict"; + +let val = value; +let obj = { + prop: value +}; +let arr = [value, value]; \ No newline at end of file diff --git a/test/__file_snapshots__/node--Flow-Type-Guards-0 b/test/__file_snapshots__/hermes-node---Flow--Type-Guards-0 similarity index 100% rename from test/__file_snapshots__/node--Flow-Type-Guards-0 rename to test/__file_snapshots__/hermes-node---Flow--Type-Guards-0 diff --git a/test/__file_snapshots__/hermes-node---Flow--Types-0 b/test/__file_snapshots__/hermes-node---Flow--Types-0 new file mode 100644 index 0000000..d26d019 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---Flow--Types-0 @@ -0,0 +1,3 @@ +"use strict"; + +let a = 'hello'; \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---React--class-component-0 b/test/__file_snapshots__/hermes-node---React--class-component-0 new file mode 100644 index 0000000..d059f30 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---React--class-component-0 @@ -0,0 +1,23 @@ +"use strict"; + +var _react = require("react"); +var _jsxRuntime = require("react/jsx-runtime"); +class Button extends _react.Component { + handleClick = async evt => { + evt.preventDefault(); + await fetch('/foo'); + }; + render() { + const { + type = 'button', + children, + ...extraProps + } = this.props; + return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { + type: type, + onClick: this.handleClick, + ...extraProps, + children: children + }); + } +} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---React--function-component-0 b/test/__file_snapshots__/hermes-node---React--function-component-0 new file mode 100644 index 0000000..999ce46 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---React--function-component-0 @@ -0,0 +1,14 @@ +"use strict"; + +var _jsxRuntime = require("react/jsx-runtime"); +function Button({ + type = 'button', + children, + ...extraProps +}) { + return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", { + type: type, + ...extraProps, + children: children + }); +} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---React--jsx-0 b/test/__file_snapshots__/hermes-node---React--jsx-0 new file mode 100644 index 0000000..326c48d --- /dev/null +++ b/test/__file_snapshots__/hermes-node---React--jsx-0 @@ -0,0 +1,6 @@ +"use strict"; + +var _jsxRuntime = require("react/jsx-runtime"); +let A = () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { + children: "hello" +}); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---React--jsx-spread-0 b/test/__file_snapshots__/hermes-node---React--jsx-spread-0 new file mode 100644 index 0000000..2df9341 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---React--jsx-spread-0 @@ -0,0 +1,8 @@ +"use strict"; + +var _jsxRuntime = require("react/jsx-runtime"); +/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { + a: true, + ...b, + children: "hello" +}); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---Regression--Flow-void-class-properties-0 b/test/__file_snapshots__/hermes-node---Regression--Flow-void-class-properties-0 new file mode 100644 index 0000000..d9c55f7 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---Regression--Flow-void-class-properties-0 @@ -0,0 +1,3 @@ +"use strict"; + +class C {} \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---Regression--Webpack-magic-comments-0 b/test/__file_snapshots__/hermes-node---Regression--Webpack-magic-comments-0 new file mode 100644 index 0000000..66cd87e --- /dev/null +++ b/test/__file_snapshots__/hermes-node---Regression--Webpack-magic-comments-0 @@ -0,0 +1,5 @@ +"use strict"; + +var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default; +var _interopRequireWildcard2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/interopRequireWildcard")); +Promise.resolve().then(() => (0, _interopRequireWildcard2.default)(require('bar'))); \ No newline at end of file diff --git a/test/__file_snapshots__/hermes-node---Regression--react-docgen-comments-0 b/test/__file_snapshots__/hermes-node---Regression--react-docgen-comments-0 new file mode 100644 index 0000000..02cb984 --- /dev/null +++ b/test/__file_snapshots__/hermes-node---Regression--react-docgen-comments-0 @@ -0,0 +1,3 @@ +"use strict"; + +function Foo() {} \ No newline at end of file diff --git a/test/babel.spec.js b/test/babel.spec.js new file mode 100644 index 0000000..7c51d7c --- /dev/null +++ b/test/babel.spec.js @@ -0,0 +1,40 @@ +const { transform } = require('@babel/core'); +const { toMatchFile } = require('jest-file-snapshot'); + +const preset = require('../'); + +const es = require('./fixtures/es'); +const flow = require('./fixtures/flow'); +const react = require('./fixtures/react'); +const regressions = require('./fixtures/regressions'); + +let cases = [...es, ...flow, ...react, ...regressions]; + +expect.extend({ toMatchFile }); + +describe('babel', () => { + test.each(cases)('cjsm > %s', (name, input) => { + let { code } = transform(input, { + presets: [preset], + }); + + expect(code).toMatchFile(); + }); + + test.each(cases)('esm > %s', (name, input) => { + let { code } = transform(input, { + presets: [[preset, { modules: false }]], + }); + + expect(code).toMatchFile(); + }); + + test.each(cases)('node > %s', (name, input) => { + let { code } = transform(input, { + targets: { node: 22 }, + presets: [preset], + }); + + expect(code).toMatchFile(); + }); +}); diff --git a/test/fixtures/es.js b/test/fixtures/es.js new file mode 100644 index 0000000..f1b5622 --- /dev/null +++ b/test/fixtures/es.js @@ -0,0 +1,89 @@ +module.exports = [ + [ + 'ES: object rest spread', + ` + let b = {...a} + `, + ], + [ + 'ES: class properties', + ` + class A { a = () => 'hello' } + `, + ], + [ + 'ES: static class properties', + ` + class A { static a = 'hello' } + `, + ], + [ + 'ES: dynamic imports', + ` + import('./a') + `, + ], + [ + 'ES: optional chaining', + ` + let obj = { + foo: { + bar: { + baz: 42, + }, + }, + }; + + let baz = obj?.foo?.bar?.baz; // 42 + + let safe = obj?.qux?.baz; // undefined + `, + ], + [ + 'ES: nullish coalescing', + ` + let obj = {}; + + let foo = obj.foo ?? 'default'; + `, + ], + [ + 'ES: async await', + ` + (async function() { + await foo(); + }()); + `, + ], + [ + 'ES: Runtime ponyfills', + ` + new Map() + new Set() + new Promise() + `, + ], + + [ + 'ES: Promise.allSettled', + ` + Promise.allSettled([ + Promise.resolve(1), + Promise.resolve(2), + ]) + .then((rs) => rs.forEach((r) => console.log(r.status))); + `, + ], + [ + 'ES: Object.entries', + ` + Object.entries({ a: 1 }); + `, + ], + [ + 'ES: Array.flatMap', + ` + [1, 2].flatMap(x => [x * 2]) + `, + ], +]; diff --git a/test/fixtures/flow-syntax.js b/test/fixtures/flow-syntax.js new file mode 100644 index 0000000..bc27e0f --- /dev/null +++ b/test/fixtures/flow-syntax.js @@ -0,0 +1,31 @@ +module.exports = [ + [ + 'Flow: Type Guards', + ` + function foo(node: any): node is Node {} + `, + ], + [ + 'Flow: Conditional Types', + ` + class Vehicle {} + class Car {} + type Test = Car extends Vehicle ? 'yep' : 'nope' + `, + ], + [ + 'Flow: Type Casting', + ` + let val = value as Type + let obj = { prop: value as Type } + let arr = [value as Type, value as Type] as Array + `, + ], + [ + 'Flow: Mapped Types', + ` + type Union = 'foo' | 'bar' | 'baz' + type MappedType = {[key in Union]: number} + `, + ], +]; diff --git a/test/fixtures/flow.js b/test/fixtures/flow.js new file mode 100644 index 0000000..f15950a --- /dev/null +++ b/test/fixtures/flow.js @@ -0,0 +1,10 @@ +module.exports = [ + [ + 'Flow: Types', + ` + // @flow + type A = string + let a: A = 'hello' + `, + ], +]; diff --git a/test/fixtures/react.js b/test/fixtures/react.js new file mode 100644 index 0000000..e2b3586 --- /dev/null +++ b/test/fixtures/react.js @@ -0,0 +1,50 @@ +module.exports = [ + [ + 'React: jsx', + ` + let A = () =>
hello
+ `, + ], + [ + 'React: jsx spread', + ` +
hello
+ `, + ], + + [ + 'React: function component', + ` + function Button({ type = 'button', children, ...extraProps }) { + return ( + + ); + } + `, + ], + [ + 'React: class component', + ` + import { Component } from 'react'; + + class Button extends Component { + handleClick = async (evt) => { + evt.preventDefault(); + await fetch('/foo'); + } + + render() { + const { type = 'button', children, ...extraProps } = this.props; + + return ( + + ); + } + } + `, + ], +]; diff --git a/test/fixtures/regressions.js b/test/fixtures/regressions.js new file mode 100644 index 0000000..2e4f027 --- /dev/null +++ b/test/fixtures/regressions.js @@ -0,0 +1,25 @@ +module.exports = [ + [ + 'Regression: Flow void class properties', + ` + // @flow + type Props = {} + class C { + props: Props + } + `, + ], + [ + 'Regression: Webpack magic comments', + ` + import(/* webpackChunkName: foo */'bar') + `, + ], + [ + 'Regression: react-docgen comments', + ` + /** @component */ + function Foo() {} + `, + ], +]; diff --git a/test/hermes.spec.js b/test/hermes.spec.js new file mode 100644 index 0000000..d2ebe43 --- /dev/null +++ b/test/hermes.spec.js @@ -0,0 +1,41 @@ +const { transform } = require('@babel/core'); +const { toMatchFile } = require('jest-file-snapshot'); + +const preset = require('../'); + +const es = require('./fixtures/es'); +const flow = require('./fixtures/flow'); +const syntax = require('./fixtures/flow-syntax'); +const react = require('./fixtures/react'); +const regressions = require('./fixtures/regressions'); + +let cases = [...es, ...flow, ...syntax, ...react, ...regressions]; + +expect.extend({ toMatchFile }); + +describe('hermes', () => { + test.each(cases)('cjsm > %s', (name, input) => { + let { code } = transform(input, { + presets: [[preset, { parser: 'hermes' }]], + }); + + expect(code).toMatchFile(); + }); + + test.each(cases)('esm > %s', (name, input) => { + let { code } = transform(input, { + presets: [[preset, { parser: 'hermes', modules: false }]], + }); + + expect(code).toMatchFile(); + }); + + test.each(cases)('node > %s', (name, input) => { + let { code } = transform(input, { + targets: { node: 22 }, + presets: [[preset, { parser: 'hermes' }]], + }); + + expect(code).toMatchFile(); + }); +}); diff --git a/test/index.spec.js b/test/index.spec.js deleted file mode 100644 index 3eeb411..0000000 --- a/test/index.spec.js +++ /dev/null @@ -1,231 +0,0 @@ -const { transform } = require('@babel/core'); -const { toMatchFile } = require('jest-file-snapshot'); -const browserslist = require('browserslist'); - -const preset = require('../'); - -expect.extend({ toMatchFile }); - -let cases = [ - [ - 'flow', - ` - // @flow - type A = string - let a: A = 'hello' - `, - ], - [ - 'jsx', - ` - let A = () =>
hello
- `, - ], - [ - 'jsx spread', - ` -
hello
- `, - ], - [ - 'object rest spread', - ` - let b = {...a} - `, - ], - [ - 'class properties', - ` - class A { a = () => 'hello' } - `, - ], - [ - 'static class properties', - ` - class A { static a = 'hello' } - `, - ], - [ - 'dynamic imports', - ` - import('./a') - `, - ], - [ - 'optional chaining', - ` - let obj = { - foo: { - bar: { - baz: 42, - }, - }, - }; - - let baz = obj?.foo?.bar?.baz; // 42 - - let safe = obj?.qux?.baz; // undefined - `, - ], - [ - 'nullish coalescing', - ` - let obj = {}; - - let foo = obj.foo ?? 'default'; - `, - ], - [ - 'async await', - ` - (async function() { - await foo(); - }()); - `, - ], - [ - 'Runtime ponyfills', - ` - new Map() - new Set() - new Promise() - `, - ], - [ - 'Regression: Flow void class properties', - ` - // @flow - type Props = {} - class C { - props: Props - } - `, - ], - [ - 'React function component', - ` - function Button({ type = 'button', children, ...extraProps }) { - return ( - - ); - } - `, - ], - [ - 'React class component', - ` - import { Component } from 'react'; - - class Button extends Component { - handleClick = async (evt) => { - evt.preventDefault(); - await fetch('/foo'); - } - - render() { - const { type = 'button', children, ...extraProps } = this.props; - - return ( - - ); - } - } - `, - ], - [ - 'Promise.allSettled', - ` - Promise.allSettled([ - Promise.resolve(1), - Promise.resolve(2), - ]) - .then((rs) => rs.forEach((r) => console.log(r.status))); - `, - ], - [ - 'Object.entries', - ` - Object.entries({ a: 1 }); - `, - ], - [ - 'Array.flatMap', - ` - [1, 2].flatMap(x => [x * 2]) - `, - ], - [ - 'Flow Type Guards', - ` - function foo(node: any): node is Node {} - `, - ], - [ - 'Flow Conditional Types', - ` - class Vehicle {} - class Car {} - type Test = Car extends Vehicle ? 'yep' : 'nope' - `, - ], -]; - -test.each(cases)('cjsm: %s', (name, input) => { - let { code } = transform(input, { - targets: { browsers: 'defaults' }, - presets: [preset], - }); - - expect(code).toMatchFile(); -}); - -test.each(cases)('esm: %s', (name, input) => { - let { code } = transform(input, { - targets: { browsers: 'defaults' }, - presets: [[preset, { modules: false }]], - }); - - expect(code).toMatchFile(); -}); - -test.each(cases)('esmodules: %s', (name, input) => { - let { code } = transform(input, { - targets: { browsers: 'defaults', esmodules: true }, - presets: [[preset, { modules: false }]], - }); - - expect(code).toMatchFile(); -}); - -test.each(cases)('node: %s', (name, input) => { - let { code } = transform(input, { - targets: { node: 22 }, - presets: [preset], - }); - - expect(code).toMatchFile(); -}); - -test('targets', () => { - let { - options: { targets }, - } = transform('', { - targets: { browsers: 'defaults' }, - presets: [[preset, { modules: false }]], - }); - - let browsers = browserslist('defaults'); - - let result = [ - '// Babel targets', - JSON.stringify(targets, null, 2), - '// Browerslist targets', - JSON.stringify(browsers, null, 2), - ].join('\n'); - - expect(result).toMatchFile(); -}); diff --git a/test/targets.spec.js b/test/targets.spec.js new file mode 100644 index 0000000..b8fa8fc --- /dev/null +++ b/test/targets.spec.js @@ -0,0 +1,27 @@ +const { transform } = require('@babel/core'); +const { toMatchFile } = require('jest-file-snapshot'); +const browserslist = require('browserslist'); + +const preset = require('../'); + +expect.extend({ toMatchFile }); + +test('targets', () => { + let { + options: { targets }, + } = transform('', { + targets: { browsers: 'defaults' }, + presets: [[preset, { modules: false }]], + }); + + let browsers = browserslist('defaults'); + + let result = [ + '// Babel targets', + JSON.stringify(targets, null, 2), + '// Browerslist targets', + JSON.stringify(browsers, null, 2), + ].join('\n'); + + expect(result).toMatchFile(); +});