Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Auto Import to Babel Plugin (#16626)
This babel transform is a fork of the @babel/plugin-transform-react-jsx transform and is for experimentation purposes only. We don't plan to own this code in the future, and we will upstream this to Babel at some point once we've proven out the concept. As per the RFC to simplify element creation, we want to add the ability to auto import "react' directly from the babel plugin. This commit updates the babel plugin with two options: 1.) importSource: The React module to import from. Defaults to react. 2.) autoImport: The type of import. Defaults to none. - none: Does not import React. JSX compiles to React.jsx etc. - namespace: import * as _react from "react";. JSX compiles to _react.jsx etc. - default: import _default from "react"; JSX compiles to _default.jsx etc. - namedExports: import {jsx as _jsx} from "react"; JSX compiles to _jsx etc. - require: var _react = _interopRequireWildcard(require("react"));. jSX compiles to _react.jsx etc. namespace, default, and namedExports can only be used when sourceType: module and require can only be used when sourceType: script. It also adds two pragmas (jsxAutoImport and jsxImportSource) that allow users to specify autoImport and importSource in the docblock.
- Loading branch information