From d118affc05a54516fe97804163726749c0675c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Fri, 19 Feb 2021 14:32:53 +0900 Subject: [PATCH] feat(es/transforms/react): New jsx transform (#1408) swc_ecma_transforms_react: - Implement new jsx transform. (#1103, denoland/deno#7993) --- Cargo.toml | 6 +- bundler/Cargo.toml | 6 +- ecmascript/Cargo.toml | 4 +- ecmascript/preset_env/Cargo.toml | 4 +- ecmascript/transforms/Cargo.toml | 6 +- ecmascript/transforms/optimization/Cargo.toml | 4 +- ecmascript/transforms/react/Cargo.toml | 5 +- .../transforms/react/scripts/.gitignore | 1 + .../transforms/react/scripts/patch-options.sh | 4 + .../transforms/react/scripts/patch-options.ts | 57 ++ .../input.js | 10 + .../options.json | 1 + .../output.js | 12 + .../input.js | 10 + .../options.json | 1 + .../output.js | 13 + .../.complicated-scope-script/input.js | 15 + .../.complicated-scope-script/options.json | 1 + .../.complicated-scope-script/output.js | 25 + .../autoImport/after-polyfills-2/input.mjs | 11 + .../autoImport/after-polyfills-2/output.mjs | 9 + .../after-polyfills-compiled-to-cjs/input.mjs | 10 + .../options.json | 1 + .../after-polyfills-compiled-to-cjs/output.js | 16 + .../autoImport/after-polyfills/input.mjs | 10 + .../autoImport/after-polyfills/output.mjs | 8 + .../input.js | 10 + .../options.json | 1 + .../output.mjs | 13 + .../complicated-scope-module/input.js | 15 + .../complicated-scope-module/options.json | 1 + .../complicated-scope-module/output.mjs | 19 + .../autoImport/import-source-pragma/input.js | 2 + .../import-source-pragma/output.mjs | 6 + .../fixture/autoImport/import-source/input.js | 1 + .../autoImport/import-source/options.json | 1 + .../autoImport/import-source/output.mjs | 5 + .../jsx/fixture/autoImport/no-jsx/input.js | 1 + .../jsx/fixture/autoImport/no-jsx/output.mjs | 1 + .../src/jsx/fixture/autoImport/options.json | 1 + .../fixture/autoImport/react-defined/input.js | 10 + .../autoImport/react-defined/options.json | 1 + .../autoImport/react-defined/output.mjs | 21 + .../input.js | 1 + .../options.json | 1 + .../output.js | 3 + .../input.js | 1 + .../options.json | 1 + .../output.stderr | 1 + .../input.js | 1 + .../options.json | 1 + .../output.stderr | 1 + .../input.js | 1 + .../options.json | 1 + .../output.stderr | 1 + .../input.js | 1 + .../options.json | 1 + .../output.js | 1 + .../input.js | 3 + .../options.json | 1 + .../output.mjs | 3 + .../output.stderr | 6 + .../input.js | 3 + .../options.json | 1 + .../output.js | 2 + .../input.js | 1 + .../options.json | 1 + .../output.js | 1 + .../input.js | 1 + .../options.json | 1 + .../output.js | 3 + .../input.js | 1 + .../options.json | 1 + .../output.js | 2 + .../input.js | 3 + .../options.json | 1 + .../output.mjs | 3 + .../output.stderr | 6 + .../input.js | 3 + .../options.json | 1 + .../output.js | 4 + .../input.js | 1 + .../options.json | 1 + .../output.js | 2 + .../input.js | 1 + .../options.json | 1 + .../output.js | 3 + .../input.js | 1 + .../options.json | 1 + .../output.js | 2 + .../input.js | 3 + .../options.json | 1 + .../output.mjs | 3 + .../output.stderr | 6 + .../input.js | 3 + .../options.json | 1 + .../output.js | 2 + .../input.js | 1 + .../options.json | 1 + .../output.js | 1 + .../react-automatic/.arrow-functions/input.js | 7 + .../.arrow-functions/output.mjs | 17 + .../.jsx-with-retainlines-option/input.js | 1 + .../.jsx-with-retainlines-option/options.json | 3 + .../.jsx-with-retainlines-option/output.mjs | 1 + .../input.js | 17 + .../options.json | 8 + .../output.mjs | 31 + .../.should-add-quotes-es3/input.js | 1 + .../.should-add-quotes-es3/options.json | 1 + .../.should-add-quotes-es3/output.mjs | 10 + .../.should-add-quotes-es3/output.stderr | 12 + .../input.js | 3 + .../options.json | 3 + .../output.mjs | 16 + .../input.js | 12 + .../options.json | 1 + .../output.mjs | 47 ++ .../input.js | 13 + .../input.js | 1 + .../options.json | 1 + .../output.stderr | 1 + .../input.js | 3 + .../output.mjs | 5 + .../react-automatic/assignment/input.js | 1 + .../react-automatic/assignment/output.mjs | 5 + .../input.js | 13 + .../output.mjs | 14 + .../input.mjs | 10 + .../options.json | 1 + .../output.mjs | 14 + .../input.js | 4 + .../output.mjs | 8 + .../react-automatic/duplicate-props/input.js | 7 + .../duplicate-props/output.mjs | 29 + .../react-automatic/flattens-spread/input.js | 7 + .../flattens-spread/output.mjs | 24 + .../handle-fragments-with-key/input.js | 3 + .../handle-fragments-with-key/output.mjs | 4 + .../input.js | 1 + .../output.mjs | 3 + .../react-automatic/handle-fragments/input.js | 1 + .../handle-fragments/output.mjs | 7 + .../handle-nonstatic-children/input.js | 5 + .../handle-nonstatic-children/output.mjs | 5 + .../handle-static-children/input.js | 6 + .../handle-static-children/output.mjs | 13 + .../jsx-without-retainlines-option/input.js | 1 + .../jsx-without-retainlines-option/output.mjs | 5 + .../key-undefined-works/input.js | 2 + .../key-undefined-works/output.mjs | 8 + .../jsx/fixture/react-automatic/options.json | 1 + .../input.js | 2 + .../output.mjs | 6 + .../should-allow-constructor-as-prop/input.js | 1 + .../output.mjs | 6 + .../input.js | 1 + .../output.mjs | 4 + .../input.js | 1 + .../output.mjs | 6 + .../should-allow-js-namespacing/blacklist.js | 1 + .../should-allow-js-namespacing/input.js | 1 + .../should-allow-js-namespacing/output.mjs | 4 + .../should-allow-nested-fragments/input.js | 12 + .../should-allow-nested-fragments/output.mjs | 20 + .../input.js | 15 + .../output.mjs | 17 + .../should-convert-simple-tags/input.js | 1 + .../should-convert-simple-tags/output.mjs | 3 + .../should-convert-simple-text/input.js | 1 + .../should-convert-simple-text/output.mjs | 5 + .../should-disallow-spread-children/input.js | 1 + .../options.json | 3 + .../output.mjs | 1 + .../output.stderr | 6 + .../should-disallow-xml-namespacing/input.js | 1 + .../options.json | 3 + .../output.mjs | 1 + .../output.stderr | 6 + .../should-escape-xhtml-jsxattribute/input.js | 3 + .../options.json | 4 + .../output.mjs | 10 + .../should-escape-xhtml-jsxtext/input.js | 12 + .../should-escape-xhtml-jsxtext/options.json | 1 + .../should-escape-xhtml-jsxtext/output.mjs | 31 + .../input.js | 11 + .../output.mjs | 14 + .../input.js | 1 + .../output.mjs | 6 + .../input.js | 5 + .../output.mjs | 9 + .../input.js | 16 + .../output.mjs | 8 + .../input.js | 1 + .../output.mjs | 10 + .../output.stderr | 12 + .../input.js | 1 + .../output.mjs | 7 + .../output.stderr | 12 + .../input.js | 1 + .../output.mjs | 6 + .../input.js | 1 + .../output.mjs | 6 + .../input.js | 10 + .../output.mjs | 11 + .../should-properly-handle-keys/input.js | 7 + .../should-properly-handle-keys/output.mjs | 7 + .../input.js | 2 + .../output.mjs | 5 + .../should-quote-jsx-attributes/input.js | 1 + .../should-quote-jsx-attributes/output.mjs | 7 + .../should-quote-jsx-attributes/output.stderr | 12 + .../input.js | 1 + .../options.json | 1 + .../output.mjs | 6 + .../input.js | 1 + .../options.json | 1 + .../output.mjs | 3 + .../output.stderr | 6 + .../input.js | 1 + .../output.mjs | 4 + .../input.js | 3 + .../output.mjs | 6 + .../input.js | 3 + .../output.mjs | 5 + .../react-automatic/this-tag-name/input.js | 1 + .../react-automatic/this-tag-name/output.mjs | 5 + .../react-automatic/weird-symbols/input.js | 5 + .../react-automatic/weird-symbols/output.mjs | 10 + .../input.js | 1 + .../output.mjs | 8 + .../input.js | 1 + .../output.mjs | 6 + .../input.js | 3 + .../options.json | 3 + .../output.js | 4 + .../fixture/react/.arrow-functions/input.js | 7 + .../fixture/react/.arrow-functions/output.js | 15 + .../react/.assignment-babel-7/input.js | 1 + .../react/.assignment-babel-7/options.json | 3 + .../react/.assignment-babel-7/output.js | 3 + .../react/.avoids-spread-babel-7/input.js | 11 + .../react/.avoids-spread-babel-7/options.json | 3 + .../react/.avoids-spread-babel-7/output.js | 32 + .../.jsx-with-retainlines-option/input.js | 1 + .../.jsx-with-retainlines-option/options.json | 3 + .../.jsx-with-retainlines-option/output.js | 1 + .../input.js | 17 + .../options.json | 8 + .../output.js | 37 + .../react/.should-add-quotes-es3/input.js | 1 + .../react/.should-add-quotes-es3/options.json | 1 + .../react/.should-add-quotes-es3/output.js | 8 + .../input.js | 13 + .../input.js | 3 + .../options.json | 1 + .../output.stderr | 1 + .../input.js | 4 + .../options.json | 3 + .../output.stderr | 1 + .../input.js | 2 + .../options.json | 3 + .../output.js | 5 + .../input.js | 1 + .../options.json | 3 + .../output.js | 5 + .../input.js | 1 + .../options.json | 3 + .../output.js | 6 + .../input.js | 3 + .../options.json | 3 + .../output.js | 4 + .../src/jsx/fixture/react/assignment/input.js | 1 + .../jsx/fixture/react/assignment/options.json | 3 + .../jsx/fixture/react/assignment/output.js | 3 + .../input.js | 13 + .../output.js | 1 + .../input.mjs | 10 + .../options.json | 3 + .../output.mjs | 10 + .../react/does-not-add-source-self/input.mjs | 10 + .../does-not-add-source-self/options.json | 3 + .../react/does-not-add-source-self/output.mjs | 10 + .../input.js | 4 + .../output.js | 2 + .../fixture/react/duplicate-props/input.js | 7 + .../fixture/react/duplicate-props/output.js | 23 + .../fixture/react/flattens-spread/input.js | 7 + .../fixture/react/flattens-spread/output.js | 17 + .../input.js | 8 + .../options.json | 1 + .../output.js | 6 + .../react/honor-custom-jsx-comment/input.js | 8 + .../react/honor-custom-jsx-comment/output.js | 6 + .../honor-custom-jsx-pragma-option/input.js | 6 + .../options.json | 1 + .../honor-custom-jsx-pragma-option/output.js | 5 + .../jsx-without-retainlines-option/input.js | 1 + .../jsx-without-retainlines-option/output.js | 1 + .../react/src/jsx/fixture/react/options.json | 1 + .../input.js | 2 + .../output.js | 2 + .../should-allow-constructor-as-prop/input.js | 1 + .../output.js | 4 + .../input.js | 1 + .../output.js | 2 + .../input.js | 1 + .../output.js | 4 + .../should-allow-js-namespacing/blacklist.js | 1 + .../should-allow-js-namespacing/input.js | 1 + .../should-allow-js-namespacing/output.js | 2 + .../should-allow-nested-fragments/input.js | 12 + .../should-allow-nested-fragments/output.js | 2 + .../input.js | 3 + .../output.js | 2 + .../should-allow-pragmafrag-and-frag/input.js | 4 + .../output.js | 4 + .../input.js | 15 + .../output.js | 4 + .../react/should-convert-simple-tags/input.js | 1 + .../should-convert-simple-tags/output.js | 1 + .../react/should-convert-simple-text/input.js | 1 + .../should-convert-simple-text/output.js | 1 + .../should-disallow-spread-children/input.js | 1 + .../options.json | 3 + .../output.mjs | 1 + .../output.stderr | 6 + .../should-disallow-xml-namespacing/input.js | 1 + .../options.json | 3 + .../output.mjs | 1 + .../output.stderr | 6 + .../input.js | 3 + .../options.json | 3 + .../output.js | 9 + .../should-escape-xhtml-jsxattribute/input.js | 3 + .../options.json | 3 + .../output.js | 9 + .../input.js | 12 + .../options.json | 3 + .../output.js | 26 + .../should-escape-xhtml-jsxtext/input.js | 12 + .../should-escape-xhtml-jsxtext/options.json | 3 + .../should-escape-xhtml-jsxtext/output.js | 26 + .../input.js | 11 + .../output.js | 9 + .../input.js | 1 + .../output.js | 2 + .../input.js | 5 + .../output.js | 1 + .../input.js | 16 + .../output.js | 6 + .../input.js | 1 + .../output.js | 8 + .../input.js | 1 + .../output.js | 4 + .../input.js | 1 + .../output.js | 2 + .../input.js | 1 + .../output.js | 2 + .../input.js | 10 + .../output.js | 8 + .../should-quote-jsx-attributes/input.js | 1 + .../should-quote-jsx-attributes/output.js | 4 + .../input.js | 1 + .../options.json | 1 + .../output.js | 3 + .../input.js | 1 + .../options.json | 1 + .../output.mjs | 1 + .../output.stderr | 6 + .../input.js | 1 + .../output.js | 2 + .../jsx/fixture/react/this-tag-name/input.js | 1 + .../jsx/fixture/react/this-tag-name/output.js | 1 + .../jsx/fixture/react/weird-symbols/input.js | 7 + .../jsx/fixture/react/weird-symbols/output.js | 7 + .../input.js | 2 + .../options.json | 3 + .../output.js | 5 + .../input.js | 1 + .../options.json | 3 + .../output.js | 6 + .../input.js | 1 + .../options.json | 3 + .../output.js | 6 + .../.issue-12478-automatic/input.js | 1 + .../.issue-12478-automatic/options.json | 1 + .../.issue-12478-automatic/output.js | 3 + .../.issue-12478-automatic/plugin.js | 13 + .../regression/.issue-12478-classic/input.js | 1 + .../.issue-12478-classic/options.json | 1 + .../regression/.issue-12478-classic/output.js | 1 + .../regression/.issue-12478-classic/plugin.js | 13 + .../input.js | 3 + .../options.json | 1 + .../output.js | 4 + .../.invalid-use-builtins-false/input.js | 1 + .../.invalid-use-builtins-false/options.json | 1 + .../.invalid-use-builtins-false/output.stderr | 1 + .../.invalid-use-builtins-true/input.js | 1 + .../.invalid-use-builtins-true/options.json | 1 + .../.invalid-use-builtins-true/output.stderr | 1 + .../.invalid-use-spread-false/input.js | 1 + .../.invalid-use-spread-false/options.json | 1 + .../.invalid-use-spread-false/output.stderr | 1 + .../.invalid-use-spread-true/input.js | 1 + .../.invalid-use-spread-true/options.json | 1 + .../.invalid-use-spread-true/output.stderr | 1 + .../runtime/.defaults-to-automatic/input.js | 1 + .../.defaults-to-automatic/options.json | 1 + .../runtime/.defaults-to-automatic/output.js | 5 + .../fixture/runtime/.invalid-runtime/input.js | 1 + .../runtime/.invalid-runtime/options.json | 1 + .../runtime/.invalid-runtime/output.stderr | 1 + .../runtime/.runtime-automatic/input.js | 1 + .../runtime/.runtime-automatic/options.json | 1 + .../runtime/.runtime-automatic/output.js | 5 + .../src/jsx/fixture/runtime/classic/input.js | 1 + .../jsx/fixture/runtime/classic/options.json | 1 + .../src/jsx/fixture/runtime/classic/output.js | 1 + .../defaults-to-classis-babel-7/input.js | 1 + .../defaults-to-classis-babel-7/options.json | 1 + .../defaults-to-classis-babel-7/output.js | 1 + .../runtime/pragma-runtime-classsic/input.js | 3 + .../pragma-runtime-classsic/options.json | 1 + .../runtime/pragma-runtime-classsic/output.js | 2 + .../.transform-to-babel-extend/input.js | 1 + .../.transform-to-babel-extend/options.json | 1 + .../.transform-to-babel-extend/output.js | 4 + .../.transform-to-object-assign/input.js | 1 + .../.transform-to-object-assign/options.json | 1 + .../.transform-to-object-assign/output.js | 5 + .../jsx/fixture/spread-transform/options.json | 3 + ecmascript/transforms/react/src/jsx/mod.rs | 709 +++++++++++++++--- .../transforms/react/src/jsx/static_check.rs | 33 + ecmascript/transforms/react/src/jsx/tests.rs | 60 ++ ecmascript/transforms/testing/Cargo.toml | 3 + ecmascript/transforms/testing/src/lib.rs | 157 ++++ 438 files changed, 3057 insertions(+), 101 deletions(-) create mode 100644 ecmascript/transforms/react/scripts/.gitignore create mode 100755 ecmascript/transforms/react/scripts/patch-options.sh create mode 100644 ecmascript/transforms/react/scripts/patch-options.ts create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/input.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/input.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/input.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-properly-handle-comments-adjacent-to-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/input.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/blacklist.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-properly-handle-comments-adjacent-to-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/assignment/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/assignment/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/assignment/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/input.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/input.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/blacklist.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.mjs create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/plugin.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/plugin.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/output.stderr create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/classic/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/classic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/classic/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/input.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/options.json create mode 100644 ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/output.js create mode 100644 ecmascript/transforms/react/src/jsx/fixture/spread-transform/options.json create mode 100644 ecmascript/transforms/react/src/jsx/static_check.rs diff --git a/Cargo.toml b/Cargo.toml index 65c16e841fd41..5ec57afc54f17 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc" repository = "https://github.com/swc-project/swc.git" -version = "0.4.0" +version = "0.5.0" [lib] name = "swc" @@ -31,8 +31,8 @@ swc_ecma_ast = {version = "0.38.0", path = "./ecmascript/ast"} swc_ecma_codegen = {version = "0.45.0", path = "./ecmascript/codegen"} swc_ecma_ext_transforms = {version = "0.4.0", path = "./ecmascript/ext-transforms"} swc_ecma_parser = {version = "0.47.0", path = "./ecmascript/parser"} -swc_ecma_preset_env = {version = "0.5.0", path = "./ecmascript/preset_env"} -swc_ecma_transforms = {version = "0.35.0", path = "./ecmascript/transforms", features = [ +swc_ecma_preset_env = {version = "0.6.0", path = "./ecmascript/preset_env"} +swc_ecma_transforms = {version = "0.36.0", path = "./ecmascript/transforms", features = [ "compat", "module", "optimization", diff --git a/bundler/Cargo.toml b/bundler/Cargo.toml index 38de01aae0087..99d3a7d4056af 100644 --- a/bundler/Cargo.toml +++ b/bundler/Cargo.toml @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"] license = "Apache-2.0/MIT" name = "swc_bundler" repository = "https://github.com/swc-project/swc.git" -version = "0.22.0" +version = "0.23.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] @@ -34,7 +34,7 @@ swc_common = {version = "0.10.0", path = "../common"} swc_ecma_ast = {version = "0.38.0", path = "../ecmascript/ast"} swc_ecma_codegen = {version = "0.45.0", path = "../ecmascript/codegen"} swc_ecma_parser = {version = "0.47.0", path = "../ecmascript/parser"} -swc_ecma_transforms = {version = "0.35.0", path = "../ecmascript/transforms", features = ["optimization"]} +swc_ecma_transforms = {version = "0.36.0", path = "../ecmascript/transforms", features = ["optimization"]} swc_ecma_utils = {version = "0.28.0", path = "../ecmascript/utils"} swc_ecma_visit = {version = "0.24.0", path = "../ecmascript/visit"} @@ -43,7 +43,7 @@ hex = "0.4" ntest = "0.7.2" reqwest = {version = "0.10.8", features = ["blocking"]} sha-1 = "0.9" -swc_ecma_transforms = {version = "0.35.0", path = "../ecmascript/transforms", features = ["react", "typescript"]} +swc_ecma_transforms = {version = "0.36.0", path = "../ecmascript/transforms", features = ["react", "typescript"]} tempfile = "3.1.0" testing = {version = "0.10.0", path = "../testing"} url = "2.1.1" diff --git a/ecmascript/Cargo.toml b/ecmascript/Cargo.toml index 0531af60dd46c..6aeedbe91eb72 100644 --- a/ecmascript/Cargo.toml +++ b/ecmascript/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecmascript" repository = "https://github.com/swc-project/swc.git" -version = "0.21.1" +version = "0.22.0" [package.metadata.docs.rs] all-features = true @@ -31,7 +31,7 @@ swc_ecma_ast = {version = "0.38.0", path = "./ast"} swc_ecma_codegen = {version = "0.45.0", path = "./codegen", optional = true} swc_ecma_dep_graph = {version = "0.15.0", path = "./dep-graph", optional = true} swc_ecma_parser = {version = "0.47.0", path = "./parser", optional = true} -swc_ecma_transforms = {version = "0.35.0", path = "./transforms", optional = true} +swc_ecma_transforms = {version = "0.36.0", path = "./transforms", optional = true} swc_ecma_utils = {version = "0.28.0", path = "./utils", optional = true} swc_ecma_visit = {version = "0.24.0", path = "./visit", optional = true} diff --git a/ecmascript/preset_env/Cargo.toml b/ecmascript/preset_env/Cargo.toml index c4d1372e92df2..8764859a12978 100644 --- a/ecmascript/preset_env/Cargo.toml +++ b/ecmascript/preset_env/Cargo.toml @@ -5,7 +5,7 @@ documentation = "https://swc.rs/rustdoc/swc_ecma_preset_env/" edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_preset_env" -version = "0.5.0" +version = "0.6.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -21,7 +21,7 @@ string_enum = {version = "0.3", path = "../../macros/string_enum"} swc_atoms = {version = "0.2", path = "../../atoms"} swc_common = {version = "0.10", path = "../../common"} swc_ecma_ast = {version = "0.38.0", path = "../ast"} -swc_ecma_transforms = {version = "0.35.0", path = "../transforms", features = ["compat", "proposal"]} +swc_ecma_transforms = {version = "0.36.0", path = "../transforms", features = ["compat", "proposal"]} swc_ecma_utils = {version = "0.28.0", path = "../utils"} swc_ecma_visit = {version = "0.24.0", path = "../visit"} walkdir = "2" diff --git a/ecmascript/transforms/Cargo.toml b/ecmascript/transforms/Cargo.toml index 7b00419c105fe..cb41608d05a5b 100644 --- a/ecmascript/transforms/Cargo.toml +++ b/ecmascript/transforms/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms" repository = "https://github.com/swc-project/swc.git" -version = "0.35.0" +version = "0.36.0" [features] compat = ["swc_ecma_transforms_compat"] @@ -24,9 +24,9 @@ swc_ecma_parser = {version = "0.47.0", path = "../parser"} swc_ecma_transforms_base = {version = "0.4.0", path = "./base"} swc_ecma_transforms_compat = {version = "0.5.0", path = "./compat", optional = true} swc_ecma_transforms_module = {version = "0.5.0", path = "./module", optional = true} -swc_ecma_transforms_optimization = {version = "0.5.0", path = "./optimization", optional = true} +swc_ecma_transforms_optimization = {version = "0.6.0", path = "./optimization", optional = true} swc_ecma_transforms_proposal = {version = "0.5.0", path = "./proposal", optional = true} -swc_ecma_transforms_react = {version = "0.5.0", path = "./react", optional = true} +swc_ecma_transforms_react = {version = "0.6.0", path = "./react", optional = true} swc_ecma_transforms_typescript = {version = "0.5.0", path = "./typescript", optional = true} swc_ecma_utils = {version = "0.28.0", path = "../utils"} swc_ecma_visit = {version = "0.24.0", path = "../visit"} diff --git a/ecmascript/transforms/optimization/Cargo.toml b/ecmascript/transforms/optimization/Cargo.toml index 78346b07d5d25..efddda78ab68b 100644 --- a/ecmascript/transforms/optimization/Cargo.toml +++ b/ecmascript/transforms/optimization/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms_optimization" repository = "https://github.com/swc-project/swc.git" -version = "0.5.0" +version = "0.6.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -29,6 +29,6 @@ swc_ecma_visit = {version = "0.24.0", path = "../../visit"} swc_ecma_transforms_compat = {version = "0.5.0", path = "../compat"} swc_ecma_transforms_module = {version = "0.5.0", path = "../module"} swc_ecma_transforms_proposal = {version = "0.5.0", path = "../proposal"} -swc_ecma_transforms_react = {version = "0.5.0", path = "../react"} +swc_ecma_transforms_react = {version = "0.6.0", path = "../react"} swc_ecma_transforms_testing = {version = "0.4.0", path = "../testing"} swc_ecma_transforms_typescript = {version = "0.5.0", path = "../typescript"} diff --git a/ecmascript/transforms/react/Cargo.toml b/ecmascript/transforms/react/Cargo.toml index e882e84958228..5ddc0d8b2b0b1 100644 --- a/ecmascript/transforms/react/Cargo.toml +++ b/ecmascript/transforms/react/Cargo.toml @@ -3,10 +3,11 @@ authors = ["강동윤 "] description = "rust port of babel and closure compiler." documentation = "https://swc.rs/rustdoc/swc_ecma_transforms_react/" edition = "2018" +include = ["Cargo.toml", "src/**/*.rs"] license = "Apache-2.0/MIT" name = "swc_ecma_transforms_react" repository = "https://github.com/swc-project/swc.git" -version = "0.5.1" +version = "0.6.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -14,6 +15,7 @@ dashmap = "4.0.1" once_cell = "1.5.2" regex = "1.4.2" serde = {version = "1.0.118", features = ["derive"]} +string_enum = {version = "0.3", path = "../../../macros/string_enum"} swc_atoms = {version = "0.2", path = "../../../atoms"} swc_common = {version = "0.10", path = "../../../common"} swc_ecma_ast = {version = "0.38.0", path = "../../ast"} @@ -26,3 +28,4 @@ swc_ecma_visit = {version = "0.24.0", path = "../../visit"} swc_ecma_transforms_compat = {version = "0.5.0", path = "../compat/"} swc_ecma_transforms_module = {version = "0.5.0", path = "../module"} swc_ecma_transforms_testing = {version = "0.4.0", path = "../testing/"} +testing = {version = "0.10.2", path = "../../../testing"} diff --git a/ecmascript/transforms/react/scripts/.gitignore b/ecmascript/transforms/react/scripts/.gitignore new file mode 100644 index 0000000000000..4c43fe68f6405 --- /dev/null +++ b/ecmascript/transforms/react/scripts/.gitignore @@ -0,0 +1 @@ +*.js \ No newline at end of file diff --git a/ecmascript/transforms/react/scripts/patch-options.sh b/ecmascript/transforms/react/scripts/patch-options.sh new file mode 100755 index 0000000000000..c308c352acc6b --- /dev/null +++ b/ecmascript/transforms/react/scripts/patch-options.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +npx tsc scripts/patch-options.ts +node scripts/patch-options.js \ No newline at end of file diff --git a/ecmascript/transforms/react/scripts/patch-options.ts b/ecmascript/transforms/react/scripts/patch-options.ts new file mode 100644 index 0000000000000..3f8c92327baf9 --- /dev/null +++ b/ecmascript/transforms/react/scripts/patch-options.ts @@ -0,0 +1,57 @@ +import * as fs from 'fs'; +import * as path from 'path'; + +async function* walk(dir: string): AsyncGenerator { + for await (const d of await fs.promises.opendir(dir)) { + const entry = path.join(dir, d.name); + if (d.isDirectory()) yield* walk(entry); + else if (d.isFile()) yield entry; + } +} + +// Then, use it with a simple async for loop +async function main() { + // TODO: Generalize path + for await (const f of walk('src/jsx/fixture')) { + if (!f.endsWith('.json')) { + continue + } + const obj = JSON.parse(await fs.promises.readFile(f, { encoding: 'utf-8' })); + const dir = path.dirname(f); + + if (obj.throws) { + await fs.promises.writeFile(path.join(dir, "output.stderr"), obj.throws); + } + + + console.log(f); + if (obj.plugins) { + if (obj.plugins.includes('transform-react-jsx')) { + const newObj = { + ...obj, + }; + delete newObj.sourceType + delete newObj.plugins; + await fs.promises.writeFile(f, JSON.stringify(newObj), { encoding: 'utf-8' }); + continue + } + + for (const [plugin, config] of obj.plugins) { + if (plugin === 'transform-react-jsx') { + console.log(plugin, config); + const newObj = { + ...obj, + ...config, + }; + delete newObj.sourceType + delete newObj.plugins; + await fs.promises.writeFile(f, JSON.stringify(newObj), { encoding: 'utf-8' }); + break + } + } + } + + } +} + +main() \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/input.js new file mode 100644 index 0000000000000..2e9a28fc925c5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/input.js @@ -0,0 +1,10 @@ +// https://github.com/babel/babel/issues/12522 + +require('react-app-polyfill/ie11'); +require('react-app-polyfill/stable'); +const ReactDOM = require('react-dom'); + +ReactDOM.render( +

Hello, World!

, + document.getElementById('root') +); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/output.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/output.js new file mode 100644 index 0000000000000..40333e930ef35 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.after-polyfills-script-not-supported/output.js @@ -0,0 +1,12 @@ +var _reactJsxRuntime = require("react/jsx-runtime"); + +// https://github.com/babel/babel/issues/12522 +require('react-app-polyfill/ie11'); + +require('react-app-polyfill/stable'); + +const ReactDOM = require('react-dom'); + +ReactDOM.render( /*#__PURE__*/_reactJsxRuntime.jsx("p", { + children: "Hello, World!" +}), document.getElementById('root')); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/input.js new file mode 100644 index 0000000000000..3a24e66a05472 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/input.js @@ -0,0 +1,10 @@ +var x = ( + <> +
+
+
+
+
+
+ +); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/output.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/output.js new file mode 100644 index 0000000000000..61a0eebb30ce9 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.auto-import-react-source-type-script/output.js @@ -0,0 +1,13 @@ +var _react = require("react"); + +var _reactJsxRuntime = require("react/jsx-runtime"); + +var x = /*#__PURE__*/_reactJsxRuntime.jsx(_reactJsxRuntime.Fragment, { + children: /*#__PURE__*/_reactJsxRuntime.jsxs("div", { + children: [/*#__PURE__*/_reactJsxRuntime.jsx("div", {}, "1"), /*#__PURE__*/_reactJsxRuntime.jsx("div", { + meow: "wolf" + }, "2"), /*#__PURE__*/_reactJsxRuntime.jsx("div", {}, "3"), /*#__PURE__*/_react.createElement("div", { ...props, + key: "4" + })] + }) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/input.js new file mode 100644 index 0000000000000..3cbea31e438af --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/input.js @@ -0,0 +1,15 @@ +const Bar = () => { + const Foo = () => { + const Component = ({thing, ..._react}) => { + if (!thing) { + var _react2 = "something useless"; + var b = _react3(); + var c = _react5(); + var jsx = 1; + var _jsx = 2; + return
; + }; + return ; + }; + } +} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/output.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/output.js new file mode 100644 index 0000000000000..8784a681200d5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/.complicated-scope-script/output.js @@ -0,0 +1,25 @@ +var _reactJsxRuntime = require("react/jsx-runtime"); + +const Bar = () => { + const Foo = () => { + const Component = ({ + thing, + ..._react + }) => { + if (!thing) { + var _react2 = "something useless"; + + var b = _react3(); + + var c = _react5(); + + var jsx = 1; + var _jsx = 2; + return /*#__PURE__*/_reactJsxRuntime.jsx("div", {}); + } + + ; + return /*#__PURE__*/_reactJsxRuntime.jsx("span", {}); + }; + }; +}; diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/input.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/input.mjs new file mode 100644 index 0000000000000..f8f6561b2e4c9 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/input.mjs @@ -0,0 +1,11 @@ +// https://github.com/babel/babel/issues/12522 + +ReactDOM.render( +

Hello, World!

, + document.getElementById('root') +); + +// Imports are hoisted, so this is still ok +import 'react-app-polyfill/ie11'; +import 'react-app-polyfill/stable'; +import ReactDOM from 'react-dom'; diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/output.mjs new file mode 100644 index 0000000000000..111ddd3ba39c0 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-2/output.mjs @@ -0,0 +1,9 @@ +// https://github.com/babel/babel/issues/12522 +ReactDOM.render( /*#__PURE__*/_jsx("p", { + children: "Hello, World!" +}), document.getElementById('root')); // Imports are hoisted, so this is still ok + +import 'react-app-polyfill/ie11'; +import 'react-app-polyfill/stable'; +import ReactDOM from 'react-dom'; +import { jsx as _jsx } from "react/jsx-runtime"; diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/input.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/input.mjs new file mode 100644 index 0000000000000..645daee448bf2 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/input.mjs @@ -0,0 +1,10 @@ +// https://github.com/babel/babel/issues/12522 + +import 'react-app-polyfill/ie11'; +import 'react-app-polyfill/stable'; +import ReactDOM from 'react-dom'; + +ReactDOM.render( +

Hello, World!

, + document.getElementById('root') +); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/output.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/output.js new file mode 100644 index 0000000000000..d6fc30116cf93 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills-compiled-to-cjs/output.js @@ -0,0 +1,16 @@ +"use strict"; + +require("react-app-polyfill/ie11"); + +require("react-app-polyfill/stable"); + +var _reactDom = _interopRequireDefault(require("react-dom")); + +var _jsxRuntime = require("react/jsx-runtime"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// https://github.com/babel/babel/issues/12522 +_reactDom.default.render( /*#__PURE__*/(0, _jsxRuntime.jsx)("p", { + children: "Hello, World!" +}), document.getElementById('root')); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/input.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/input.mjs new file mode 100644 index 0000000000000..645daee448bf2 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/input.mjs @@ -0,0 +1,10 @@ +// https://github.com/babel/babel/issues/12522 + +import 'react-app-polyfill/ie11'; +import 'react-app-polyfill/stable'; +import ReactDOM from 'react-dom'; + +ReactDOM.render( +

Hello, World!

, + document.getElementById('root') +); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/output.mjs new file mode 100644 index 0000000000000..dce91bef3b678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/after-polyfills/output.mjs @@ -0,0 +1,8 @@ +// https://github.com/babel/babel/issues/12522 +import 'react-app-polyfill/ie11'; +import 'react-app-polyfill/stable'; +import ReactDOM from 'react-dom'; +import { jsx as _jsx } from "react/jsx-runtime"; +ReactDOM.render( /*#__PURE__*/_jsx("p", { + children: "Hello, World!" +}), document.getElementById('root')); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/input.js new file mode 100644 index 0000000000000..3a24e66a05472 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/input.js @@ -0,0 +1,10 @@ +var x = ( + <> +
+
+
+
+
+
+ +); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/output.mjs new file mode 100644 index 0000000000000..dac25125f2e37 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/auto-import-react-source-type-module/output.mjs @@ -0,0 +1,13 @@ +import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; +import { createElement as _createElement } from "react"; + +var x = /*#__PURE__*/_jsx(_Fragment, { + children: /*#__PURE__*/_jsxs("div", { + children: [/*#__PURE__*/_jsx("div", {}, "1"), /*#__PURE__*/_jsx("div", { + meow: "wolf" + }, "2"), /*#__PURE__*/_jsx("div", {}, "3"), /*#__PURE__*/_createElement("div", { + ...props, + key: "4" + })] + }) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/input.js new file mode 100644 index 0000000000000..3cbea31e438af --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/input.js @@ -0,0 +1,15 @@ +const Bar = () => { + const Foo = () => { + const Component = ({thing, ..._react}) => { + if (!thing) { + var _react2 = "something useless"; + var b = _react3(); + var c = _react5(); + var jsx = 1; + var _jsx = 2; + return
; + }; + return ; + }; + } +} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/output.mjs new file mode 100644 index 0000000000000..8aa70983ae71f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/complicated-scope-module/output.mjs @@ -0,0 +1,19 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +const Bar = ()=>{ + const Foo = ()=>{ + const Component = ({ thing , ..._react })=>{ + if (!thing) { + var _react2 = "something useless"; + var b = _react3(); + var c = _react5(); + var jsx = 1; + var _jsx1 = 2; + return _jsx("div", { + }); + } + ; + return _jsx("span", { + }); + }; + }; +}; diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/input.js new file mode 100644 index 0000000000000..8384da556f8ff --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/input.js @@ -0,0 +1,2 @@ +/** @jsxImportSource baz */ +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/output.mjs new file mode 100644 index 0000000000000..0049c235923c9 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source-pragma/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "baz/jsx-runtime"; + +/** @jsxImportSource baz */ +var x = _jsx("div", { + children: _jsx("span", {}) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/input.js new file mode 100644 index 0000000000000..6a6f1f219c0db --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/input.js @@ -0,0 +1 @@ +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/options.json new file mode 100644 index 0000000000000..ddb157ecfc332 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/options.json @@ -0,0 +1 @@ +{"importSource":"foo","runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/output.mjs new file mode 100644 index 0000000000000..05dafe98f54b6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/import-source/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "foo/jsx-runtime"; + +var x = _jsx("div", { + children: _jsx("span", {}) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/input.js new file mode 100644 index 0000000000000..3ea99257fd419 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/input.js @@ -0,0 +1 @@ +var foo = "
"; \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/output.mjs new file mode 100644 index 0000000000000..9afe2bdf3f517 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/no-jsx/output.mjs @@ -0,0 +1 @@ +var foo = "
"; diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/input.js b/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/input.js new file mode 100644 index 0000000000000..bde12661d8ec0 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/input.js @@ -0,0 +1,10 @@ +import * as react from "react"; +var y = react.createElement("div", {foo: 1}); +var x = ( +
+
+
+
+
+
+); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/options.json b/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/output.mjs new file mode 100644 index 0000000000000..3af4950ef64b3 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/autoImport/react-defined/output.mjs @@ -0,0 +1,21 @@ +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; +import { createElement as _createElement } from "react"; +import * as react from "react"; +var y = react.createElement("div", { + foo: 1 +}); +var x = _jsxs("div", { + children: [ + _jsx("div", { + }, "1"), + _jsx("div", { + meow: "wolf" + }, "2"), + _jsx("div", { + }, "3"), + _createElement("div", { + ...props, + key: "4" + }) + ] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/options.json new file mode 100644 index 0000000000000..6955447c69d32 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/options.json @@ -0,0 +1 @@ +{"pure":false,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/output.js new file mode 100644 index 0000000000000..e93ee3babc60e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-default-pragma-automatic-runtime/output.js @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("div", { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/options.json new file mode 100644 index 0000000000000..1c8de489ca4f6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/options.json @@ -0,0 +1 @@ +{"throws":"pragma and pragmaFrag cannot be set when runtime is automatic.","pragma":"h","pure":false,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/output.stderr new file mode 100644 index 0000000000000..869e7c78afb9a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.false-pragma-option-automatic-runtime/output.stderr @@ -0,0 +1 @@ +pragma and pragmaFrag cannot be set when runtime is automatic. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/options.json new file mode 100644 index 0000000000000..34f6912a95af7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/options.json @@ -0,0 +1 @@ +{"throws":"pragma and pragmaFrag cannot be set when runtime is automatic.","pragma":"h","pure":true,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/output.stderr new file mode 100644 index 0000000000000..869e7c78afb9a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.true-pragma-option-automatic-runtime/output.stderr @@ -0,0 +1 @@ +pragma and pragmaFrag cannot be set when runtime is automatic. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/options.json new file mode 100644 index 0000000000000..40e3619e58b2f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/options.json @@ -0,0 +1 @@ +{"throws":"pragma and pragmaFrag cannot be set when runtime is automatic.","pragma":"h","runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/output.stderr new file mode 100644 index 0000000000000..869e7c78afb9a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/.unset-pragma-option-automatic-runtime/output.stderr @@ -0,0 +1 @@ +pragma and pragmaFrag cannot be set when runtime is automatic. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/options.json new file mode 100644 index 0000000000000..f029d34bdb541 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/options.json @@ -0,0 +1 @@ +{"pure":false,"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/output.js new file mode 100644 index 0000000000000..3cd05d5f9f2f1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-default-pragma-classic-runtime/output.js @@ -0,0 +1 @@ +React.createElement("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/input.js new file mode 100644 index 0000000000000..6b8761b4a90a6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/input.js @@ -0,0 +1,3 @@ +/* @jsx h */ + +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/options.json new file mode 100644 index 0000000000000..4024eb0460971 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/options.json @@ -0,0 +1 @@ +{"throws":"pragma and pragmaFrag cannot be set when runtime is automatic","pure":false,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.mjs new file mode 100644 index 0000000000000..e93ee3babc60e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.mjs @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("div", { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.stderr new file mode 100644 index 0000000000000..4b189d0486e89 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-automatic-runtime/output.stderr @@ -0,0 +1,6 @@ +error: pragma and pragmaFrag cannot be set when runtime is automatic + --> input.js:3:1 + | +3 |
; + | ^^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/input.js new file mode 100644 index 0000000000000..6b8761b4a90a6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/input.js @@ -0,0 +1,3 @@ +/* @jsx h */ + +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/options.json new file mode 100644 index 0000000000000..f029d34bdb541 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/options.json @@ -0,0 +1 @@ +{"pure":false,"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/output.js new file mode 100644 index 0000000000000..6dc3b55a8a61c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-comment-classic-runtime/output.js @@ -0,0 +1,2 @@ +/* @jsx h */ +h("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/options.json new file mode 100644 index 0000000000000..454ebcdeb2d1a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/options.json @@ -0,0 +1 @@ +{"pragma":"h","pure":false,"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/output.js new file mode 100644 index 0000000000000..5b745cd1b8637 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/false-pragma-option-classic-runtime/output.js @@ -0,0 +1 @@ +h("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/options.json new file mode 100644 index 0000000000000..8b229e0bdfbff --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/options.json @@ -0,0 +1 @@ +{"pure":true,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/output.js new file mode 100644 index 0000000000000..e93ee3babc60e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-automatic-runtime/output.js @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("div", { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/options.json new file mode 100644 index 0000000000000..0f0647955a6af --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/options.json @@ -0,0 +1 @@ +{"pure":true,"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/output.js new file mode 100644 index 0000000000000..6ad0513bb2032 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-default-pragma-classic-runtime/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/input.js new file mode 100644 index 0000000000000..6b8761b4a90a6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/input.js @@ -0,0 +1,3 @@ +/* @jsx h */ + +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/options.json new file mode 100644 index 0000000000000..0d779f83dcf13 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/options.json @@ -0,0 +1 @@ +{"throws":"pragma and pragmaFrag cannot be set when runtime is automatic","pure":true,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.mjs new file mode 100644 index 0000000000000..e93ee3babc60e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.mjs @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("div", { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.stderr new file mode 100644 index 0000000000000..4b189d0486e89 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-automatic-runtime/output.stderr @@ -0,0 +1,6 @@ +error: pragma and pragmaFrag cannot be set when runtime is automatic + --> input.js:3:1 + | +3 |
; + | ^^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/input.js new file mode 100644 index 0000000000000..6b8761b4a90a6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/input.js @@ -0,0 +1,3 @@ +/* @jsx h */ + +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/options.json new file mode 100644 index 0000000000000..0f0647955a6af --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/options.json @@ -0,0 +1 @@ +{"pure":true,"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/output.js new file mode 100644 index 0000000000000..f9bf7e4e5fbce --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-comment-classic-runtime/output.js @@ -0,0 +1,4 @@ +/* @jsx h */ + +/*#__PURE__*/ +h("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/options.json new file mode 100644 index 0000000000000..9d253ee7264df --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/options.json @@ -0,0 +1 @@ +{"pragma":"h","pure":true,"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/output.js new file mode 100644 index 0000000000000..64cd477b1617f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/true-pragma-option-classic-runtime/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +h("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/output.js new file mode 100644 index 0000000000000..e93ee3babc60e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-automatic-runtime/output.js @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("div", { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/output.js new file mode 100644 index 0000000000000..6ad0513bb2032 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-default-pragma-classic-runtime/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/input.js new file mode 100644 index 0000000000000..6b8761b4a90a6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/input.js @@ -0,0 +1,3 @@ +/* @jsx h */ + +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/options.json new file mode 100644 index 0000000000000..44d34326c07b2 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/options.json @@ -0,0 +1 @@ +{"throws":"pragma and pragmaFrag cannot be set when runtime is automatic","runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.mjs new file mode 100644 index 0000000000000..e93ee3babc60e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.mjs @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("div", { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.stderr new file mode 100644 index 0000000000000..4b189d0486e89 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-automatic-runtime/output.stderr @@ -0,0 +1,6 @@ +error: pragma and pragmaFrag cannot be set when runtime is automatic + --> input.js:3:1 + | +3 |
; + | ^^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/input.js new file mode 100644 index 0000000000000..6b8761b4a90a6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/input.js @@ -0,0 +1,3 @@ +/* @jsx h */ + +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/output.js new file mode 100644 index 0000000000000..6dc3b55a8a61c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-comment-classic-runtime/output.js @@ -0,0 +1,2 @@ +/* @jsx h */ +h("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/input.js new file mode 100644 index 0000000000000..cbe1d12c589be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/input.js @@ -0,0 +1 @@ +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/options.json new file mode 100644 index 0000000000000..2e02f708fe6d3 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/options.json @@ -0,0 +1 @@ +{"pragma":"h","runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/output.js new file mode 100644 index 0000000000000..5b745cd1b8637 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/pure/unset-pragma-option-classic-runtime/output.js @@ -0,0 +1 @@ +h("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/input.js new file mode 100644 index 0000000000000..91f343d34974b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/input.js @@ -0,0 +1,7 @@ +var foo = function () { + return () => ; +}; + +var bar = function () { + return () => ; +}; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/output.mjs new file mode 100644 index 0000000000000..e5a605c67c18a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.arrow-functions/output.mjs @@ -0,0 +1,17 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var foo = function () { + var _this = this; + + return function () { + return /*#__PURE__*/_jsx(_this, {}); + }; +}; + +var bar = function () { + var _this2 = this; + + return function () { + return /*#__PURE__*/_jsx(_this2.foo, {}); + }; +}; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/input.js new file mode 100644 index 0000000000000..1addddeb1500c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/input.js @@ -0,0 +1 @@ +var div =
test
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/options.json new file mode 100644 index 0000000000000..97925bbcb61be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/options.json @@ -0,0 +1,3 @@ +{ + "retainLines": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/output.mjs new file mode 100644 index 0000000000000..81cfa808941f6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.jsx-with-retainlines-option/output.mjs @@ -0,0 +1 @@ +import { jsx as _jsx } from "react/jsx-runtime";var div = /*#__PURE__*/_jsx("div", { children: "test" }); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/input.js new file mode 100644 index 0000000000000..87ccec557d36b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/input.js @@ -0,0 +1,17 @@ +class App extends React.Component { + render() { + const navbarHeader =
+ + + +
; + + return
+ +
; + } +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/options.json new file mode 100644 index 0000000000000..721403cf3973f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + ["external-helpers", { "helperVersion": "7.100.0" }], + "transform-react-constant-elements", + "transform-classes", + "syntax-jsx" + ] +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/output.mjs new file mode 100644 index 0000000000000..188cfa91ed069 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.optimisation.react.constant-elements/output.mjs @@ -0,0 +1,31 @@ +var _ref =
+ + + +
; + +let App = /*#__PURE__*/function (_React$Component) { + babelHelpers.inherits(App, _React$Component); + + var _super = babelHelpers.createSuper(App); + + function App() { + babelHelpers.classCallCheck(this, App); + return _super.apply(this, arguments); + } + + babelHelpers.createClass(App, [{ + key: "render", + value: function render() { + const navbarHeader = _ref; + return
+ +
; + } + }]); + return App; +}(React.Component); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/input.js new file mode 100644 index 0000000000000..a47734ffb31a4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/input.js @@ -0,0 +1 @@ +var es3 = ; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.mjs new file mode 100644 index 0000000000000..a57a04a495083 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.mjs @@ -0,0 +1,10 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var es3 = /*#__PURE__*/_jsx(F, { + aaa: true, + "new": true, + "const": true, + "var": true, + "default": true, + "foo-bar": true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.stderr new file mode 100644 index 0000000000000..23ed73ac85f02 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-add-quotes-es3/output.stderr @@ -0,0 +1,12 @@ +error: Expected ,, got : + --> output.js:8:12 + | +8 | foo-bar: true + | ^ + +error: Expression expected + --> output.js:8:8 + | +8 | foo-bar: true + | ^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/input.js new file mode 100644 index 0000000000000..addae3b9f807e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/input.js @@ -0,0 +1,3 @@ +
; +
; +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/output.mjs new file mode 100644 index 0000000000000..9a5aedeff449c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxattribute-babel-7/output.mjs @@ -0,0 +1,16 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("div", { + id: "w\xF4w" +}); + +/*#__PURE__*/ +_jsx("div", { + id: "\\w" +}); + +/*#__PURE__*/ +_jsx("div", { + id: "w < w" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/input.js new file mode 100644 index 0000000000000..2104766109bb5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/input.js @@ -0,0 +1,12 @@ +
wow
; +
wôw
; + +
w & w
; +
w & w
; + +
w   w
; +
this should not parse as unicode: \u00a0
; +
this should parse as nbsp:  
; +
this should parse as unicode: {'\u00a0 '}
; + +
w < w
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/options.json new file mode 100644 index 0000000000000..3849cb9189b5f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/options.json @@ -0,0 +1 @@ +{ "BABEL_8_BREAKING": false } diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/output.mjs new file mode 100644 index 0000000000000..4c325c34bd4dc --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-escape-xhtml-jsxtext-babel-7/output.mjs @@ -0,0 +1,47 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +import { jsxs as _jsxs } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("div", { + children: "wow" +}); + +/*#__PURE__*/ +_jsx("div", { + children: "w\xF4w" +}); + +/*#__PURE__*/ +_jsx("div", { + children: "w & w" +}); + +/*#__PURE__*/ +_jsx("div", { + children: "w & w" +}); + +/*#__PURE__*/ +_jsx("div", { + children: "w \xA0 w" +}); + +/*#__PURE__*/ +_jsx("div", { + children: "this should not parse as unicode: \\u00a0" +}); + +/*#__PURE__*/ +_jsx("div", { + children: "this should parse as nbsp: \xA0 " +}); + +/*#__PURE__*/ +_jsxs("div", { + children: ["this should parse as unicode: ", '\u00a0 '] +}); + +/*#__PURE__*/ +_jsx("div", { + children: "w < w" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-properly-handle-comments-adjacent-to-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-properly-handle-comments-adjacent-to-children/input.js new file mode 100644 index 0000000000000..412984681eea7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-properly-handle-comments-adjacent-to-children/input.js @@ -0,0 +1,13 @@ +var x = ( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/input.js new file mode 100644 index 0000000000000..1addddeb1500c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/input.js @@ -0,0 +1 @@ +var div =
test
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/options.json new file mode 100644 index 0000000000000..3a4a9775bc6ec --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/options.json @@ -0,0 +1 @@ +{"throws":"pragma and pragmaFrag cannot be set when runtime is automatic.","runtime":"automatic","pragma":"foo"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/output.stderr new file mode 100644 index 0000000000000..869e7c78afb9a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/.should-warn-when-pragma-or-pragmaFrag-is-set/output.stderr @@ -0,0 +1 @@ +pragma and pragmaFrag cannot be set when runtime is automatic. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/input.js new file mode 100644 index 0000000000000..2c800f155830a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/input.js @@ -0,0 +1,3 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/output.mjs new file mode 100644 index 0000000000000..dda0abe4fb935 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/adds-appropriate-newlines-when-using-spread-attribute/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx(Component, { + ...props, + sound: "moo" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/output.mjs new file mode 100644 index 0000000000000..1819ffb3b3663 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/assignment/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +var div = _jsx(Component, { + ...props, + foo: "bar" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/input.js new file mode 100644 index 0000000000000..f3f30af044087 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/input.js @@ -0,0 +1,13 @@ +var x = +
+ foo + {"bar"} + baz +
+ buz + bang +
+ qux + {null} + quack +
diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/output.mjs new file mode 100644 index 0000000000000..75eb66eca698c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/concatenates-adjacent-string-literals/output.mjs @@ -0,0 +1,14 @@ +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; +var x = _jsxs("div", { + children: [ + "foo", + "bar", + "baz", + _jsx("div", { + children: "buz bang" + }), + "qux", + null, + "quack" + ] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/input.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/input.mjs new file mode 100644 index 0000000000000..ebd66ec03e0ad --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/input.mjs @@ -0,0 +1,10 @@ +var x = ( + <> +
+
+
+
+
+
+ +); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/options.json new file mode 100644 index 0000000000000..e838d2b000992 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/options.json @@ -0,0 +1 @@ +{"autoImport":"namedExports","runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/output.mjs new file mode 100644 index 0000000000000..0d5facec86d48 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/does-not-add-source-self-automatic/output.mjs @@ -0,0 +1,14 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +import { createElement as _createElement } from "react"; +import { jsxs as _jsxs } from "react/jsx-runtime"; +import { Fragment as _Fragment } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx(_Fragment, { + children: /*#__PURE__*/_jsxs("div", { + children: [/*#__PURE__*/_jsx("div", {}, "1"), /*#__PURE__*/_jsx("div", { + meow: "wolf" + }, "2"), /*#__PURE__*/_jsx("div", {}, "3"), /*#__PURE__*/_createElement("div", { ...props, + key: "4" + })] + }) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/input.js new file mode 100644 index 0000000000000..c8da550222839 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/input.js @@ -0,0 +1,4 @@ + + To get started, edit index.ios.js!!!{"\n"} + Press Cmd+R to reload + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/output.mjs new file mode 100644 index 0000000000000..a90dd94731644 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/dont-coerce-expression-containers/output.mjs @@ -0,0 +1,8 @@ +import { jsxs as _jsxs } from "react/jsx-runtime"; +_jsxs(Text, { + children: [ + "To get started, edit index.ios.js!!!", + "\n", + "Press Cmd+R to reload" + ] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/input.js new file mode 100644 index 0000000000000..8741892b4cef0 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/input.js @@ -0,0 +1,7 @@ +

text

; + +

text

; + +

text

; + +

text

; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/output.mjs new file mode 100644 index 0000000000000..f968ee0b3cb96 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/duplicate-props/output.mjs @@ -0,0 +1,29 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("p", { + prop: true, + prop: true, + children: "text" +}); + +/*#__PURE__*/ +_jsx("p", { + prop, + prop, + children: "text" +}); + +/*#__PURE__*/ +_jsx("p", { + prop: true, + prop, + children: "text" +}); + +/*#__PURE__*/ +_jsx("p", { + prop, + prop: true, + children: "text" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/input.js new file mode 100644 index 0000000000000..7cf92a69c6056 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/input.js @@ -0,0 +1,7 @@ +

text

; + +
{contents}
; + +; + +
{items}
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/output.mjs new file mode 100644 index 0000000000000..738dcc4e9e951 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/flattens-spread/output.mjs @@ -0,0 +1,24 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("p", { ...props, + children: "text" +}); + +/*#__PURE__*/ +_jsx("div", { ...props, + children: contents +}); + +/*#__PURE__*/ +_jsx("img", { + alt: "", + src, + title +}); + +/*#__PURE__*/ +_jsx("blockquote", { + cite, + children: items +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/input.js new file mode 100644 index 0000000000000..9fac2d0f98502 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/input.js @@ -0,0 +1,3 @@ +import * as React from "react"; + +var x = ; \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/output.mjs new file mode 100644 index 0000000000000..de66025461657 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-key/output.mjs @@ -0,0 +1,4 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +import * as React from "react"; +var x = _jsx(React.Fragment, { +}, "foo"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/input.js new file mode 100644 index 0000000000000..d766356c98c24 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/input.js @@ -0,0 +1 @@ +var x = <>; \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/output.mjs new file mode 100644 index 0000000000000..34e75ad17bf57 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments-with-no-children/output.mjs @@ -0,0 +1,3 @@ +import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; +var x = _jsx(_Fragment, { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/input.js new file mode 100644 index 0000000000000..d2a2902b85743 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/input.js @@ -0,0 +1 @@ +var x = <>
\ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/output.mjs new file mode 100644 index 0000000000000..c406bdcfe7dfb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-fragments/output.mjs @@ -0,0 +1,7 @@ +import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; +var x = _jsx(_Fragment, { + children: [ + _jsx("div", { + }) + ] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/input.js new file mode 100644 index 0000000000000..e0fab82c495bb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/input.js @@ -0,0 +1,5 @@ +var x = ( +
+ {[, ]} +
+); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/output.mjs new file mode 100644 index 0000000000000..1b19cdfcbdbfa --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-nonstatic-children/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx("div", { + children: [/*#__PURE__*/_jsx("span", {}, '0'), /*#__PURE__*/_jsx("span", {}, '1')] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/input.js new file mode 100644 index 0000000000000..fbe28fd373c63 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/input.js @@ -0,0 +1,6 @@ +var x = ( +
+ + {[, ]} +
+); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/output.mjs new file mode 100644 index 0000000000000..8d312c416fb10 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/handle-static-children/output.mjs @@ -0,0 +1,13 @@ +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; +var x = _jsxs("div", { + children: [ + _jsx("span", { + }), + [ + _jsx("span", { + }, "0"), + _jsx("span", { + }, "1") + ] + ] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/input.js new file mode 100644 index 0000000000000..1addddeb1500c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/input.js @@ -0,0 +1 @@ +var div =
test
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/output.mjs new file mode 100644 index 0000000000000..e74b251a647e6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/jsx-without-retainlines-option/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var div = /*#__PURE__*/_jsx("div", { + children: "test" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/input.js new file mode 100644 index 0000000000000..23d79e4ffb040 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/input.js @@ -0,0 +1,2 @@ +const props = {foo: true}; +var x = (
) diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/output.mjs new file mode 100644 index 0000000000000..3c78adf144f78 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/key-undefined-works/output.mjs @@ -0,0 +1,8 @@ +import { createElement as _createElement } from "react"; +const props = { + foo: true +}; + +var x = /*#__PURE__*/_createElement("div", { ...props, + key: undefined +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/input.js new file mode 100644 index 0000000000000..73a676f679ae8 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/input.js @@ -0,0 +1,2 @@ +/* @jsxImportSource foo*/ +
Hi
; \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/output.mjs new file mode 100644 index 0000000000000..7f8eea819da13 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/pragma-works-with-no-space-at-the-end/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "foo/jsx-runtime"; + +/* @jsxImportSource foo*/ +_jsx("div", { + children: "Hi" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/input.js new file mode 100644 index 0000000000000..29c24a7630abd --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/output.mjs new file mode 100644 index 0000000000000..1a28ef6db34ee --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-constructor-as-prop/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx(Component, { + constructor: "foo" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/input.js new file mode 100644 index 0000000000000..158b9a9dee080 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/output.mjs new file mode 100644 index 0000000000000..9aa4c36567204 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-deeper-js-namespacing/output.mjs @@ -0,0 +1,4 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx(Namespace.DeepNamespace.Component, {}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/input.js new file mode 100644 index 0000000000000..240f6d37ae059 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/input.js @@ -0,0 +1 @@ +
/> diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/output.mjs new file mode 100644 index 0000000000000..9d18ed3e73f09 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-elements-as-attributes/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("div", { + attr: /*#__PURE__*/_jsx("div", {}) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/blacklist.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/blacklist.js new file mode 100644 index 0000000000000..980df45724377 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/blacklist.js @@ -0,0 +1 @@ +React.createElement(Namespace.Component, null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/input.js new file mode 100644 index 0000000000000..6c104620cff46 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/output.mjs new file mode 100644 index 0000000000000..c0b46c8974982 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-js-namespacing/output.mjs @@ -0,0 +1,4 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx(Namespace.Component, {}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/input.js new file mode 100644 index 0000000000000..73b5cad5588dc --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/input.js @@ -0,0 +1,12 @@ +
+ < > + <> + Hello + world + + <> + Goodbye + world + + +
diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/output.mjs new file mode 100644 index 0000000000000..9ae2f3fed90bb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-allow-nested-fragments/output.mjs @@ -0,0 +1,20 @@ +import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("div", { + children: /*#__PURE__*/_jsxs(_Fragment, { + children: [/*#__PURE__*/_jsxs(_Fragment, { + children: [/*#__PURE__*/_jsx("span", { + children: "Hello" + }), /*#__PURE__*/_jsx("span", { + children: "world" + })] + }), /*#__PURE__*/_jsxs(_Fragment, { + children: [/*#__PURE__*/_jsx("span", { + children: "Goodbye" + }), /*#__PURE__*/_jsx("span", { + children: "world" + })] + })] + }) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js new file mode 100644 index 0000000000000..0304845f88c14 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js @@ -0,0 +1,15 @@ +var x =
+ +
; + +var x =
+ {props.children} +
; + +var x = + {props.children} +; + +var x = + +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/output.mjs new file mode 100644 index 0000000000000..99f063b7fdd63 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-avoid-wrapping-in-extra-parens-if-not-needed/output.mjs @@ -0,0 +1,17 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx("div", { + children: /*#__PURE__*/_jsx(Component, {}) +}); + +var x = /*#__PURE__*/_jsx("div", { + children: props.children +}); + +var x = /*#__PURE__*/_jsx(Composite, { + children: props.children +}); + +var x = /*#__PURE__*/_jsx(Composite, { + children: /*#__PURE__*/_jsx(Composite2, {}) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/input.js new file mode 100644 index 0000000000000..b6d801a6bc268 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/input.js @@ -0,0 +1 @@ +var x =
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/output.mjs new file mode 100644 index 0000000000000..dac95436f8e96 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-tags/output.mjs @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx("div", {}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/input.js new file mode 100644 index 0000000000000..42c927f15a90f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/input.js @@ -0,0 +1 @@ +var x =
text
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/output.mjs new file mode 100644 index 0000000000000..7791e67597335 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-convert-simple-text/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx("div", { + children: "text" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/input.js new file mode 100644 index 0000000000000..6a05e108dc66d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/input.js @@ -0,0 +1 @@ +
{...children}
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/options.json new file mode 100644 index 0000000000000..bcb773e34314c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Spread children are not supported in React." +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.mjs new file mode 100644 index 0000000000000..3cd05d5f9f2f1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.mjs @@ -0,0 +1 @@ +React.createElement("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.stderr new file mode 100644 index 0000000000000..f99204e6a3295 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-spread-children/output.stderr @@ -0,0 +1,6 @@ +error: Spread children are not supported in React. + --> input.js:1:6 + | +1 |
{...children}
; + | ^^^^^^^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/input.js new file mode 100644 index 0000000000000..50df717c1267f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/options.json new file mode 100644 index 0000000000000..746037e9f505a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning." +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.mjs new file mode 100644 index 0000000000000..9df43c229dcd4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.mjs @@ -0,0 +1 @@ +React.createElement("Namespace:Component", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.stderr new file mode 100644 index 0000000000000..b7b58439ba863 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-disallow-xml-namespacing/output.stderr @@ -0,0 +1,6 @@ +error: JSX Namespace is disabled by default because react does not support it yet. You can specify jsc.transform.react.throwIfNamespace to false to override default behavior + --> input.js:1:2 + | +1 | ; + | ^^^^^^^^^^^^^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/input.js new file mode 100644 index 0000000000000..addae3b9f807e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/input.js @@ -0,0 +1,3 @@ +
; +
; +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/options.json new file mode 100644 index 0000000000000..4b7bffc1ad7af --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/options.json @@ -0,0 +1,4 @@ +{ + "BABEL_8_BREAKING": true, + "runtime": "automatic" +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/output.mjs new file mode 100644 index 0000000000000..c15d6ffc234cf --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxattribute/output.mjs @@ -0,0 +1,10 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("div", { + id: "w\xf4w" +}); +_jsx("div", { + id: "w" +}); +_jsx("div", { + id: "w < w" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/input.js new file mode 100644 index 0000000000000..2104766109bb5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/input.js @@ -0,0 +1,12 @@ +
wow
; +
wôw
; + +
w & w
; +
w & w
; + +
w   w
; +
this should not parse as unicode: \u00a0
; +
this should parse as nbsp:  
; +
this should parse as unicode: {'\u00a0 '}
; + +
w < w
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/options.json new file mode 100644 index 0000000000000..7921ce7ea2c76 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/options.json @@ -0,0 +1 @@ +{ "BABEL_8_BREAKING": true, "runtime": "automatic" } diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/output.mjs new file mode 100644 index 0000000000000..ee681cec070f9 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-escape-xhtml-jsxtext/output.mjs @@ -0,0 +1,31 @@ +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; +_jsx("div", { + children: "wow" +}); +_jsx("div", { + children: "w\xf4w" +}); +_jsx("div", { + children: "w & w" +}); +_jsx("div", { + children: "w & w" +}); +_jsx("div", { + children: "w \xa0 w" +}); +_jsx("div", { + children: "this should not parse as unicode: \\u00a0" +}); +_jsx("div", { + children: "this should parse as nbsp: \xa0 " +}); +_jsxs("div", { + children: [ + "this should parse as unicode: ", + "\xa0\xa0" + ] +}); +_jsx("div", { + children: "w < w" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/input.js new file mode 100644 index 0000000000000..e179659161696 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/input.js @@ -0,0 +1,11 @@ +var HelloMessage = React.createClass({ + render: function() { + return
Hello {this.props.name}
; + } +}); + +React.render( + Sebastian + +} />, mountNode); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/output.mjs new file mode 100644 index 0000000000000..b5dd9a99c6d9b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-attributed-elements/output.mjs @@ -0,0 +1,14 @@ +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; +var HelloMessage = React.createClass({ + render: function () { + return /*#__PURE__*/_jsxs("div", { + children: ["Hello ", this.props.name] + }); + }, + displayName: "HelloMessage", +}); +React.render( /*#__PURE__*/_jsx(HelloMessage, { + name: /*#__PURE__*/_jsx("span", { + children: "Sebastian" + }) +}), mountNode); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/input.js new file mode 100644 index 0000000000000..4d5e8fb63c737 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/input.js @@ -0,0 +1 @@ +testing; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/output.mjs new file mode 100644 index 0000000000000..7c7ac7d56bbfb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-handle-has-own-property-correctly/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("hasOwnProperty", { + children: "testing" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/input.js new file mode 100644 index 0000000000000..fa82e1cd08cb7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/input.js @@ -0,0 +1,5 @@ +var x =
+

+ {foo}
{bar}
+
+
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/output.mjs new file mode 100644 index 0000000000000..75f292fb3be5d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-have-correct-comma-in-nested-children/output.mjs @@ -0,0 +1,9 @@ +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsxs("div", { + children: [/*#__PURE__*/_jsx("div", { + children: /*#__PURE__*/_jsx("br", {}) + }), /*#__PURE__*/_jsxs(Component, { + children: [foo, /*#__PURE__*/_jsx("br", {}), bar] + }), /*#__PURE__*/_jsx("br", {})] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/input.js new file mode 100644 index 0000000000000..92541bbb3554e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/input.js @@ -0,0 +1,16 @@ +var x = +
+
diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/output.mjs new file mode 100644 index 0000000000000..a7dc56ee31959 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-insert-commas-after-expressions-before-whitespace/output.mjs @@ -0,0 +1,8 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx("div", { + attr1: "foo" + "bar", + attr2: "foo" + "bar" + "baz" + "bug", + attr3: "foo" + "bar" + "baz" + "bug", + attr4: "baz" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/input.js new file mode 100644 index 0000000000000..44d58a60fecf5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/input.js @@ -0,0 +1 @@ +var e = ; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.mjs new file mode 100644 index 0000000000000..210066ec1feb2 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.mjs @@ -0,0 +1,10 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var e = /*#__PURE__*/_jsx(F, { + aaa: true, + new: true, + const: true, + var: true, + default: true, + "foo-bar": true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.stderr new file mode 100644 index 0000000000000..23ed73ac85f02 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-add-quotes-to-identifier-names/output.stderr @@ -0,0 +1,12 @@ +error: Expected ,, got : + --> output.js:8:12 + | +8 | foo-bar: true + | ^ + +error: Expression expected + --> output.js:8:8 + | +8 | foo-bar: true + | ^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/input.js new file mode 100644 index 0000000000000..acecaa910f205 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.mjs new file mode 100644 index 0000000000000..198de8a241581 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.mjs @@ -0,0 +1,7 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("button", { + "data-value": "a value\n with\nnewlines\n and spaces", + children: "Button" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.stderr new file mode 100644 index 0000000000000..1b5413c15418f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-mangle-expressioncontainer-attribute-values/output.stderr @@ -0,0 +1,12 @@ +error: Expected ,, got : + --> output.js:3:15 + | +3 | data-value: "a value\n with\nnewlines\n and spaces", + | ^ + +error: Expression expected + --> output.js:3:9 + | +3 | data-value: "a value\n with\nnewlines\n and spaces", + | ^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js new file mode 100644 index 0000000000000..38d8acbab5451 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js @@ -0,0 +1 @@ +
 
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.mjs new file mode 100644 index 0000000000000..86f0e9eaeceaa --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("div", { + children: "\xA0 " +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/input.js new file mode 100644 index 0000000000000..0e05a7be8d236 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/input.js @@ -0,0 +1 @@ +
 
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/output.mjs new file mode 100644 index 0000000000000..6a0ea18e16ccf --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-not-strip-tags-with-a-single-child-of-nbsp/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("div", { + children: "\xA0" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/input.js new file mode 100644 index 0000000000000..8b1943e8f6836 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/input.js @@ -0,0 +1,10 @@ +var x = ( +
+ +
+); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/output.mjs new file mode 100644 index 0000000000000..7b0923e096497 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-comments-between-props/output.mjs @@ -0,0 +1,11 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx("div", { + /* a multi-line + comment */ + attr1: "foo", + children: /*#__PURE__*/_jsx("span", { + // a double-slash comment + attr2: "bar" + }) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/input.js new file mode 100644 index 0000000000000..336592502a4bb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/input.js @@ -0,0 +1,7 @@ +var x = ( +
+
+
+
+
+); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/output.mjs new file mode 100644 index 0000000000000..30dbc55bd6b85 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-keys/output.mjs @@ -0,0 +1,7 @@ +import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsxs("div", { + children: [/*#__PURE__*/_jsx("div", {}, "1"), /*#__PURE__*/_jsx("div", { + meow: "wolf" + }, "2"), /*#__PURE__*/_jsx("div", {}, "3")] +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/input.js new file mode 100644 index 0000000000000..e0b99b87da511 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/input.js @@ -0,0 +1,2 @@ +var foo = null; +var x =
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/output.mjs new file mode 100644 index 0000000000000..075d0ab77a090 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-properly-handle-null-prop-spread/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +var foo = null; + +var x = /*#__PURE__*/_jsx("div", { ...foo +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/input.js new file mode 100644 index 0000000000000..c794650e94a66 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.mjs new file mode 100644 index 0000000000000..6644401db9a05 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.mjs @@ -0,0 +1,7 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("button", { + "data-value": "a value", + children: "Button" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.stderr new file mode 100644 index 0000000000000..a6cf99d99cdc5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-quote-jsx-attributes/output.stderr @@ -0,0 +1,12 @@ +error: Expected ,, got : + --> output.js:3:15 + | +3 | data-value: "a value", + | ^ + +error: Expression expected + --> output.js:3:9 + | +3 | data-value: "a value", + | ^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/input.js new file mode 100644 index 0000000000000..48d051a95141b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/options.json new file mode 100644 index 0000000000000..fbba93f504b44 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/options.json @@ -0,0 +1 @@ +{"throwIfNamespace":false,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/output.mjs new file mode 100644 index 0000000000000..a1da85af076eb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-support-xml-namespaces-if-flag/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("f:image", { + "n:attr": true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/input.js new file mode 100644 index 0000000000000..4888b2b70588b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/options.json b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/options.json new file mode 100644 index 0000000000000..fb0c186897651 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/options.json @@ -0,0 +1 @@ +{"throws":"Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning.","throwIfNamespace":true,"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.mjs new file mode 100644 index 0000000000000..a6e5deaac6147 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.mjs @@ -0,0 +1,3 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx("f:image", { +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.stderr new file mode 100644 index 0000000000000..cd122c303ec34 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-throw-error-namespaces-if-not-flag/output.stderr @@ -0,0 +1,6 @@ +error: JSX Namespace is disabled by default because react does not support it yet. You can specify jsc.transform.react.throwIfNamespace to false to override default behavior + --> input.js:1:2 + | +1 | ; + | ^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/input.js new file mode 100644 index 0000000000000..1cb54dd68816b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/output.mjs new file mode 100644 index 0000000000000..2ea1f6082acaf --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-transform-known-hyphenated-tags/output.mjs @@ -0,0 +1,4 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx("font-face", {}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/input.js new file mode 100644 index 0000000000000..927a4174b6edc --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/input.js @@ -0,0 +1,3 @@ +var x = ( +
+); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/output.mjs new file mode 100644 index 0000000000000..312d7cfc2a8a5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-createElement-when-key-comes-after-spread/output.mjs @@ -0,0 +1,6 @@ +import { createElement as _createElement } from "react"; + +var x = /*#__PURE__*/_createElement("div", { ...props, + key: "1", + foo: "bar" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/input.js new file mode 100644 index 0000000000000..650a8354fe4aa --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/input.js @@ -0,0 +1,3 @@ +var x = ( +
+); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/output.mjs new file mode 100644 index 0000000000000..5e449874dd87f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/should-use-jsx-when-key-comes-before-spread/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var x = /*#__PURE__*/_jsx("div", { ...props, + foo: "bar" +}, "1"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/input.js new file mode 100644 index 0000000000000..f65588acf7b45 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/input.js @@ -0,0 +1 @@ +var div = test; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/output.mjs new file mode 100644 index 0000000000000..eb3f1f63a15ba --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/this-tag-name/output.mjs @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +var div = /*#__PURE__*/_jsx(this.foo, { + children: "test" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/input.js new file mode 100644 index 0000000000000..e4bc0b7035e29 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/input.js @@ -0,0 +1,5 @@ +class MobileHomeActivityTaskPriorityIcon extends React.PureComponent { + render() { + return  {this.props.value} ; + } +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/output.mjs new file mode 100644 index 0000000000000..65cfda12fc6ad --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/weird-symbols/output.mjs @@ -0,0 +1,10 @@ +import { jsxs as _jsxs } from "react/jsx-runtime"; + +class MobileHomeActivityTaskPriorityIcon extends React.PureComponent { + render() { + return /*#__PURE__*/_jsxs(Text, { + children: ["\xA0", this.props.value, "\xA0"] + }); + } + +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/input.js new file mode 100644 index 0000000000000..ce7fb5b60f9f7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/input.js @@ -0,0 +1 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/output.mjs new file mode 100644 index 0000000000000..cc9c33d709a1a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-last-spread-attributes/output.mjs @@ -0,0 +1,8 @@ +import { jsx as _jsx } from "react/jsx-runtime"; + +/*#__PURE__*/ +_jsx(Component, { + y: 2, + z: true, + ...x +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/input.js new file mode 100644 index 0000000000000..919adaebb41e2 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/input.js @@ -0,0 +1 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/output.mjs new file mode 100644 index 0000000000000..d12860cb8f177 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react-automatic/wraps-props-in-react-spread-for-middle-spread-attributes/output.mjs @@ -0,0 +1,6 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +_jsx(Component, { + y: 2, + ...x, + z: true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/input.js new file mode 100644 index 0000000000000..2c800f155830a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/input.js @@ -0,0 +1,3 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/output.js new file mode 100644 index 0000000000000..bfd6ae7c13f90 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.adds-appropriate-newlines-when-using-spread-attribute-babel-7/output.js @@ -0,0 +1,4 @@ +/*#__PURE__*/ +React.createElement(Component, babelHelpers.extends({}, props, { + sound: "moo" +})); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/input.js new file mode 100644 index 0000000000000..91f343d34974b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/input.js @@ -0,0 +1,7 @@ +var foo = function () { + return () => ; +}; + +var bar = function () { + return () => ; +}; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/output.js new file mode 100644 index 0000000000000..6ee7dcc94f2e1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.arrow-functions/output.js @@ -0,0 +1,15 @@ +var foo = function () { + var _this = this; + + return function () { + return /*#__PURE__*/React.createElement(_this, null); + }; +}; + +var bar = function () { + var _this2 = this; + + return function () { + return /*#__PURE__*/React.createElement(_this2.foo, null); + }; +}; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/output.js new file mode 100644 index 0000000000000..5d6aec1438187 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.assignment-babel-7/output.js @@ -0,0 +1,3 @@ +var div = /*#__PURE__*/React.createElement(Component, babelHelpers.extends({}, props, { + foo: "bar" +})); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/input.js new file mode 100644 index 0000000000000..6dbb876ac43d6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/input.js @@ -0,0 +1,11 @@ +; + +; + +; + +; + +; + +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/output.js new file mode 100644 index 0000000000000..8d4d99fab9c08 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.avoids-spread-babel-7/output.js @@ -0,0 +1,32 @@ +/*#__PURE__*/ +React.createElement(E, babelHelpers.extends({}, props, { + last: true +})); + +/*#__PURE__*/ +React.createElement(E, babelHelpers.extends({ + first: true +}, props)); + +/*#__PURE__*/ +React.createElement(E, babelHelpers.extends({}, pre, suf)); + +/*#__PURE__*/ +React.createElement(E, babelHelpers.extends({ + first: true +}, pre, { + mid: true +}, suf)); + +/*#__PURE__*/ +React.createElement(E, babelHelpers.extends({}, pre, { + mid: true +}, suf, { + last: true +})); + +/*#__PURE__*/ +React.createElement(E, babelHelpers.extends({}, pre, { + mid1: true, + mid2: true +}, suf)); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/input.js new file mode 100644 index 0000000000000..1addddeb1500c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/input.js @@ -0,0 +1 @@ +var div =
test
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/options.json new file mode 100644 index 0000000000000..97925bbcb61be --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/options.json @@ -0,0 +1,3 @@ +{ + "retainLines": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/output.js new file mode 100644 index 0000000000000..7a1aee57ef3e1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.jsx-with-retainlines-option/output.js @@ -0,0 +1 @@ +var div = /*#__PURE__*/React.createElement("div", null, "test"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/input.js new file mode 100644 index 0000000000000..87ccec557d36b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/input.js @@ -0,0 +1,17 @@ +class App extends React.Component { + render() { + const navbarHeader =
+ + + +
; + + return
+ +
; + } +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/options.json new file mode 100644 index 0000000000000..35f1579a971d3 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/options.json @@ -0,0 +1,8 @@ +{ + "plugins": [ + "external-helpers", + "transform-react-constant-elements", + "transform-classes", + "syntax-jsx" + ] +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/output.js new file mode 100644 index 0000000000000..a9b90e8bc5d05 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.optimisation.react.constant-elements/output.js @@ -0,0 +1,37 @@ +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; } + +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +var _ref =
+ + + +
; + +let App = /*#__PURE__*/function (_React$Component) { + "use strict"; + + babelHelpers.inherits(App, _React$Component); + + var _super = _createSuper(App); + + function App() { + babelHelpers.classCallCheck(this, App); + return _super.apply(this, arguments); + } + + babelHelpers.createClass(App, [{ + key: "render", + value: function render() { + const navbarHeader = _ref; + return
+ +
; + } + }]); + return App; +}(React.Component); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/input.js new file mode 100644 index 0000000000000..a47734ffb31a4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/input.js @@ -0,0 +1 @@ +var es3 = ; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/output.js new file mode 100644 index 0000000000000..e67cc4ba42d59 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-add-quotes-es3/output.js @@ -0,0 +1,8 @@ +var es3 = /*#__PURE__*/React.createElement(F, { + aaa: true, + "new": true, + "const": true, + "var": true, + "default": true, + "foo-bar": true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-properly-handle-comments-adjacent-to-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.should-properly-handle-comments-adjacent-to-children/input.js new file mode 100644 index 0000000000000..412984681eea7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-properly-handle-comments-adjacent-to-children/input.js @@ -0,0 +1,13 @@ +var x = ( +
+ {/* A comment at the beginning */} + {/* A second comment at the beginning */} + + {/* A nested comment */} + + {/* A sandwiched comment */} +
+ {/* A comment at the end */} + {/* A second comment at the end */} +
+); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/input.js new file mode 100644 index 0000000000000..7925155a5faff --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/input.js @@ -0,0 +1,3 @@ +/** @jsxRuntime classic */ + +var div =
test
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/options.json new file mode 100644 index 0000000000000..3ff61a7ea5fbe --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/options.json @@ -0,0 +1 @@ +{"throws":"importSource cannot be set when runtime is classic.","runtime":"automatic","importSource":"foo"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/output.stderr new file mode 100644 index 0000000000000..1f45761cc515f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-is-set/output.stderr @@ -0,0 +1 @@ +importSource cannot be set when runtime is classic. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/input.js new file mode 100644 index 0000000000000..8d4d4fb301751 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/input.js @@ -0,0 +1,4 @@ +/** @jsxRuntime classic */ +/** @jsxImportSource foo */ + +var div =
test
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/options.json new file mode 100644 index 0000000000000..a25dd07e9124e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/options.json @@ -0,0 +1,3 @@ +{ + "throws": "importSource cannot be set when runtime is classic." +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/output.stderr new file mode 100644 index 0000000000000..1f45761cc515f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.should-warn-when-importSource-pragma-is-set/output.stderr @@ -0,0 +1 @@ +importSource cannot be set when runtime is classic. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/input.js new file mode 100644 index 0000000000000..4e9432dfa388b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/input.js @@ -0,0 +1,2 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/output.js new file mode 100644 index 0000000000000..b6fe512bfda89 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-first-spread-attributes-babel-7/output.js @@ -0,0 +1,5 @@ +/*#__PURE__*/ +React.createElement(Component, babelHelpers.extends({}, x, { + y: 2, + z: true +})); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/input.js new file mode 100644 index 0000000000000..ce7fb5b60f9f7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/input.js @@ -0,0 +1 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/output.js new file mode 100644 index 0000000000000..c1c22b02c9da6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-last-spread-attributes-babel-7/output.js @@ -0,0 +1,5 @@ +/*#__PURE__*/ +React.createElement(Component, babelHelpers.extends({ + y: 2, + z: true +}, x)); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/input.js new file mode 100644 index 0000000000000..919adaebb41e2 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/input.js @@ -0,0 +1 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/output.js new file mode 100644 index 0000000000000..7d99b1a29c3d3 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/.wraps-props-in-react-spread-for-middle-spread-attributes-babel-7/output.js @@ -0,0 +1,6 @@ +/*#__PURE__*/ +React.createElement(Component, babelHelpers.extends({ + y: 2 +}, x, { + z: true +})); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/input.js new file mode 100644 index 0000000000000..2c800f155830a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/input.js @@ -0,0 +1,3 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/output.js new file mode 100644 index 0000000000000..b07ab7c68f78f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/adds-appropriate-newlines-when-using-spread-attribute/output.js @@ -0,0 +1,4 @@ +/*#__PURE__*/ +React.createElement(Component, { ...props, + sound: "moo" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/assignment/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/assignment/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/assignment/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/assignment/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/assignment/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/assignment/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/assignment/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/assignment/output.js new file mode 100644 index 0000000000000..0c5b1f75b0737 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/assignment/output.js @@ -0,0 +1,3 @@ +var div = /*#__PURE__*/React.createElement(Component, { ...props, + foo: "bar" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/input.js new file mode 100644 index 0000000000000..f3f30af044087 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/input.js @@ -0,0 +1,13 @@ +var x = +
+ foo + {"bar"} + baz +
+ buz + bang +
+ qux + {null} + quack +
diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/output.js new file mode 100644 index 0000000000000..d3772171e0659 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/concatenates-adjacent-string-literals/output.js @@ -0,0 +1 @@ +var x = /*#__PURE__*/React.createElement("div", null, "foo", "bar", "baz", /*#__PURE__*/React.createElement("div", null, "buz bang"), "qux", null, "quack"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/input.mjs b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/input.mjs new file mode 100644 index 0000000000000..ebd66ec03e0ad --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/input.mjs @@ -0,0 +1,10 @@ +var x = ( + <> +
+
+
+
+
+
+ +); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/output.mjs new file mode 100644 index 0000000000000..76b2c3a6a38fb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self-babel-7/output.mjs @@ -0,0 +1,10 @@ +var x = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + key: "1" +}), /*#__PURE__*/React.createElement("div", { + key: "2", + meow: "wolf" +}), /*#__PURE__*/React.createElement("div", { + key: "3" +}), /*#__PURE__*/React.createElement("div", babelHelpers.extends({}, props, { + key: "4" +})))); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/input.mjs b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/input.mjs new file mode 100644 index 0000000000000..ebd66ec03e0ad --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/input.mjs @@ -0,0 +1,10 @@ +var x = ( + <> +
+
+
+
+
+
+ +); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/output.mjs new file mode 100644 index 0000000000000..3466065a8d742 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/does-not-add-source-self/output.mjs @@ -0,0 +1,10 @@ +var x = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", { + key: "1" +}), /*#__PURE__*/React.createElement("div", { + key: "2", + meow: "wolf" +}), /*#__PURE__*/React.createElement("div", { + key: "3" +}), /*#__PURE__*/React.createElement("div", { ...props, + key: "4" +}))); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/input.js new file mode 100644 index 0000000000000..c8da550222839 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/input.js @@ -0,0 +1,4 @@ + + To get started, edit index.ios.js!!!{"\n"} + Press Cmd+R to reload + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/output.js new file mode 100644 index 0000000000000..30d36264bde90 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/dont-coerce-expression-containers/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement(Text, null, "To get started, edit index.ios.js!!!", "\n", "Press Cmd+R to reload"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/input.js new file mode 100644 index 0000000000000..8741892b4cef0 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/input.js @@ -0,0 +1,7 @@ +

text

; + +

text

; + +

text

; + +

text

; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/output.js new file mode 100644 index 0000000000000..341892d567dd1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/duplicate-props/output.js @@ -0,0 +1,23 @@ +/*#__PURE__*/ +React.createElement("p", { + prop: true, + prop: true +}, "text"); + +/*#__PURE__*/ +React.createElement("p", { + prop, + prop +}, "text"); + +/*#__PURE__*/ +React.createElement("p", { + prop: true, + prop +}, "text"); + +/*#__PURE__*/ +React.createElement("p", { + prop, + prop: true +}, "text"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/input.js new file mode 100644 index 0000000000000..7cf92a69c6056 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/input.js @@ -0,0 +1,7 @@ +

text

; + +
{contents}
; + +; + +
{items}
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/output.js new file mode 100644 index 0000000000000..25b234ea3b584 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/flattens-spread/output.js @@ -0,0 +1,17 @@ +/*#__PURE__*/ +React.createElement("p", props, "text"); + +/*#__PURE__*/ +React.createElement("div", props, contents); + +/*#__PURE__*/ +React.createElement("img", { + alt: "", + src, + title +}); + +/*#__PURE__*/ +React.createElement("blockquote", { + cite +}, items); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/input.js new file mode 100644 index 0000000000000..822df7957d342 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/input.js @@ -0,0 +1,8 @@ +/** @jsx dom */ + +; + +var profile =
+ +

{[user.firstName, user.lastName].join(" ")}

+
; \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/options.json new file mode 100644 index 0000000000000..cdae37bdfeb15 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/options.json @@ -0,0 +1 @@ +{"pragma":"foo.bar","runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/output.js new file mode 100644 index 0000000000000..1e933b068077a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment-if-jsx-pragma-option-set/output.js @@ -0,0 +1,6 @@ +/** @jsx dom */ +dom(Foo, null); +var profile = dom("div", null, dom("img", { + src: "avatar.png", + className: "profile" +}), dom("h3", null, [user.firstName, user.lastName].join(" "))); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/input.js new file mode 100644 index 0000000000000..822df7957d342 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/input.js @@ -0,0 +1,8 @@ +/** @jsx dom */ + +; + +var profile =
+ +

{[user.firstName, user.lastName].join(" ")}

+
; \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/output.js new file mode 100644 index 0000000000000..1e933b068077a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-comment/output.js @@ -0,0 +1,6 @@ +/** @jsx dom */ +dom(Foo, null); +var profile = dom("div", null, dom("img", { + src: "avatar.png", + className: "profile" +}), dom("h3", null, [user.firstName, user.lastName].join(" "))); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/input.js new file mode 100644 index 0000000000000..5b144eb3ee80e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/input.js @@ -0,0 +1,6 @@ +; + +var profile =
+ +

{[user.firstName, user.lastName].join(" ")}

+
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/options.json new file mode 100644 index 0000000000000..3169fdae054d0 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/options.json @@ -0,0 +1 @@ +{"pragma":"dom","runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/output.js new file mode 100644 index 0000000000000..f74131189c025 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/honor-custom-jsx-pragma-option/output.js @@ -0,0 +1,5 @@ +dom(Foo, null); +var profile = dom("div", null, dom("img", { + src: "avatar.png", + className: "profile" +}), dom("h3", null, [user.firstName, user.lastName].join(" "))); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/input.js new file mode 100644 index 0000000000000..1addddeb1500c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/input.js @@ -0,0 +1 @@ +var div =
test
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/output.js new file mode 100644 index 0000000000000..7a1aee57ef3e1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/jsx-without-retainlines-option/output.js @@ -0,0 +1 @@ +var div = /*#__PURE__*/React.createElement("div", null, "test"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/input.js new file mode 100644 index 0000000000000..1a449a84872c5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/input.js @@ -0,0 +1,2 @@ +/* @jsx foo*/ +
Hi
; \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/output.js new file mode 100644 index 0000000000000..31b6fe25a4834 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/pragma-works-with-no-space-at-the-end/output.js @@ -0,0 +1,2 @@ +/* @jsx foo*/ +foo("div", null, "Hi"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/input.js new file mode 100644 index 0000000000000..29c24a7630abd --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/output.js new file mode 100644 index 0000000000000..68157cf0a134d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-constructor-as-prop/output.js @@ -0,0 +1,4 @@ +/*#__PURE__*/ +React.createElement(Component, { + constructor: "foo" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/input.js new file mode 100644 index 0000000000000..158b9a9dee080 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/output.js new file mode 100644 index 0000000000000..51e8fd555561e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-deeper-js-namespacing/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement(Namespace.DeepNamespace.Component, null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/input.js new file mode 100644 index 0000000000000..240f6d37ae059 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/input.js @@ -0,0 +1 @@ +
/> diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/output.js new file mode 100644 index 0000000000000..06428ad3807dd --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-elements-as-attributes/output.js @@ -0,0 +1,4 @@ +/*#__PURE__*/ +React.createElement("div", { + attr: /*#__PURE__*/React.createElement("div", null) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/blacklist.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/blacklist.js new file mode 100644 index 0000000000000..980df45724377 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/blacklist.js @@ -0,0 +1 @@ +React.createElement(Namespace.Component, null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/input.js new file mode 100644 index 0000000000000..6c104620cff46 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/output.js new file mode 100644 index 0000000000000..870cb0a6db33f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-js-namespacing/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement(Namespace.Component, null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/input.js new file mode 100644 index 0000000000000..73b5cad5588dc --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/input.js @@ -0,0 +1,12 @@ +
+ < > + <> + Hello + world + + <> + Goodbye + world + + +
diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/output.js new file mode 100644 index 0000000000000..2ac191c03c5ab --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-nested-fragments/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement("div", null, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Hello"), /*#__PURE__*/React.createElement("span", null, "world")), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, "Goodbye"), /*#__PURE__*/React.createElement("span", null, "world")))); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/input.js new file mode 100644 index 0000000000000..4da208d348006 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/input.js @@ -0,0 +1,3 @@ +/** @jsx dom */ + +
no fragment is used
diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/output.js new file mode 100644 index 0000000000000..bac7ff4042d44 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-no-pragmafrag-if-frag-unused/output.js @@ -0,0 +1,2 @@ +/** @jsx dom */ +dom("div", null, "no fragment is used"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/input.js new file mode 100644 index 0000000000000..3f029e60c7292 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/input.js @@ -0,0 +1,4 @@ +/** @jsx dom */ +/** @jsxFrag DomFrag */ + +<> diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/output.js new file mode 100644 index 0000000000000..d5a2a9bac23c0 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-allow-pragmafrag-and-frag/output.js @@ -0,0 +1,4 @@ +/** @jsx dom */ + +/** @jsxFrag DomFrag */ +dom(DomFrag, null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js new file mode 100644 index 0000000000000..0304845f88c14 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/input.js @@ -0,0 +1,15 @@ +var x =
+ +
; + +var x =
+ {props.children} +
; + +var x = + {props.children} +; + +var x = + +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/output.js new file mode 100644 index 0000000000000..98d7262c3a782 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-avoid-wrapping-in-extra-parens-if-not-needed/output.js @@ -0,0 +1,4 @@ +var x = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Component, null)); +var x = /*#__PURE__*/React.createElement("div", null, props.children); +var x = /*#__PURE__*/React.createElement(Composite, null, props.children); +var x = /*#__PURE__*/React.createElement(Composite, null, /*#__PURE__*/React.createElement(Composite2, null)); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/input.js new file mode 100644 index 0000000000000..b6d801a6bc268 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/input.js @@ -0,0 +1 @@ +var x =
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/output.js new file mode 100644 index 0000000000000..2973c9e9fd148 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-tags/output.js @@ -0,0 +1 @@ +var x = /*#__PURE__*/React.createElement("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/input.js new file mode 100644 index 0000000000000..42c927f15a90f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/input.js @@ -0,0 +1 @@ +var x =
text
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/output.js new file mode 100644 index 0000000000000..afcefb65f15de --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-convert-simple-text/output.js @@ -0,0 +1 @@ +var x = /*#__PURE__*/React.createElement("div", null, "text"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/input.js new file mode 100644 index 0000000000000..6a05e108dc66d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/input.js @@ -0,0 +1 @@ +
{...children}
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/options.json new file mode 100644 index 0000000000000..bcb773e34314c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Spread children are not supported in React." +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.mjs new file mode 100644 index 0000000000000..3cd05d5f9f2f1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.mjs @@ -0,0 +1 @@ +React.createElement("div", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.stderr new file mode 100644 index 0000000000000..f99204e6a3295 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-spread-children/output.stderr @@ -0,0 +1,6 @@ +error: Spread children are not supported in React. + --> input.js:1:6 + | +1 |
{...children}
; + | ^^^^^^^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/input.js new file mode 100644 index 0000000000000..50df717c1267f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/options.json new file mode 100644 index 0000000000000..746037e9f505a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning." +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.mjs new file mode 100644 index 0000000000000..9df43c229dcd4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.mjs @@ -0,0 +1 @@ +React.createElement("Namespace:Component", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.stderr new file mode 100644 index 0000000000000..b7b58439ba863 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-disallow-xml-namespacing/output.stderr @@ -0,0 +1,6 @@ +error: JSX Namespace is disabled by default because react does not support it yet. You can specify jsc.transform.react.throwIfNamespace to false to override default behavior + --> input.js:1:2 + | +1 | ; + | ^^^^^^^^^^^^^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/input.js new file mode 100644 index 0000000000000..addae3b9f807e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/input.js @@ -0,0 +1,3 @@ +
; +
; +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/output.js new file mode 100644 index 0000000000000..06ba91769554b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute-babel-7/output.js @@ -0,0 +1,9 @@ +React.createElement("div", { + id: "w\xf4w" +}); +React.createElement("div", { + id: "w" +}); +React.createElement("div", { + id: "w < w" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/input.js new file mode 100644 index 0000000000000..addae3b9f807e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/input.js @@ -0,0 +1,3 @@ +
; +
; +
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/output.js new file mode 100644 index 0000000000000..06ba91769554b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxattribute/output.js @@ -0,0 +1,9 @@ +React.createElement("div", { + id: "w\xf4w" +}); +React.createElement("div", { + id: "w" +}); +React.createElement("div", { + id: "w < w" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/input.js new file mode 100644 index 0000000000000..2104766109bb5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/input.js @@ -0,0 +1,12 @@ +
wow
; +
wôw
; + +
w & w
; +
w & w
; + +
w   w
; +
this should not parse as unicode: \u00a0
; +
this should parse as nbsp:  
; +
this should parse as unicode: {'\u00a0 '}
; + +
w < w
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/options.json new file mode 100644 index 0000000000000..29a3f0e841678 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": false +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/output.js new file mode 100644 index 0000000000000..64f33c72531ab --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext-babel-7/output.js @@ -0,0 +1,26 @@ +/*#__PURE__*/ +React.createElement("div", null, "wow"); + +/*#__PURE__*/ +React.createElement("div", null, "w\xF4w"); + +/*#__PURE__*/ +React.createElement("div", null, "w & w"); + +/*#__PURE__*/ +React.createElement("div", null, "w & w"); + +/*#__PURE__*/ +React.createElement("div", null, "w \xA0 w"); + +/*#__PURE__*/ +React.createElement("div", null, "this should not parse as unicode: \\u00a0"); + +/*#__PURE__*/ +React.createElement("div", null, "this should parse as nbsp: \xA0 "); + +/*#__PURE__*/ +React.createElement("div", null, "this should parse as unicode: ", '\u00a0 '); + +/*#__PURE__*/ +React.createElement("div", null, "w < w"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/input.js new file mode 100644 index 0000000000000..2104766109bb5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/input.js @@ -0,0 +1,12 @@ +
wow
; +
wôw
; + +
w & w
; +
w & w
; + +
w   w
; +
this should not parse as unicode: \u00a0
; +
this should parse as nbsp:  
; +
this should parse as unicode: {'\u00a0 '}
; + +
w < w
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/output.js new file mode 100644 index 0000000000000..1edc53edeb27f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-escape-xhtml-jsxtext/output.js @@ -0,0 +1,26 @@ +/*#__PURE__*/ +React.createElement("div", null, "wow"); + +/*#__PURE__*/ +React.createElement("div", null, "wôw"); + +/*#__PURE__*/ +React.createElement("div", null, "w & w"); + +/*#__PURE__*/ +React.createElement("div", null, "w & w"); + +/*#__PURE__*/ +React.createElement("div", null, "w \xA0 w"); + +/*#__PURE__*/ +React.createElement("div", null, "this should not parse as unicode: \\u00a0"); + +/*#__PURE__*/ +React.createElement("div", null, "this should parse as nbsp: \xA0 "); + +/*#__PURE__*/ +React.createElement("div", null, "this should parse as unicode: ", '\u00a0 '); + +/*#__PURE__*/ +React.createElement("div", null, "w < w"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/input.js new file mode 100644 index 0000000000000..e179659161696 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/input.js @@ -0,0 +1,11 @@ +var HelloMessage = React.createClass({ + render: function() { + return
Hello {this.props.name}
; + } +}); + +React.render( + Sebastian + +} />, mountNode); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/output.js new file mode 100644 index 0000000000000..e958d0cd57741 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-attributed-elements/output.js @@ -0,0 +1,9 @@ +var HelloMessage = React.createClass({ + render: function() { + return React.createElement("div", null, "Hello ", this.props.name); + }, + displayName: "HelloMessage" +}); +React.render(React.createElement(HelloMessage, { + name: React.createElement("span", null, "Sebastian") +}), mountNode); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/input.js new file mode 100644 index 0000000000000..4d5e8fb63c737 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/input.js @@ -0,0 +1 @@ +testing; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/output.js new file mode 100644 index 0000000000000..5a06e153c496f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-handle-has-own-property-correctly/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement("hasOwnProperty", null, "testing"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/input.js new file mode 100644 index 0000000000000..fa82e1cd08cb7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/input.js @@ -0,0 +1,5 @@ +var x =
+

+ {foo}
{bar}
+
+
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/output.js new file mode 100644 index 0000000000000..d8667f762c7d3 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-have-correct-comma-in-nested-children/output.js @@ -0,0 +1 @@ +var x = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("br", null)), /*#__PURE__*/React.createElement(Component, null, foo, /*#__PURE__*/React.createElement("br", null), bar), /*#__PURE__*/React.createElement("br", null)); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/input.js new file mode 100644 index 0000000000000..92541bbb3554e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/input.js @@ -0,0 +1,16 @@ +var x = +
+
diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/output.js new file mode 100644 index 0000000000000..9ae706684fd7f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-insert-commas-after-expressions-before-whitespace/output.js @@ -0,0 +1,6 @@ +var x = /*#__PURE__*/React.createElement("div", { + attr1: "foo" + "bar", + attr2: "foo" + "bar" + "baz" + "bug", + attr3: "foo" + "bar" + "baz" + "bug", + attr4: "baz" +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/input.js new file mode 100644 index 0000000000000..44d58a60fecf5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/input.js @@ -0,0 +1 @@ +var e = ; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/output.js new file mode 100644 index 0000000000000..1be1c61decdab --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-add-quotes-to-identifier-names/output.js @@ -0,0 +1,8 @@ +var e = /*#__PURE__*/React.createElement(F, { + aaa: true, + new: true, + const: true, + var: true, + default: true, + "foo-bar": true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/input.js new file mode 100644 index 0000000000000..acecaa910f205 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/output.js new file mode 100644 index 0000000000000..2e104ae0ae17d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-mangle-expressioncontainer-attribute-values/output.js @@ -0,0 +1,4 @@ +/*#__PURE__*/ +React.createElement("button", { + "data-value": "a value\n with\nnewlines\n and spaces" +}, "Button"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js new file mode 100644 index 0000000000000..38d8acbab5451 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/input.js @@ -0,0 +1 @@ +
 
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.js new file mode 100644 index 0000000000000..a8114f7ca5d45 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-nbsp-even-coupled-with-other-whitespace/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement("div", null, "\xA0 "); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/input.js new file mode 100644 index 0000000000000..0e05a7be8d236 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/input.js @@ -0,0 +1 @@ +
 
; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/output.js new file mode 100644 index 0000000000000..b01dbe6b08163 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-not-strip-tags-with-a-single-child-of-nbsp/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement("div", null, "\xA0"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/input.js new file mode 100644 index 0000000000000..8b1943e8f6836 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/input.js @@ -0,0 +1,10 @@ +var x = ( +
+ +
+); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/output.js new file mode 100644 index 0000000000000..fbe9b6dd6844f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-properly-handle-comments-between-props/output.js @@ -0,0 +1,8 @@ +var x = /*#__PURE__*/React.createElement("div", { + /* a multi-line + comment */ + attr1: "foo" +}, /*#__PURE__*/React.createElement("span", { + // a double-slash comment + attr2: "bar" +})); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/input.js new file mode 100644 index 0000000000000..c794650e94a66 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/output.js new file mode 100644 index 0000000000000..c8ab96101ebcb --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-quote-jsx-attributes/output.js @@ -0,0 +1,4 @@ +/*#__PURE__*/ +React.createElement("button", { + "data-value": "a value" +}, "Button"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/input.js new file mode 100644 index 0000000000000..48d051a95141b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/options.json new file mode 100644 index 0000000000000..d64437578f813 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/options.json @@ -0,0 +1 @@ +{"pragma":"h","runtime":"classic","throwIfNamespace":false} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/output.js new file mode 100644 index 0000000000000..24a57b8f231b6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-support-xml-namespaces-if-flag/output.js @@ -0,0 +1,3 @@ +h("f:image", { + "n:attr": true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/input.js new file mode 100644 index 0000000000000..4888b2b70588b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/options.json new file mode 100644 index 0000000000000..bb987d16f3132 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/options.json @@ -0,0 +1 @@ +{"throws":"Namespace tags are not supported by default. React's JSX doesn't support namespace tags. You can set `throwIfNamespace: false` to bypass this warning.","pragma":"h","runtime":"classic","throwIfNamespace":true} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.mjs b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.mjs new file mode 100644 index 0000000000000..84038ebb97225 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.mjs @@ -0,0 +1 @@ +h("f:image", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.stderr new file mode 100644 index 0000000000000..cd122c303ec34 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-throw-error-namespaces-if-not-flag/output.stderr @@ -0,0 +1,6 @@ +error: JSX Namespace is disabled by default because react does not support it yet. You can specify jsc.transform.react.throwIfNamespace to false to override default behavior + --> input.js:1:2 + | +1 | ; + | ^^^^^^^ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/input.js new file mode 100644 index 0000000000000..1cb54dd68816b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/input.js @@ -0,0 +1 @@ +; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/output.js new file mode 100644 index 0000000000000..24118629b8ebe --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/should-transform-known-hyphenated-tags/output.js @@ -0,0 +1,2 @@ +/*#__PURE__*/ +React.createElement("font-face", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/input.js new file mode 100644 index 0000000000000..f65588acf7b45 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/input.js @@ -0,0 +1 @@ +var div = test; diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/output.js new file mode 100644 index 0000000000000..abcfc719b2e8d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/this-tag-name/output.js @@ -0,0 +1 @@ +var div = /*#__PURE__*/React.createElement(this.foo, null, "test"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/input.js new file mode 100644 index 0000000000000..c0245177d289b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/input.js @@ -0,0 +1,7 @@ +/** @jsxRuntime classic */ + +class MobileHomeActivityTaskPriorityIcon extends React.PureComponent { + render() { + return  {this.props.value} ; + } +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/output.js new file mode 100644 index 0000000000000..3f5b87cb22396 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/weird-symbols/output.js @@ -0,0 +1,7 @@ +/** @jsxRuntime classic */ +class MobileHomeActivityTaskPriorityIcon extends React.PureComponent { + render() { + return /*#__PURE__*/React.createElement(Text, null, "\xA0", this.props.value, "\xA0"); + } + +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/input.js new file mode 100644 index 0000000000000..4e9432dfa388b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/input.js @@ -0,0 +1,2 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/output.js new file mode 100644 index 0000000000000..f3e155af3c33a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-first-spread-attributes/output.js @@ -0,0 +1,5 @@ +/*#__PURE__*/ +React.createElement(Component, { ...x, + y: 2, + z: true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/input.js new file mode 100644 index 0000000000000..ce7fb5b60f9f7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/input.js @@ -0,0 +1 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/output.js new file mode 100644 index 0000000000000..2131262e948c5 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-last-spread-attributes/output.js @@ -0,0 +1,6 @@ +/*#__PURE__*/ +React.createElement(Component, { + y: 2, + z: true, + ...x +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/input.js b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/input.js new file mode 100644 index 0000000000000..919adaebb41e2 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/input.js @@ -0,0 +1 @@ + diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/options.json b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/output.js b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/output.js new file mode 100644 index 0000000000000..0915d43ce0cc1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/react/wraps-props-in-react-spread-for-middle-spread-attributes/output.js @@ -0,0 +1,6 @@ +/*#__PURE__*/ +React.createElement(Component, { + y: 2, + ...x, + z: true +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/input.js b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/input.js new file mode 100644 index 0000000000000..8f34f4659447e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/input.js @@ -0,0 +1 @@ +const foo = 2; diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/options.json b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/output.js b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/output.js new file mode 100644 index 0000000000000..2b1080f18f94d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/output.js @@ -0,0 +1,3 @@ +var _reactJsxRuntime = require("react/jsx-runtime"); + +const foo = /*#__PURE__*/_reactJsxRuntime.jsx("p", {}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/plugin.js b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/plugin.js new file mode 100644 index 0000000000000..008f85eda2a4d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-automatic/plugin.js @@ -0,0 +1,13 @@ +module.exports = ({ types: t }) => ({ + visitor: { + NumericLiteral(path) { + path.replaceWith( + t.jsxElement( + t.jsxOpeningElement(t.jsxIdentifier("p"), []), + t.jsxClosingElement(t.jsxIdentifier("p")), + [] + ) + ); + } + } +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/input.js b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/input.js new file mode 100644 index 0000000000000..8f34f4659447e --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/input.js @@ -0,0 +1 @@ +const foo = 2; diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/options.json b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/output.js b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/output.js new file mode 100644 index 0000000000000..b28842cb637a3 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/output.js @@ -0,0 +1 @@ +const foo = /*#__PURE__*/React.createElement("p", null); diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/plugin.js b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/plugin.js new file mode 100644 index 0000000000000..008f85eda2a4d --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/.issue-12478-classic/plugin.js @@ -0,0 +1,13 @@ +module.exports = ({ types: t }) => ({ + visitor: { + NumericLiteral(path) { + path.replaceWith( + t.jsxElement( + t.jsxOpeningElement(t.jsxIdentifier("p"), []), + t.jsxClosingElement(t.jsxIdentifier("p")), + [] + ) + ); + } + } +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/input.js new file mode 100644 index 0000000000000..b0dacd1181a33 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/input.js @@ -0,0 +1,3 @@ +/* @jsxFrag React.Fragment */ +/* @jsx h */ +<>Test; diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/output.js b/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/output.js new file mode 100644 index 0000000000000..8a621e8a4575b --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/regression/pragma-frag-set-default-classic-runtime/output.js @@ -0,0 +1,4 @@ +/* @jsxFrag React.Fragment */ + +/* @jsx h */ +h(React.Fragment, null, "Test"); diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/input.js b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/options.json b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/options.json new file mode 100644 index 0000000000000..2220f31c43148 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/options.json @@ -0,0 +1 @@ +{"BABEL_8_BREAKING":true,"throws":"@babel/plugin-transform-react-jsx: Since \"useBuiltIns\" is removed in Babel 8, you can remove it from the config.","useBuiltIns":false} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/output.stderr new file mode 100644 index 0000000000000..1105b07354dfc --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-false/output.stderr @@ -0,0 +1 @@ +@babel/plugin-transform-react-jsx: Since "useBuiltIns" is removed in Babel 8, you can remove it from the config. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/input.js b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/options.json b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/options.json new file mode 100644 index 0000000000000..0fd635ccd79a8 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/options.json @@ -0,0 +1 @@ +{"BABEL_8_BREAKING":true,"throws":"@babel/plugin-transform-react-jsx: Since \"useBuiltIns\" is removed in Babel 8, you can remove it from the config.","useBuiltIns":true} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/output.stderr new file mode 100644 index 0000000000000..1105b07354dfc --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-builtins-true/output.stderr @@ -0,0 +1 @@ +@babel/plugin-transform-react-jsx: Since "useBuiltIns" is removed in Babel 8, you can remove it from the config. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/input.js b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/options.json b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/options.json new file mode 100644 index 0000000000000..09763926f3a43 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/options.json @@ -0,0 +1 @@ +{"BABEL_8_BREAKING":true,"throws":"transform-react-jsx: Since Babel 8, an inline object with spread elements is always used, and the \"useSpread\" option is no longer available. Please remove it from your config.","useSpread":false} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/output.stderr new file mode 100644 index 0000000000000..7d5b2269da3f6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-false/output.stderr @@ -0,0 +1 @@ +transform-react-jsx: Since Babel 8, an inline object with spread elements is always used, and the "useSpread" option is no longer available. Please remove it from your config. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/input.js b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/options.json b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/options.json new file mode 100644 index 0000000000000..251bb57c4add4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/options.json @@ -0,0 +1 @@ +{"BABEL_8_BREAKING":true,"throws":"transform-react-jsx: Since Babel 8, an inline object with spread elements is always used, and the \"useSpread\" option is no longer available. Please remove it from your config.","useSpread":true} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/output.stderr new file mode 100644 index 0000000000000..7d5b2269da3f6 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/removed-options/.invalid-use-spread-true/output.stderr @@ -0,0 +1 @@ +transform-react-jsx: Since Babel 8, an inline object with spread elements is always used, and the "useSpread" option is no longer available. Please remove it from your config. \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/input.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/input.js new file mode 100644 index 0000000000000..6a6f1f219c0db --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/input.js @@ -0,0 +1 @@ +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/options.json b/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/options.json new file mode 100644 index 0000000000000..f3682ff05b6c9 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/options.json @@ -0,0 +1 @@ +{"BABEL_8_BREAKING":true} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/output.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/output.js new file mode 100644 index 0000000000000..aaeb378c588a7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.defaults-to-automatic/output.js @@ -0,0 +1,5 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +var x = _jsx("div", { + children: _jsx("span", { + }) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/input.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/input.js new file mode 100644 index 0000000000000..6a6f1f219c0db --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/input.js @@ -0,0 +1 @@ +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/options.json b/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/options.json new file mode 100644 index 0000000000000..3b4683dee243f --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/options.json @@ -0,0 +1 @@ +{"throws":"Runtime must be either \"classic\" or \"automatic\".","runtime":"invalidOption"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/output.stderr b/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/output.stderr new file mode 100644 index 0000000000000..6d74b921ffcc7 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.invalid-runtime/output.stderr @@ -0,0 +1 @@ +Runtime must be either "classic" or "automatic". \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/input.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/input.js new file mode 100644 index 0000000000000..6a6f1f219c0db --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/input.js @@ -0,0 +1 @@ +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/options.json b/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/output.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/output.js new file mode 100644 index 0000000000000..607dafdc732b1 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/.runtime-automatic/output.js @@ -0,0 +1,5 @@ +var _reactJsxRuntime = require("react/jsx-runtime"); + +var x = /*#__PURE__*/_reactJsxRuntime.jsx("div", { + children: /*#__PURE__*/_reactJsxRuntime.jsx("span", {}) +}); diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/input.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/input.js new file mode 100644 index 0000000000000..6a6f1f219c0db --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/input.js @@ -0,0 +1 @@ +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/options.json b/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/output.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/output.js new file mode 100644 index 0000000000000..ebd8fce02e70a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/classic/output.js @@ -0,0 +1 @@ +var x = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", null)); diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/input.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/input.js new file mode 100644 index 0000000000000..6a6f1f219c0db --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/input.js @@ -0,0 +1 @@ +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/options.json b/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/options.json new file mode 100644 index 0000000000000..2ad5496953345 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/options.json @@ -0,0 +1 @@ +{"BABEL_8_BREAKING":false} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/output.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/output.js new file mode 100644 index 0000000000000..ebd8fce02e70a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/defaults-to-classis-babel-7/output.js @@ -0,0 +1 @@ +var x = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", null)); diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/input.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/input.js new file mode 100644 index 0000000000000..0b5717e407b44 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/input.js @@ -0,0 +1,3 @@ +/** @jsxRuntime classic */ + +var x = (
); \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/options.json b/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/options.json new file mode 100644 index 0000000000000..a96bee8a40458 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/options.json @@ -0,0 +1 @@ +{"runtime":"automatic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/output.js b/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/output.js new file mode 100644 index 0000000000000..8785f4a11be5c --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/runtime/pragma-runtime-classsic/output.js @@ -0,0 +1,2 @@ +/** @jsxRuntime classic */ +var x = /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", null)); diff --git a/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/input.js b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/options.json b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/options.json new file mode 100644 index 0000000000000..d870e73669298 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/options.json @@ -0,0 +1 @@ +{"runtime":"classic"} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/output.js b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/output.js new file mode 100644 index 0000000000000..b3819a2fc0aa3 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-babel-extend/output.js @@ -0,0 +1,4 @@ +var div = React.createElement(Component, _extends({ +}, props, { + foo: "bar" +})); diff --git a/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/input.js b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/input.js new file mode 100644 index 0000000000000..4caacb6aa17d4 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/input.js @@ -0,0 +1 @@ +var div = diff --git a/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/options.json b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/options.json new file mode 100644 index 0000000000000..9e26dfeeb6e64 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/options.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/output.js b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/output.js new file mode 100644 index 0000000000000..d05561223fd1a --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/.transform-to-object-assign/output.js @@ -0,0 +1,5 @@ +var _reactJsxRuntime = require("react/jsx-runtime"); + +var div = /*#__PURE__*/_reactJsxRuntime.jsx(Component, Object.assign({}, props, { + foo: "bar" +})); diff --git a/ecmascript/transforms/react/src/jsx/fixture/spread-transform/options.json b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/options.json new file mode 100644 index 0000000000000..cbf6d15954278 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/fixture/spread-transform/options.json @@ -0,0 +1,3 @@ +{ + "BABEL_8_BREAKING": true +} diff --git a/ecmascript/transforms/react/src/jsx/mod.rs b/ecmascript/transforms/react/src/jsx/mod.rs index 9cca1c46efc32..992429287e3ee 100644 --- a/ecmascript/transforms/react/src/jsx/mod.rs +++ b/ecmascript/transforms/react/src/jsx/mod.rs @@ -1,8 +1,11 @@ +use self::static_check::should_use_create_element; use dashmap::DashMap; use once_cell::sync::Lazy; use regex::Regex; use serde::{Deserialize, Serialize}; +use std::iter::once; use std::{iter, mem}; +use string_enum::StringEnum; use swc_atoms::{js_word, JsWord}; use swc_common::{ comments::{CommentKind, Comments}, @@ -16,6 +19,9 @@ use swc_ecma_transforms_base::ext::MapWithMut; use swc_ecma_transforms_base::helper; use swc_ecma_utils::drop_span; use swc_ecma_utils::member_expr; +use swc_ecma_utils::prepend; +use swc_ecma_utils::private_ident; +use swc_ecma_utils::quote_ident; use swc_ecma_utils::ExprFactory; use swc_ecma_utils::HANDLER; use swc_ecma_visit::as_folder; @@ -24,12 +30,42 @@ use swc_ecma_visit::Fold; use swc_ecma_visit::VisitMut; use swc_ecma_visit::VisitMutWith; +mod static_check; #[cfg(test)] mod tests; +/// https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#runtime +#[derive(StringEnum, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)] +pub enum Runtime { + /// `automatic` + Automatic, + /// `classic` + Classic, +} + +/// Note: This will changed in v2 +impl Default for Runtime { + fn default() -> Self { + Runtime::Classic + } +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] +#[serde(deny_unknown_fields)] pub struct Options { + /// If this is `true`, swc will behave just like babel 8 with + /// `BABEL_8_BREAKING: true`. + #[serde(skip, default)] + pub next: bool, + + #[serde(default)] + pub runtime: Option, + + /// For automatic runtime + #[serde(default = "default_import_source")] + pub import_source: String, + #[serde(default = "default_pragma")] pub pragma: String, #[serde(default = "default_pragma_frag")] @@ -41,22 +77,34 @@ pub struct Options { #[serde(default)] pub development: bool, - #[serde(default)] + /// TODO: Remove this field. + #[serde(default, alias = "useBuiltIns")] pub use_builtins: bool, + + #[serde(default)] + pub use_spread: bool, } impl Default for Options { fn default() -> Self { Options { + next: false, + runtime: Default::default(), + import_source: default_import_source(), pragma: default_pragma(), pragma_frag: default_pragma_frag(), throw_if_namespace: default_throw_if_namespace(), development: false, use_builtins: false, + use_spread: false, } } } +fn default_import_source() -> String { + "react".into() +} + fn default_pragma() -> String { "React.createElement".into() } @@ -69,7 +117,7 @@ fn default_throw_if_namespace() -> bool { true } -fn parse_option(cm: &SourceMap, name: &str, src: String) -> Box { +fn parse_classic_option(cm: &SourceMap, name: &str, src: String) -> Box { static CACHE: Lazy>> = Lazy::new(|| DashMap::with_capacity(2)); let fm = cm.new_source_file(FileName::Custom(format!("", name)), src); @@ -106,14 +154,23 @@ where { as_folder(Jsx { cm: cm.clone(), - pragma: ExprOrSuper::Expr(parse_option(&cm, "pragma", options.pragma)), + next: options.next, + runtime: options.runtime.unwrap_or_default(), + import_source: options.import_source.into(), + import_jsx: None, + import_jsxs: None, + import_fragment: None, + import_create_element: None, + + pragma: ExprOrSuper::Expr(parse_classic_option(&cm, "pragma", options.pragma)), comments, pragma_frag: ExprOrSpread { spread: None, - expr: parse_option(&cm, "pragmaFrag", options.pragma_frag), + expr: parse_classic_option(&cm, "pragmaFrag", options.pragma_frag), }, use_builtins: options.use_builtins, throw_if_namespace: options.throw_if_namespace, + top_level_node: true, }) } @@ -122,6 +179,21 @@ where C: Comments, { cm: Lrc, + + next: bool, + runtime: Runtime, + /// For automatic runtime. + import_source: JsWord, + /// For automatic runtime. + import_jsx: Option, + /// For automatic runtime. + import_jsxs: Option, + /// For automatic runtime. + import_create_element: Option, + /// For automatic runtime. + import_fragment: Option, + top_level_node: bool, + pragma: ExprOrSuper, comments: Option, pragma_frag: ExprOrSpread, @@ -136,48 +208,302 @@ where fn jsx_frag_to_expr(&mut self, el: JSXFragment) -> Expr { let span = el.span(); - Expr::Call(CallExpr { - span, - callee: self.pragma.clone(), - args: iter::once(self.pragma_frag.clone()) - // attribute: null - .chain(iter::once(Lit::Null(Null { span: DUMMY_SP }).as_arg())) - .chain({ - // Children - el.children - .into_iter() - .filter_map(|c| self.jsx_elem_child_to_expr(c)) + let use_jsxs = count_children(&el.children) > 1; + + match self.runtime { + Runtime::Automatic => { + let jsx = if use_jsxs { + self.import_jsxs + .get_or_insert_with(|| private_ident!("_jsxs")) + .clone() + } else { + self.import_jsx + .get_or_insert_with(|| private_ident!("_jsx")) + .clone() + }; + + let fragment = self + .import_fragment + .get_or_insert_with(|| private_ident!("_Fragment")) + .clone(); + + let mut props_obj = ObjectLit { + span: DUMMY_SP, + props: vec![], + }; + + let children = el + .children + .into_iter() + .filter_map(|child| self.jsx_elem_child_to_expr(child)) + .map(Some) + .collect::>(); + + match children.len() { + 0 => {} + 1 if children[0].as_ref().unwrap().spread.is_none() + && match &*children[0].as_ref().unwrap().expr { + Expr::Call(CallExpr { + callee: ExprOrSuper::Expr(callee), + .. + }) => match &**callee { + Expr::Ident(Ident { sym, .. }) => *sym != *"_jsx", + _ => true, + }, + _ => true, + } => + { + props_obj + .props + .push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { + key: PropName::Ident(quote_ident!("children")), + value: children.into_iter().next().flatten().unwrap().expr, + })))); + } + _ => { + props_obj + .props + .push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { + key: PropName::Ident(quote_ident!("children")), + value: Box::new(Expr::Array(ArrayLit { + span: DUMMY_SP, + elems: children, + })), + })))); + } + } + + Expr::Call(CallExpr { + span, + callee: jsx.as_callee(), + args: vec![fragment.as_arg(), props_obj.as_arg()], + type_args: None, }) - .collect(), - type_args: None, - }) + } + Runtime::Classic => { + Expr::Call(CallExpr { + span, + callee: self.pragma.clone(), + args: iter::once(self.pragma_frag.clone()) + // attribute: null + .chain(iter::once(Lit::Null(Null { span: DUMMY_SP }).as_arg())) + .chain({ + // Children + el.children + .into_iter() + .filter_map(|c| self.jsx_elem_child_to_expr(c)) + }) + .collect(), + type_args: None, + }) + } + } } + /// # Automatic + /// + /// + /// + /// # Classic + /// + ///
=> React.createElement('div', null); fn jsx_elem_to_expr(&mut self, el: JSXElement) -> Expr { + let top_level_node = self.top_level_node; let span = el.span(); + let use_create_element = should_use_create_element(&el.opening.attrs); + self.top_level_node = false; let name = self.jsx_name(el.opening.name); - Expr::Call(CallExpr { - span, - callee: self.pragma.clone(), - args: iter::once(name.as_arg()) - .chain(iter::once({ - // Attributes - self.fold_attrs(el.opening.attrs).as_arg() - })) - .chain({ - // Children - el.children - .into_iter() - .filter_map(|c| self.jsx_elem_child_to_expr(c)) + match self.runtime { + Runtime::Automatic => { + // function jsx(tagName: string, props: { children: Node[], ... }, key: string) + + let use_jsxs = count_children(&el.children) > 1; + + let jsx = if use_create_element { + self.import_create_element + .get_or_insert_with(|| private_ident!("_createElement")) + .clone() + } else if use_jsxs { + self.import_jsxs + .get_or_insert_with(|| private_ident!("_jsxs")) + .clone() + } else { + self.import_jsx + .get_or_insert_with(|| private_ident!("_jsx")) + .clone() + }; + + let mut props_obj = ObjectLit { + span: DUMMY_SP, + props: vec![], + }; + + let mut key = None; + + for attr in el.opening.attrs { + match attr { + JSXAttrOrSpread::JSXAttr(attr) => { + // + match attr.name { + JSXAttrName::Ident(i) => { + // + if !use_create_element && i.sym == js_word!("key") { + key = attr + .value + .map(jsx_attr_value_to_expr) + .flatten() + .map(|expr| ExprOrSpread { expr, spread: None }); + assert_ne!( + key, None, + "value of property 'key' should not be empty" + ); + continue; + } + + let value = match attr.value { + Some(v) => jsx_attr_value_to_expr(v) + .expect("empty expression container?"), + None => Box::new(Expr::Lit(Lit::Bool(Bool { + span: DUMMY_SP, + value: true, + }))), + }; + + // TODO: Check if `i` is a valid identifier. + let key = if i.sym.contains("-") { + PropName::Str(Str { + span: i.span, + value: i.sym, + has_escape: false, + kind: StrKind::Normal { + contains_quote: false, + }, + }) + } else { + PropName::Ident(i) + }; + props_obj.props.push(PropOrSpread::Prop(Box::new( + Prop::KeyValue(KeyValueProp { key, value }), + ))); + } + JSXAttrName::JSXNamespacedName(JSXNamespacedName { ns, name }) => { + if self.throw_if_namespace { + HANDLER.with(|handler| { + handler + .struct_span_err( + span, + "JSX Namespace is disabled by default because \ + react does not support it yet. You can \ + specify jsc.transform.react.throwIfNamespace \ + to false to override default behavior", + ) + .emit() + }); + } + + let value = match attr.value { + Some(v) => jsx_attr_value_to_expr(v) + .expect("empty expression container?"), + None => Box::new(Expr::Lit(Lit::Bool(Bool { + span: DUMMY_SP, + value: true, + }))), + }; + + let key = Str { + span, + value: format!("{}:{}", ns.sym, name.sym).into(), + has_escape: false, + kind: Default::default(), + }; + let key = PropName::Str(key); + + props_obj.props.push(PropOrSpread::Prop(Box::new( + Prop::KeyValue(KeyValueProp { key, value }), + ))); + } + } + } + JSXAttrOrSpread::SpreadElement(attr) => match *attr.expr { + Expr::Object(obj) => { + props_obj.props.extend(obj.props); + } + _ => { + props_obj.props.push(PropOrSpread::Spread(attr)); + } + }, + } + } + + let children = el + .children + .into_iter() + .filter_map(|child| self.jsx_elem_child_to_expr(child)) + .map(Some) + .collect::>(); + + match children.len() { + 0 => {} + 1 if children[0].as_ref().unwrap().spread.is_none() => { + props_obj + .props + .push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { + key: PropName::Ident(quote_ident!("children")), + value: children.into_iter().next().flatten().unwrap().expr, + })))); + } + _ => { + props_obj + .props + .push(PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp { + key: PropName::Ident(quote_ident!("children")), + value: Box::new(Expr::Array(ArrayLit { + span: DUMMY_SP, + elems: children, + })), + })))); + } + } + + self.top_level_node = top_level_node; + + Expr::Call(CallExpr { + span, + callee: jsx.as_callee(), + args: once(name.as_arg()) + .chain(once(props_obj.as_arg())) + .chain(key) + .collect(), + type_args: Default::default(), }) - .collect(), - type_args: Default::default(), - }) + } + Runtime::Classic => { + Expr::Call(CallExpr { + span, + callee: self.pragma.clone(), + args: iter::once(name.as_arg()) + .chain(iter::once({ + // Attributes + self.fold_attrs_for_classic(el.opening.attrs).as_arg() + })) + .chain({ + // Children + el.children + .into_iter() + .filter_map(|c| self.jsx_elem_child_to_expr(c)) + }) + .collect(), + type_args: Default::default(), + }) + } + } } fn jsx_elem_child_to_expr(&mut self, c: JSXElementChild) -> Option { + self.top_level_node = false; + Some(match c { JSXElementChild::JSXText(text) => { // TODO(kdy1): Optimize @@ -205,11 +531,61 @@ where JSXElementChild::JSXFragment(el) => self.jsx_frag_to_expr(el).as_arg(), JSXElementChild::JSXSpreadChild(JSXSpreadChild { .. }) => { unimplemented!("jsx spread child") + JSXElementChild::JSXSpreadChild(JSXSpreadChild { span, .. }) => { + HANDLER.with(|handler| { + handler + .struct_span_err(span, "Spread children are not supported in React.") + .emit(); + }); + return None; } }) } - fn fold_attrs(&mut self, attrs: Vec) -> Box { + fn fold_attrs_for_classic(&mut self, attrs: Vec) -> Box { + if self.next { + self.fold_attrs_for_next_classic(attrs) + } else { + self.fold_attrs_for_old_classic(attrs) + } + } + + /// Runtiem; `classic` + fn fold_attrs_for_next_classic(&mut self, attrs: Vec) -> Box { + if attrs.is_empty() { + return Box::new(Expr::Lit(Lit::Null(Null { span: DUMMY_SP }))); + } + let attr_cnt = attrs.len(); + + let mut props = vec![]; + for attr in attrs { + match attr { + JSXAttrOrSpread::JSXAttr(attr) => { + props.push(PropOrSpread::Prop(Box::new(self.attr_to_prop(attr)))) + } + JSXAttrOrSpread::SpreadElement(spread) => { + if attr_cnt == 1 { + return spread.expr; + } + // babel does some optimizations + match *spread.expr { + Expr::Object(obj) => props.extend(obj.props), + _ => props.push(PropOrSpread::Spread(spread)), + } + } + } + } + + let obj = ObjectLit { + span: DUMMY_SP, + props, + }; + + Box::new(Expr::Object(obj)) + } + + /// Runtime: `automatic` + fn fold_attrs_for_old_classic(&mut self, attrs: Vec) -> Box { if attrs.is_empty() { return Box::new(Expr::Lit(Lit::Null(Null { span: DUMMY_SP }))); } @@ -238,7 +614,7 @@ where for attr in attrs { match attr { JSXAttrOrSpread::JSXAttr(a) => { - cur_obj_props.push(PropOrSpread::Prop(Box::new(attr_to_prop(a)))) + cur_obj_props.push(PropOrSpread::Prop(Box::new(self.attr_to_prop(a)))) } JSXAttrOrSpread::SpreadElement(e) => { check!(); @@ -270,10 +646,9 @@ where JSXAttrOrSpread::JSXAttr(a) => a, _ => unreachable!(), }) - .map(attr_to_prop) - .map(|mut v| { + .map(|attr| { + let mut v = self.attr_to_prop(attr); v.visit_mut_with(self); - v }) .map(Box::new) @@ -282,6 +657,32 @@ where })) } } + + fn attr_to_prop(&mut self, a: JSXAttr) -> Prop { + let key = to_prop_name(a.name); + let value = a + .value + .map(|v| match v { + JSXAttrValue::JSXExprContainer(JSXExprContainer { + expr: JSXExpr::Expr(e), + .. + }) => e, + JSXAttrValue::JSXElement(element) => Box::new(self.jsx_elem_to_expr(*element)), + JSXAttrValue::JSXFragment(fragment) => Box::new(self.jsx_frag_to_expr(fragment)), + JSXAttrValue::Lit(lit) => Box::new(lit.into()), + JSXAttrValue::JSXExprContainer(JSXExprContainer { + span: _, + expr: JSXExpr::JSXEmptyExpr(_), + }) => unreachable!("attr_to_prop(JSXEmptyExpr)"), + }) + .unwrap_or_else(|| { + Box::new(Expr::Lit(Lit::Bool(Bool { + span: key.span(), + value: true, + }))) + }); + Prop::KeyValue(KeyValueProp { key, value }) + } } impl VisitMut for Jsx @@ -301,21 +702,72 @@ where } for line in leading.text.lines() { - if !line.trim().starts_with("* @jsx") { + let mut line = line.trim(); + if line.starts_with('*') { + line = line[1..].trim(); + } + + if !line.starts_with("@jsx") { continue; } - if line.trim().starts_with("* @jsxFrag") { - let src = line.replace("* @jsxFrag", "").trim().to_string(); + if line.starts_with("@jsxRuntime ") { + let src = line.replace("@jsxRuntime ", "").trim().to_string(); + if src == "classic" { + self.runtime = Runtime::Classic; + } else if src == "automatic" { + self.runtime = Runtime::Automatic; + } else { + todo!("proper error reporting for wrong `@jsxRuntime`") + } + continue; + } + + if line.starts_with("@jsxImportSource") { + let src = line.replace("@jsxImportSource", "").trim().to_string(); + self.import_source = src.into(); + } + + if line.starts_with("@jsxFrag") { + if self.runtime == Runtime::Automatic { + HANDLER.with(|handler| { + handler + .struct_span_err( + module.span, + "pragma and pragmaFrag cannot be set when runtime is \ + automatic", + ) + .emit() + }); + } + + let src = line.replace("@jsxFrag", "").trim().to_string(); self.pragma_frag = ExprOrSpread { - expr: parse_option(&self.cm, "module-jsx-pragma-frag", src), + expr: parse_classic_option(&self.cm, "module-jsx-pragma-frag", src), spread: None, }; - } else { - let src = line.replace("* @jsx", "").trim().to_string(); + } else if line.starts_with("@jsx ") { + if self.runtime == Runtime::Automatic { + if self.runtime == Runtime::Automatic { + HANDLER.with(|handler| { + handler + .struct_span_err( + module.span, + "pragma and pragmaFrag cannot be set when runtime \ + is automatic", + ) + .emit() + }); + } + } - self.pragma = - ExprOrSuper::Expr(parse_option(&self.cm, "module-jsx-pragma", src)); + let src = line.replace("@jsx", "").trim().to_string(); + + self.pragma = ExprOrSuper::Expr(parse_classic_option( + &self.cm, + "module-jsx-pragma", + src, + )); } } } @@ -333,36 +785,117 @@ where } module.visit_mut_children_with(self); + + if self.runtime == Runtime::Automatic { + if let Some(local) = self.import_create_element.take() { + let specifier = ImportSpecifier::Named(ImportNamedSpecifier { + span: DUMMY_SP, + local, + imported: Some(Ident::new("createElement".into(), DUMMY_SP)), + }); + prepend( + &mut module.body, + ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { + span: DUMMY_SP, + specifiers: vec![specifier], + src: Str { + span: DUMMY_SP, + value: "react".into(), + has_escape: false, + kind: Default::default(), + }, + type_only: Default::default(), + asserts: Default::default(), + })), + ); + } + + let imports = self + .import_jsx + .take() + .map(|local| ImportNamedSpecifier { + span: DUMMY_SP, + local, + imported: Some(quote_ident!("jsx")), + }) + .into_iter() + .chain(self.import_jsxs.take().map(|local| ImportNamedSpecifier { + span: DUMMY_SP, + local, + imported: Some(quote_ident!("jsxs")), + })) + .chain( + self.import_fragment + .take() + .map(|local| ImportNamedSpecifier { + span: DUMMY_SP, + local, + imported: Some(quote_ident!("Fragment")), + }), + ) + .map(ImportSpecifier::Named) + .collect::>(); + + if !imports.is_empty() { + prepend( + &mut module.body, + ModuleItem::ModuleDecl(ModuleDecl::Import(ImportDecl { + span: DUMMY_SP, + specifiers: imports, + src: Str { + span: DUMMY_SP, + value: format!("{}/jsx-runtime", self.import_source).into(), + has_escape: false, + kind: Default::default(), + }, + type_only: Default::default(), + asserts: Default::default(), + })), + ); + } + } } fn visit_mut_expr(&mut self, expr: &mut Expr) { - expr.visit_mut_children_with(self); + let top_level_node = self.top_level_node; + let mut did_work = false; if let Expr::JSXElement(el) = expr { + did_work = true; //
=> React.createElement('div', null); *expr = self.jsx_elem_to_expr(*el.take()); - return; - } - if let Expr::JSXFragment(frag) = expr { + } else if let Expr::JSXFragment(frag) = expr { // <> => React.createElement(React.Fragment, null); + did_work = true; *expr = self.jsx_frag_to_expr(frag.take()); - return; - } - - if let Expr::Paren(ParenExpr { + } else if let Expr::Paren(ParenExpr { expr: inner_expr, .. }) = expr { if let Expr::JSXElement(el) = &mut **inner_expr { + did_work = true; *expr = self.jsx_elem_to_expr(*el.take()); - return; - } - if let Expr::JSXFragment(frag) = &mut **inner_expr { + } else if let Expr::JSXFragment(frag) = &mut **inner_expr { // <> => React.createElement(React.Fragment, null); + did_work = true; *expr = self.jsx_frag_to_expr(frag.take()); - return; } } + + if did_work { + self.top_level_node = false; + } + + expr.visit_mut_children_with(self); + + self.top_level_node = top_level_node; + } + + fn visit_mut_member_expr(&mut self, e: &mut MemberExpr) { + e.obj.visit_mut_with(self); + if e.computed { + e.prop.visit_mut_with(self); + } } } @@ -449,32 +982,6 @@ where } } -fn attr_to_prop(a: JSXAttr) -> Prop { - let key = to_prop_name(a.name); - let value = a - .value - .map(|v| match v { - JSXAttrValue::JSXExprContainer(JSXExprContainer { - expr: JSXExpr::Expr(e), - .. - }) => e, - JSXAttrValue::JSXElement(e) => Box::new(Expr::JSXElement(e)), - JSXAttrValue::JSXFragment(e) => Box::new(Expr::JSXFragment(e)), - JSXAttrValue::Lit(lit) => Box::new(lit.into()), - JSXAttrValue::JSXExprContainer(JSXExprContainer { - span: _, - expr: JSXExpr::JSXEmptyExpr(_), - }) => unreachable!("attr_to_prop(JSXEmptyExpr)"), - }) - .unwrap_or_else(|| { - Box::new(Expr::Lit(Lit::Bool(Bool { - span: key.span(), - value: true, - }))) - }); - Prop::KeyValue(KeyValueProp { key, value }) -} - fn to_prop_name(n: JSXAttrName) -> PropName { let span = n.span(); @@ -502,6 +1009,7 @@ fn to_prop_name(n: JSXAttrName) -> PropName { } } +#[inline] fn jsx_text_to_str(t: JsWord) -> JsWord { static SPACE_NL_START: Lazy = Lazy::new(|| Regex::new("^\\s*\n\\s*").unwrap()); static SPACE_NL_END: Lazy = Lazy::new(|| Regex::new("\\s*\n\\s*$").unwrap()); @@ -533,3 +1041,34 @@ fn jsx_text_to_str(t: JsWord) -> JsWord { buf.into() } + +fn jsx_attr_value_to_expr(v: JSXAttrValue) -> Option> { + Some(match v { + JSXAttrValue::Lit(lit) => Box::new(lit.into()), + JSXAttrValue::JSXExprContainer(e) => match e.expr { + JSXExpr::JSXEmptyExpr(_) => None?, + JSXExpr::Expr(e) => e, + }, + JSXAttrValue::JSXElement(e) => Box::new(Expr::JSXElement(e)), + JSXAttrValue::JSXFragment(f) => Box::new(Expr::JSXFragment(f)), + }) +} + +fn count_children(children: &[JSXElementChild]) -> usize { + children + .iter() + .filter(|v| match v { + JSXElementChild::JSXText(text) => { + let text = jsx_text_to_str(text.value.clone()); + !text.is_empty() + } + JSXElementChild::JSXExprContainer(e) => match e.expr { + JSXExpr::JSXEmptyExpr(_) => false, + JSXExpr::Expr(_) => true, + }, + JSXElementChild::JSXSpreadChild(_) => true, + JSXElementChild::JSXElement(_) => true, + JSXElementChild::JSXFragment(_) => true, + }) + .count() +} diff --git a/ecmascript/transforms/react/src/jsx/static_check.rs b/ecmascript/transforms/react/src/jsx/static_check.rs new file mode 100644 index 0000000000000..0aa3ef3ad9813 --- /dev/null +++ b/ecmascript/transforms/react/src/jsx/static_check.rs @@ -0,0 +1,33 @@ +use swc_atoms::js_word; +use swc_ecma_ast::*; + +/// We want to use React.createElement, even in the case of +/// jsx, for
to distinguish it +/// from
. This is an intermediary +/// step while we deprecate key spread from props. Afterwards, +/// we will stop using createElement in the transform. +pub(super) fn should_use_create_element(attrs: &[JSXAttrOrSpread]) -> bool { + let mut seen_prop_spread = false; + for attr in attrs { + if seen_prop_spread + && match attr { + JSXAttrOrSpread::JSXAttr(attr) => match &attr.name { + JSXAttrName::Ident(i) => i.sym == js_word!("key"), + JSXAttrName::JSXNamespacedName(_) => false, + }, + _ => false, + } + { + return true; + } + + match attr { + JSXAttrOrSpread::SpreadElement(_) => { + seen_prop_spread = true; + } + _ => {} + } + } + + false +} diff --git a/ecmascript/transforms/react/src/jsx/tests.rs b/ecmascript/transforms/react/src/jsx/tests.rs index 220c47340dc36..3e606e8fa5504 100644 --- a/ecmascript/transforms/react/src/jsx/tests.rs +++ b/ecmascript/transforms/react/src/jsx/tests.rs @@ -1,12 +1,15 @@ use super::*; use crate::display_name; +use std::path::PathBuf; use swc_common::{chain, Mark}; use swc_ecma_parser::EsConfig; use swc_ecma_transforms_compat::es2015::arrow; use swc_ecma_transforms_compat::es2015::classes; use swc_ecma_transforms_compat::es3::property_literals; use swc_ecma_transforms_module::common_js::common_js; +use swc_ecma_transforms_testing::parse_options; use swc_ecma_transforms_testing::test; +use swc_ecma_transforms_testing::test_fixture; use swc_ecma_transforms_testing::Tester; fn tr(t: &mut Tester, options: Options) -> impl Fold { @@ -18,6 +21,42 @@ fn tr(t: &mut Tester, options: Options) -> impl Fold { ) } +#[derive(Debug, Deserialize)] +#[serde(deny_unknown_fields)] +struct FixtureOptions { + #[serde(flatten)] + options: Options, + + #[serde(default, rename = "BABEL_8_BREAKING")] + babel_8_breaking: bool, + + #[serde(default = "true_by_default")] + pure: bool, + + #[serde(default)] + throws: Option, + + #[serde(default, alias = "useBuiltIns")] + use_builtins: bool, +} + +fn true_by_default() -> bool { + true +} + +fn fixture_tr(t: &mut Tester, mut options: FixtureOptions) -> impl Fold { + options.options.next = options.babel_8_breaking || options.options.runtime.is_some(); + + if !options.babel_8_breaking && options.options.runtime.is_none() { + options.options.runtime = Some(Runtime::Classic); + } + + options.options.use_builtins |= options.use_builtins; + chain!( + jsx(t.cm.clone(), Some(t.comments.clone()), options.options), + display_name(), + ) +} test!( ::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig { jsx: true, @@ -1236,3 +1275,24 @@ exports.default = RandomComponent; "# ); + +#[testing::fixture("fixture/**/input.js")] +fn fixture(input: PathBuf) { + let mut output = input.with_file_name("output.js"); + if !output.exists() { + output = input.with_file_name("output.mjs"); + } + + test_fixture( + Syntax::Es(EsConfig { + jsx: true, + ..Default::default() + }), + &|t| { + let options = parse_options(input.parent().unwrap()); + fixture_tr(t, options) + }, + &input, + &output, + ); +} diff --git a/ecmascript/transforms/testing/Cargo.toml b/ecmascript/transforms/testing/Cargo.toml index a128ac7fed279..fec88b9a7de7b 100644 --- a/ecmascript/transforms/testing/Cargo.toml +++ b/ecmascript/transforms/testing/Cargo.toml @@ -11,6 +11,9 @@ version = "0.4.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +ansi_term = "0.12.1" +serde = "1" +serde_json = "1" swc_common = {version = "0.10", path = "../../../common"} swc_ecma_ast = {version = "0.38.0", path = "../../ast"} swc_ecma_codegen = {version = "0.45.0", path = "../../codegen"} diff --git a/ecmascript/transforms/testing/src/lib.rs b/ecmascript/transforms/testing/src/lib.rs index b8d36788913e3..e1be459a8b1fa 100644 --- a/ecmascript/transforms/testing/src/lib.rs +++ b/ecmascript/transforms/testing/src/lib.rs @@ -1,3 +1,7 @@ +use ansi_term::Color; +use serde::de::DeserializeOwned; +use std::env; +use std::fs::read_to_string; use std::mem::replace; use std::{ fmt, @@ -18,10 +22,13 @@ use swc_ecma_transforms_base::fixer; use swc_ecma_transforms_base::helpers::{inject_helpers, HELPERS}; use swc_ecma_transforms_base::hygiene; use swc_ecma_utils::DropSpan; +use swc_ecma_utils::HANDLER; use swc_ecma_visit::VisitMut; use swc_ecma_visit::VisitMutWith; use swc_ecma_visit::{as_folder, Fold, FoldWith}; use tempfile::tempdir_in; +use testing::assert_eq; +use testing::NormalizedOutput; pub struct Tester<'a> { pub cm: Lrc, @@ -52,6 +59,35 @@ impl<'a> Tester<'a> { } } + pub(crate) fn run_captured(op: F) -> (Option, NormalizedOutput) + where + F: FnOnce(&mut Tester<'_>) -> Result, + { + let mut res = None; + let output = ::testing::Tester::new().print_errors(|cm, handler| -> Result<(), _> { + HANDLER.set(&handler, || { + HELPERS.set(&Default::default(), || { + let result = op(&mut Tester { + cm, + handler: &handler, + comments: Default::default(), + }); + + res = result.ok(); + + // We need stderr + Err(()) + }) + }) + }); + + let output = output + .err() + .unwrap_or_else(|| NormalizedOutput::from(String::from(""))); + + (res, output) + } + pub fn with_parser( &mut self, file_name: &str, @@ -403,3 +439,124 @@ impl Fold for HygieneVisualizer { } } } + +pub fn parse_options(dir: &Path) -> T +where + T: DeserializeOwned, +{ + let mut s = String::from("{}"); + + fn check(dir: &Path) -> Option { + let file = dir.join("options.json"); + match read_to_string(&file) { + Ok(v) => { + eprintln!("Using options.json at {}", file.display()); + eprintln!("----- {} -----\n{}", Color::Green.paint("Options"), v); + + return Some(v); + } + Err(_) => {} + } + + dir.parent().and_then(check) + } + + if let Some(content) = check(dir) { + s = content; + } + + serde_json::from_str(&s) + .unwrap_or_else(|err| panic!("failed to deserialize options.json: {}", err)) +} + +pub fn test_fixture

(syntax: Syntax, tr: &dyn Fn(&mut Tester) -> P, input: &Path, output: &Path) +where + P: Fold, +{ + let expected = read_to_string(output); + let _is_really_expected = expected.is_ok(); + let expected = expected.unwrap_or_default(); + + let (values, stderr) = Tester::run_captured(|tester| { + let input_str = read_to_string(input).unwrap(); + println!("----- {} -----\n{}", Color::Green.paint("Input"), input_str); + + let tr = tr(tester); + + let expected = tester.apply_transform( + as_folder(::swc_ecma_utils::DropSpan { + preserve_ctxt: true, + }), + "output.js", + syntax, + &expected, + )?; + + let expected_src = tester.print(&expected); + + println!( + "----- {} -----\n{}", + Color::Green.paint("Expected"), + expected_src + ); + + println!("----- {} -----", Color::Green.paint("Actual")); + + let actual = + tester.apply_transform(tr, "input.js", syntax, &read_to_string(&input).unwrap())?; + + match ::std::env::var("PRINT_HYGIENE") { + Ok(ref s) if s == "1" => { + let hygiene_src = tester.print(&actual.clone().fold_with(&mut HygieneVisualizer)); + println!( + "----- {} -----\n{}", + Color::Green.paint("Hygiene"), + hygiene_src + ); + } + _ => {} + } + + let actual = actual + .fold_with(&mut crate::hygiene::hygiene()) + .fold_with(&mut crate::fixer::fixer(None)) + .fold_with(&mut as_folder(DropSpan { + preserve_ctxt: false, + })); + + let actual_src = tester.print(&actual); + + Ok((actual_src, expected_src)) + }); + + let mut results = vec![]; + + if !stderr.is_empty() { + results + .push(NormalizedOutput::from(stderr).compare_to_file(output.with_extension("stderr"))); + } + + match values { + Some((actual_src, expected_src)) => { + println!("{}", actual_src); + + if actual_src == expected_src { + // Ignore `UPDATE` + return; + } + + if let Ok("1") = env::var("UPDATE").as_deref() { + results.push(NormalizedOutput::from(actual_src.clone()).compare_to_file(output)); + } + assert_eq!( + DebugUsingDisplay(&actual_src), + DebugUsingDisplay(&expected_src) + ); + } + _ => {} + } + + for result in results { + result.unwrap(); + } +}