babel-preset-expo 8.5.1 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +28 -1
  2. package/index.js +5 -2
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -44,13 +44,40 @@ If the `bundler` is not defined, it will default to checking if a `babel-loader`
44
44
 
45
45
  ### [`jsxRuntime`](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#runtime)
46
46
 
47
- `classic | automatic`, defaults to `classic`
47
+ `classic | automatic`, defaults to `automatic`
48
48
 
49
49
  - `automatic` automatically convert JSX to JS without the need to `import React from 'react'` in every file. Be sure to follow the rest of the [setup guide](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#how-to-upgrade-to-the-new-jsx-transform) after enabling this, otherwise ESLint and other tools will throw warnings.
50
50
  - `classic` does not automatically import anything, React must imported into every file that uses JSX syntax.
51
51
 
52
+ ```js
53
+ [
54
+ 'babel-preset-expo',
55
+ {
56
+ jsxRuntime: 'classic',
57
+ },
58
+ ];
59
+ ```
60
+
52
61
  This property is passed down to [`@babel/plugin-transform-react-jsx`](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx). This flag does nothing when `native.useTransformReactJSXExperimental` is set to `true` because `@babel/plugin-transform-react-jsx` is omitted.
53
62
 
63
+ ### [`jsxImportSource`](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#importsource)
64
+
65
+ `string`, defaults to `react`
66
+
67
+ This option allows specifying a custom import source for importing functions.
68
+
69
+ ```js
70
+ [
71
+ 'babel-preset-expo',
72
+ {
73
+ jsxRuntime: 'automatic',
74
+ importSource: 'react',
75
+ },
76
+ ];
77
+ ```
78
+
79
+ This property is passed down to [`@babel/plugin-transform-react-jsx`](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx). This options does nothing when `jsxRuntime` is not set to `automatic`.
80
+
54
81
  ### [`lazyImports`](https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#lazy)
55
82
 
56
83
  Changes Babel's compiled `import` statements to be lazily evaluated when their imported bindings are used for the first time.
package/index.js CHANGED
@@ -43,8 +43,11 @@ module.exports = function (api, options = {}) {
43
43
  extraPlugins.push([
44
44
  require('@babel/plugin-transform-react-jsx'),
45
45
  {
46
- // Defaults to `classic`, pass in `automatic` for auto JSX transformations.
47
- runtime: options && options.jsxRuntime,
46
+ // Defaults to `automatic`, pass in `classic` to disable auto JSX transformations.
47
+ runtime: (options && options.jsxRuntime) || 'automatic',
48
+ ...(options?.jsxRuntime !== 'classic' && {
49
+ importSource: (options && options.jsxImportSource) || 'react',
50
+ }),
48
51
  },
49
52
  ]);
50
53
  // Purposefully not adding the deprecated packages:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-preset-expo",
3
- "version": "8.5.1",
3
+ "version": "9.0.0",
4
4
  "description": "The Babel preset for Expo projects",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -56,5 +56,5 @@
56
56
  "@babel/core": "^7.12.9",
57
57
  "jest": "^26.6.3"
58
58
  },
59
- "gitHead": "1fffde73411ee7a642b98f1506a8de921805d52b"
59
+ "gitHead": "2e5c6983b86d5ecfca028ba64002897d8adc2cc4"
60
60
  }