51 Commits

Author SHA1 Message Date
Mateusz Burzyński
c2fcd69e94
Stop using old JSX transform (#12253) 2020-12-08 22:41:13 +01:00
Nicolò Ribaudo
02fc9e835c
Revert "add .js extension to react runtime for JSX transform" (#12213) 2020-10-19 19:50:43 +02:00
Luna Ruan
9808d2566e
add js extension to react runtime (#12116) 2020-09-30 08:31:45 +02:00
Christoph Nakazawa
2bb2933dea
[helpers] Add a private function name within createSuper (#11514) 2020-05-04 23:30:53 +02:00
Justin Ridgewell
070ec201bb
Speed up the createSuper helper (#11401) 2020-04-10 16:00:20 +02:00
Luna Ruan
94447135c7
fix auto import error with whitespace JSXText (#11354) 2020-04-02 00:29:27 +02:00
Nicolò Ribaudo
87b2781046
Consider jsxFrag as set when it's set to the default value (#11295)
* Consider jsxFrag as set when it's set to the default value

* Test #11294
2020-03-20 22:29:50 +01:00
Nicolò Ribaudo
11292a3c74
Use the correct this in __self for JSX elements in arrows (#11288)
* Inject `__source` and `__self` in JSX elements earlier

This fixes an issue where `this` was not correct inside arrow functions, similar to
906f8be24d

* Add test

* Remove try-catch

* Update error

* Update fixtures

* Update windows fixtures
2020-03-19 20:01:17 +01:00
Nicolò Ribaudo
f3912ac08f
Mark transpiled JSX elements as pure (#11126)
* Mark transpiled JSX elements as pure

* Avoid duble annotation

* Add "pure" option to the React preset

* Fix generator indentation

* Update tests

* Add tests for the "pure" option

* Update windows fixtures
2020-03-19 15:43:54 +01:00
Luna Ruan
748897be07
Add experimental version of the `babel-plugin-transform-react-… (#11154)
* add next option for babel-plugin-transform-react-jsx

* address review comments

* chore: update test fixtures

* Update fixture

* Add "columnNumber" to the new React transform

* Update windows fixtures

* Delete unused output.js

* Update windows tests

* Fix windows again

* fix comments

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Moti Zilberman <motiz88@gmail.com>
2020-03-17 09:16:53 +01:00
Nicolò Ribaudo
f6c7bf36ce
Allow extending untranspiled classes (#8656) 2020-03-16 23:59:15 +01:00
Nicolò Ribaudo
d21e2217d5
Skip newlines around inline #__PURE__ annotations (#11133)
* Skip newlines around #__PURE__ annotations

* Update tests
2020-02-13 19:16:33 +01:00
Aziz Khambati
a0d76a8c0e Fix pragmaFrag spelling in error message (#10868) 2019-12-16 09:55:08 -05:00
Ivan Medina
3d2f365074 [transform-react-jsx] Add useSpread option to transform JSX (#10572)
* [transform-react-jsx] Add useSpread option to transform JSX

* Add validation for default option

* Add error when using useSpread and useBuiltIns at the same time

* Move useSpread to convertAttribute helper function

* Add useSpread option to presect-react

* Remove casting useSpread to boolean in preset-react option.

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2019-10-29 23:02:53 +01:00
Daniel Tschinder
54f072991d
Revert "Revert babel-helper-builder-react-jsx change from #4988" (#9119)
This reverts commit dbc07220ae9188a3fb2bdea3d826ff7f48532a2e.

# Conflicts:
#	packages/babel-helper-builder-react-jsx/src/index.js
2019-01-05 22:22:49 -08:00
Brian Ng
38cf318f61
Bump lint-related deps (#8765) 2018-09-24 18:09:54 -05:00
Logan Smyth
79b2af5997
Format fixture JSON with Prettier. (#8658) 2018-09-09 17:57:52 -07:00
Erik Arvidsson
7846eaebaa Do not quote JSX attribute keys for IdentifierName (#8045)
Given the following

```js
a = <F new/>
```

We used to generate:

```js
a = React.createElement(F, {"new": true})
```

but now we generate

```js
a = React.createElement(F, {new: true})
```

If you need to quote these (ie for ES3 you can use
transform-property-literals)
2018-05-27 12:48:18 -04:00
Justin Ridgewell
2af7a33c4e Fix class inheritance in IE10 (#7969)
* Revert "Move subclass inheritance to end (#7772)"

This reverts commit f8ab9466d331871a90f458af40b14e8d831e0c29.

* Only use getPrototypeOf if setPrototypeOf is implemented

* Update fixtures

* Helpers updates

* Update fixtures

* Fall back to getPrototypeOf

* Update fixtures
2018-05-23 16:21:21 -04:00
Justin Ridgewell
f8ab9466d3
Move subclass inheritance to end (#7772)
We were using `Object.create` to setup the prototype chain at the start of the class definition, which lead to #7771.

I was a bit worried about a speed hit, but it seems everyone optimizes the two patterns the same way.
https://jsbench.github.io/#f9fca52407643d96458a35763b201215

Fixes #7771.
2018-04-21 17:31:44 -04:00
Markus Török
6597a472b3 Add "use strict" directive (#7411)
* #7349
- Add "use strict" directive to transformed class bodies

* Update tests (#7349)

* Add test for program with use strict directive (#7349)

* Update tests (#7349)

* Update source mapping (#7349)

* Add test for parent blockStatement with use strict directive (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Update tests (#7349)

* Add test for constructor-only class (#7349)

* Constructor only classes are strict, too

But constructor only that use non-simple parameters must use a strict function wrapper.

* Fix test

* Wrapper not needed if class is already strict

* Revert change to lerna.json
2018-04-10 17:33:38 -04:00
Justin Ridgewell
450a1678f2
Use getProto and setProto helpers (#7675)
Depends on #7674.
2018-04-06 02:54:08 +01:00
Logan Smyth
7cc00cce0d Require output fixture extension to match sourceType output. 2018-03-04 13:31:33 -08:00
Logan Smyth
beb99dfda1 Rename test fixtures using module syntax to .mjs files. 2018-03-04 13:31:32 -08:00
Mateusz Burzyński
d283324f8a
Mark hoisted react constant elements as #__PURE__ (#7372) 2018-02-21 18:58:56 +01:00
Nicolò Ribaudo
8659e1a88c Remove old expected.{js,json} files (#7187) 2018-01-09 13:10:30 -06:00
Raja Sekar
0f42accb87 Renamed files 2018-01-09 15:36:42 +01:00
mtpc
63157159ab Preserve namespaced attributes when throwIfNamespace is false (#7173)
Previously that part would throw since it expects a JSXIdentifier but it (logically) gets a JSXNamespacedName when using a namespaced attribute.
2018-01-08 21:24:02 -08:00
Diogo Franco
f9e0805337
Regenerate fixtures (#7120)
* Update line endings in test fixtures to match current output

* Fix incorrectly set up static-property-tdz fixtures

It seems the fixture runner does not look into subfolders.

* Remove expected file that should not exist

* Reenable disable optimisation test

* Reenable disabled nbsp tests

* Reenable comments between props test

The comments adjacent to children test is still broken so it stays off.
2017-12-28 19:28:05 +09:00
Clement Hoang
1a7194a22f Add JSX Fragment syntax support (#6552)
* Add JSX Fragments to babel-types

* Support JSX fragments in the transform-react-jsx plugin

* Add tests JSX fragments

* Update helper-builder and transform plugin documentations for jsx fragment

* Add generator for jsx fragments

* Add test for jsx fragment generator

* Split jsx transform example into normal and fragment examples

* Remove unnecessary fields from ElementState in babel-helper-builder-react-jsx

* inline [skip ci]
2017-11-03 10:43:48 -04:00
Jakub Beneš
04d2c030be Add a 'throwIfNamespace' option for JSX transform (#6563)
* Added tests for ifThrowNamespace flag

* JSX transformator could work with XMLNamespaces (ifThrowNamespace flag)

* Use template literal instead

* Attempt to reword the message

* Added docs

* Reworded docs

* Reworded docs

* Fixed missing space in error message
2017-10-28 20:44:15 -04:00
Henry Zhu
9ac326b075
remove es20xx prefixes from plugins and rename folders (#6575) 2017-10-28 20:43:15 -04:00
Henry Zhu
691f90a774 Scoped: change test imports to @babel/ [skip ci] 2017-10-16 22:49:56 -04:00
Astha Sharma
3a2b7fe3cd JSX pragma revert (#6195)
* Removed the deprecated jsx pragma detection code and the concerned tests that included jsx-pragma

* Removed extra tests

* Restored packages/babel-plugin-transform-react-jsx/test/fixtures/react/honor-custom-jsx-pragma-option/

* Added JSX_ANNOTATION_REGEX

* Reverted the tests for jsx-pragma-options and removed those which throw deprecated message
2017-09-04 00:25:56 -04:00
Astha Sharma
62c22c7b5d Removed the deprecated jsx pragma detection code (#6145)
* Removed the deprecated jsx pragma detection code and the concerned tests that included jsx-pragma

* Removed extra tests

* Restored packages/babel-plugin-transform-react-jsx/test/fixtures/react/honor-custom-jsx-pragma-option/
2017-08-22 15:29:06 -04:00
Henry Zhu
0f823beeb1 Newlines in fixtures (#6044)
* write newlines for fixtures

* rerun fixtures
2017-08-02 15:35:29 -04:00
Noah Lemen
51a293601b add JSXAttribute visitor function, wraps JSXElement attributes in a JSXExpressionContainer; also adds test fixtures (#6006) 2017-07-25 09:30:32 -04:00
Justin Ridgewell
28ae47a174 Stop mutating nodes (#5963)
* Stop mutating nodes

* Update tests

* linting
2017-07-18 13:24:07 -04:00
Daniel Tschinder
b3372a572d Remove whitespace generation (#5833)
* Remove whitespace generation and rely on default printing

Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines

* Fix a few more fixtures
2017-06-27 21:57:02 -05:00
Henry Zhu
123dce5fcd Hardcode to double quotes, indent to 2 spaces (#5824) 2017-06-05 22:14:37 -05:00
Logan Smyth
6af8e64711 Typecheck much more of the config loading process (#5642)
* Add type declarations for micromatch.

* Enable Flowtype on all config loading.

* Remove unneeded comments.
2017-04-18 09:28:18 -07:00
Alex Rattray
348cc5eeff Use raw value of JSXText and JSXAttribute (#5256) 2017-04-04 15:46:20 +02:00
Sergey Rubanov
292c3ca206 Refactor test packages to use ES modules instead of CJS (#5138) 2017-01-16 11:25:04 -05:00
Logan Smyth
dbc07220ae Revert babel-helper-builder-react-jsx change from #4988 2016-12-17 20:50:03 -08:00
Justin Ridgewell
2bbc36d25e JSXSpreadChildren, throw in transform-react-jsx (#4988) 2016-12-16 15:30:00 -05:00
Brian Ng
fde16f10fa Add useBuiltIns option to helper-builder-react-jsx (#4655) 2016-10-14 21:18:39 +02:00
Eric O'Connell
aef82d190b Preserve whitespace in JSXExpressionContainer StringLiteral children - fixes T7243 2016-03-24 21:17:09 -07:00
Sebastian McKenzie
1fa24b1efd rename babel-plugin-external-helpers-2 to babel-plugin-external-helpers 2015-12-24 03:54:40 +00:00
claudiopro
6d1a6dfc94 Fixes @jsx pragma detection + tests 2015-11-17 22:32:44 +01:00
Sebastian McKenzie
fe5aff09a4 fix remaining babel helper issues 2015-11-11 22:45:50 -08:00