Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-preset-expo

Package Overview
Dependencies
Maintainers
20
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-preset-expo - npm Package Compare versions

Comparing version 8.1.0 to 8.2.0

49

index.js

@@ -5,7 +5,18 @@ const lazyImportsBlacklist = require('./lazy-imports-blacklist');

const { web = {}, native = {} } = options;
const isWeb = api.caller(isTargetWeb);
const platformOptions = isWeb
? { disableImportExportTransform: true, ...web }
: { disableImportExportTransform: false, ...native };
const bundler = api.caller(getBundler);
const isWebpack = bundler === 'webpack';
let platform = api.caller(getPlatform);
// If the `platform` prop is not defined then this must be a custom config that isn't
// defining a platform in the babel-loader. Currently this may happen with Next.js + Expo web.
if (!platform && isWebpack) {
platform = 'web';
}
const platformOptions =
platform === 'web'
? { disableImportExportTransform: true, ...web }
: { disableImportExportTransform: false, ...native };
// Note that if `options.lazyImports` is not set (i.e., `null` or `undefined`),

@@ -44,3 +55,4 @@ // `metro-react-native-babel-preset` will handle it.

[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
isWeb && [require.resolve('babel-plugin-react-native-web')],
platform === 'web' && [require.resolve('babel-plugin-react-native-web')],
isWebpack && platform !== 'web' && [require.resolve('./plugins/disable-ambiguous-requires')],
].filter(Boolean),

@@ -79,4 +91,27 @@ };

function isTargetWeb(caller) {
return caller && caller.name === 'babel-loader';
function getPlatform(caller) {
return caller && caller.platform;
}
/**
* Get the name of the `bundler`.
*
* @param {*} caller
*/
function getBundler(caller) {
if (!caller) return null;
const { bundler, name } = caller;
if (!bundler) {
if (name === 'metro') {
// This is a hack to determine if metro is being used.
return 'metro';
} else if (name === 'babel-loader') {
// This won't work in all cases as tools like Next.js could change the name of their loader.
return 'webpack';
}
}
// Perhaps we should add a check to log once when an unexpected bundler is being used.
return bundler || null;
}

4

package.json
{
"name": "babel-preset-expo",
"version": "8.1.0",
"version": "8.2.0",
"description": "The Babel preset for Expo projects",

@@ -57,3 +57,3 @@ "main": "index.js",

},
"gitHead": "3ad68bbd9847ebc8a55272c263b17d998a92f64f"
"gitHead": "d0ab2ab84b3aa64c69575167b0e59b8ab44c85eb"
}

@@ -12,2 +12,33 @@ # babel-preset-expo

## Expo Bundler Spec Compliance
A bundler must follow these requirements if they are to be considered spec compliant for use with a **universal React** (Expo) project.
### Babel Loader
The babel loading mechanism must include the following properties on its `caller`.
#### platform
A `platform` property denoting the target platform. If the `platform` is not defined, it will default to using `web` when the `bundler` is `webpack` -- this is temporary and will throw an error in the future.
| Value | Description |
| --------- | ----------------------- |
| `ios` | Runs on iOS devices |
| `android` | Runs on Android devices |
| `web` | Runs in web browsers |
#### bundler
A `bundler` property denoting the name of the bundler that is being used to create the JavaScript bundle.
If the `bundler` is not defined, it will default to checking if a `babel-loader` is used, if so then `webpack` will be used, otherwise it will default to `metro`.
| Value | Description |
| --------- | -------------------------------- |
| `metro` | Bundling with [Metro][metro] |
| `webpack` | Bundling with [Webpack][webpack] |
[metro]: https://facebook.github.io/metro/
[webpack]: https://webpack.js.org/
## Options

@@ -14,0 +45,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc