32 Commits
Author SHA1 Message Date
Nicolò RibaudoandGitHub 1255a2af9a Use type: module in all package.jsons (#16535)
* Use `type: module` in all `package.json`s

* Remove now unnecessary `{ "type": "module" }` package.jsons

* Use `type: commonjs` where needed
2024-05-30 09:27:35 +02:00
Nicolò RibaudoandGitHub 3c210ed5b3 Inline exports.XXX = update in simple variable declarations (#15984) 2023-09-19 16:25:14 +02:00
b70f712746 Reverts "Re-use common JSX element transform for <>...</>" (#15355)
* Reverts "Re-use common JSX element transform for <>...</>"

* add a regression test

* fix Babel 8 test error

* Update fixtures (Windows)

* disable the regression test on Babel 8

Co-authored-by: Babel Bot <[email protected]>
2023-01-20 13:24:35 -05:00
26092a188f Re-use common JSX element transform for <>...</> (#15047)
* Re-use common JSX element transform for `<>...</>`

* Avoid trailing `void 0` params

* Update fixtures (Windows)

Co-authored-by: Babel Bot <[email protected]>
2022-12-13 21:43:52 +01:00
65b1f4e89e Improve comments generation (#14979)
Co-authored-by: Nicolò Ribaudo <[email protected]>
2022-10-09 17:21:02 +02:00
Nicolò RibaudoandGitHub df22d9da48 Run tests in a native Node.js ESM environment (#13966) 2021-12-03 15:32:58 +01:00
Nicolò RibaudoandGitHub ad0dd901a2 Avoid using CJS globals in internal source files (#12963)
* Lint against CJS globals in modules

* Use `import.meta.url` instead of `__filename` in `src` files

* Prepare fixtures runner for `import.meta.url`

* Use `import.meta.url` instead of `__filename` in `test/index` files

* Remove `__dirname` from remaining test files

dirname

* Avoid using `module` in `src` files

* Avoid using `require` in `src` files

* Avoid using `require` in `test` files

* Update `@types/node`

* Compile dynamic import in `@babel/node`

* Fix windows

* Use `@babel/plugin-proposal-dynamic-import` from npm
2021-03-05 19:55:36 +01:00
360e501253 Enable external-helpers by default in tests (#12911)
Co-authored-by: Huáng Jùnliàng <[email protected]>
Co-authored-by: Babel Bot <[email protected]>
2021-02-26 23:33:26 +01:00
3df22f4ed7 [babel 8] Use the JSX automatic runtime by default (#12630)
Co-authored-by: Nicolò Ribaudo <[email protected]>
Co-authored-by: Arun Kumar Mohan <[email protected]>
2021-01-19 01:41:07 +01:00
Nicolò RibaudoandGitHub a7e4db14ab 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
Logan SmythandGitHub d57db9a48c Format fixture JSON with Prettier. (#8658) 2018-09-09 17:57:52 -07:00
Erik ArvidssonandJustin Ridgewell 540ad4e07e 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
Logan Smyth def4a287fe Rename test fixtures using module syntax to .mjs files. 2018-03-04 13:31:32 -08:00
Nicolò RibaudoandBrian Ng a1c0d724ae Remove old expected.{js,json} files (#7187) 2018-01-09 13:10:30 -06:00
Raja SekarandNicolò Ribaudo 4b5e34de4e Renamed files 2018-01-09 15:36:42 +01:00
Mouad DebbarandLogan Smyth 6e4ce5ff94 Bail out on JSX fragments instead of throwing (#7166)
* Bail out on JSX fragments instead of throwing

The `transform-react-inline-elements` plugin doesn't handle JSX fragments. It throws an exception because `node.openingElement` is undefined.

* Add a comment explaining `node.openingElement`
2018-01-08 21:38:52 -08:00
Henry ZhuandGitHub 5393e73937 remove es20xx prefixes from plugins and rename folders (#6575) 2017-10-28 20:43:15 -04:00
Henry Zhu b59bc74947 Scoped: change test imports to @babel/ [skip ci] 2017-10-16 22:49:56 -04:00
Nicolò RibaudoandHenry Zhu 8052e08520 Use helper-builder-react-jsx inside plugin-transform-react-inline-elements (#6294)
* Use helper-builder-react-jsx inside plugin-transform-react-inline-elements.

This avoids duplicating the logic for converting jsx elements to plain JavaScript.

* Add a comment which explains the _jsx signature, [skip ci]
so it is a little bit easier to understand what all those .splice() calls do
2017-09-26 10:15:27 -04:00
Logan Smyth 4087d4057f Convert CommonJS to use new shared implementation. 2017-09-12 17:17:41 -07:00
Henry ZhuandGitHub 551b23548c Newlines in fixtures (#6044)
* write newlines for fixtures

* rerun fixtures
2017-08-02 15:35:29 -04:00
Daniel TschinderandBrian Ng 5efda75cf8 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
Damien MaillardandHenry Zhu 4218cc86c0 Fix path.remove() leading & trailing comments sharing (#5504) 2017-03-23 11:55:14 -04:00
Sergey RubanovandHenry Zhu f6d768cc53 Refactor test packages to use ES modules instead of CJS (#5138) 2017-01-16 11:25:04 -05:00
Andrew LevineandHenry Zhu 433c61b385 Don't treat JSXIdentifier in JSXMemberExpression as HTML tag. Closes #4027 (#4765) 2016-10-24 10:42:50 -04:00
Andrew LevineandHenry Zhu d0ca24f9fe Handle remapping of JSXIdentifier to MemberExpression in CommonJS transform. Closes #3728 (#4763) 2016-10-24 10:23:43 -04:00
Sebastian McKenzie 1fa24b1efd rename babel-plugin-external-helpers-2 to babel-plugin-external-helpers 2015-12-24 03:54:40 +00:00
Ben Alpert d1b8db1532 React inlining: Refactor to reduce parsing cost
- Have the `jsx` helper do the `defaultProps` work instead of calling `defaultProps` inline.
- Put `key` after `props` and make it optional.
- Inline `children` as rest args instead of in the object.
- Rename `createRawReactElement` to `jsx`. I wish I was kidding.

Most of these are silly microoptimizations. In my test file (based off an internal RN app), this reduces the parsing overhead of inlining from around 1% to 0.1% in JSC and from 0.6% to 0.0% in V8 (compared to element inlining before this commit).

Once parsed, the initial render with inlining is the same speed as not inlining in JSC and ~1% slower in V8. A second initial render in the same context (reusing the function objects, JIT, etc) is 2.0% faster in JSC and 5.5% faster in V8.
2015-11-12 18:05:57 -08:00
Ben Alpert e8ebc7074e React inlining: Make sure some props object always exists 2015-11-11 15:33:43 -08:00
Ben Alpert 07a5bcc04a React inlining: Fix transform for computed key
(This was broken before my last change too.)
2015-11-11 15:27:02 -08:00
Ben Alpert 3cad287233 Use a helper function for React "inlining"
Either due to lower parsing costs or better type inference, this seems
to perform better than direct object inlining. (All along, the main win
was skipping a loop through props, not avoiding a function call.)
2015-11-10 21:10:06 -08:00
Sebastian McKenzie 15969a0904 move all plugin tests out of babel-core and into their appropriate folders 2015-11-08 23:04:10 -08:00