New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-preset-expo

Package Overview
Dependencies
Maintainers
26
Versions
138
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 0.0.1-canary-20231130-ede75a7-1 to 0.0.1-canary-20231205-250b31f

1

build/common.d.ts

@@ -14,1 +14,2 @@ export declare function hasModule(name: string): boolean;

export declare function getInlineEnvVarsEnabled(caller: any): boolean;
export declare function getAsyncRoutes(caller: any): boolean;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getInlineEnvVarsEnabled = exports.getExpoRouterAbsoluteAppRoot = exports.getIsServer = exports.getBaseUrl = exports.getIsNodeModule = exports.getIsProd = exports.getIsFastRefreshEnabled = exports.getIsDev = exports.getPossibleProjectRoot = exports.getPlatform = exports.getBundler = exports.hasModule = void 0;
exports.getAsyncRoutes = exports.getInlineEnvVarsEnabled = exports.getExpoRouterAbsoluteAppRoot = exports.getIsServer = exports.getBaseUrl = exports.getIsNodeModule = exports.getIsProd = exports.getIsFastRefreshEnabled = exports.getIsDev = exports.getPossibleProjectRoot = exports.getPlatform = exports.getBundler = exports.hasModule = void 0;
const path_1 = __importDefault(require("path"));

@@ -112,1 +112,14 @@ function hasModule(name) {

exports.getInlineEnvVarsEnabled = getInlineEnvVarsEnabled;
function getAsyncRoutes(caller) {
const isServer = getIsServer(caller);
if (isServer) {
return false;
}
const isProd = getIsProd(caller);
const platform = getPlatform(caller);
if (platform !== 'web' && isProd) {
return false;
}
return caller?.asyncRoutes ?? false;
}
exports.getAsyncRoutes = getAsyncRoutes;

4

build/expo-router-plugin.d.ts

@@ -9,5 +9,3 @@ import { ConfigAPI, types } from '@babel/core';

* EXPO_ROUTER_APP_ROOT
* EXPO_ROUTER_IMPORT_MODE_IOS
* EXPO_ROUTER_IMPORT_MODE_ANDROID
* EXPO_ROUTER_IMPORT_MODE_WEB
* EXPO_ROUTER_IMPORT_MODE
*/

@@ -14,0 +12,0 @@ export declare function expoRouterBabelPlugin(api: ConfigAPI & {

@@ -8,3 +8,2 @@ "use strict";

const core_1 = require("@babel/core");
const config_1 = require("expo/config");
const path_1 = __importDefault(require("path"));

@@ -14,40 +13,2 @@ const resolve_from_1 = __importDefault(require("resolve-from"));

const debug = require('debug')('expo:babel:router');
let config;
function getConfigMemo(projectRoot) {
if (!config || process.env._EXPO_INTERNAL_TESTING) {
config = (0, config_1.getConfig)(projectRoot);
}
return config;
}
function getExpoRouterImportMode(projectRoot, platform) {
const envVar = 'EXPO_ROUTER_IMPORT_MODE_' + platform.toUpperCase();
if (process.env[envVar]) {
return process.env[envVar];
}
const env = process.env.NODE_ENV || process.env.BABEL_ENV;
const { exp } = getConfigMemo(projectRoot);
let asyncRoutesSetting;
if (exp.extra?.router?.asyncRoutes) {
const asyncRoutes = exp.extra?.router?.asyncRoutes;
if (typeof asyncRoutes === 'string') {
asyncRoutesSetting = asyncRoutes;
}
else if (typeof asyncRoutes === 'object') {
asyncRoutesSetting = asyncRoutes[platform] ?? asyncRoutes.default;
}
}
let mode = [env, true].includes(asyncRoutesSetting) ? 'lazy' : 'sync';
// TODO: Production bundle splitting
if (env === 'production' && mode === 'lazy') {
throw new Error('Async routes are not supported in production yet. Set the `expo-router` Config Plugin prop `asyncRoutes` to `development`, `false`, or `undefined`.');
}
// NOTE: This is a temporary workaround for static rendering on web.
if (platform === 'web' && (exp.web || {}).output === 'static') {
mode = 'sync';
}
// Development
debug('Router import mode', mode);
process.env[envVar] = mode;
return mode;
}
function getExpoRouterAppRoot(projectRoot, appFolder) {

@@ -67,5 +28,3 @@ // TODO: We should have cache invalidation if the expo-router/entry file location changes.

* EXPO_ROUTER_APP_ROOT
* EXPO_ROUTER_IMPORT_MODE_IOS
* EXPO_ROUTER_IMPORT_MODE_ANDROID
* EXPO_ROUTER_IMPORT_MODE_WEB
* EXPO_ROUTER_IMPORT_MODE
*/

@@ -76,2 +35,3 @@ function expoRouterBabelPlugin(api) {

const possibleProjectRoot = api.caller(common_1.getPossibleProjectRoot);
const asyncRoutes = api.caller(common_1.getAsyncRoutes);
const routerAbsoluteRoot = api.caller(common_1.getExpoRouterAbsoluteAppRoot);

@@ -84,3 +44,2 @@ function isFirstInAssign(path) {

visitor: {
// Convert `process.env.EXPO_ROUTER_APP_ROOT` to a string literal
MemberExpression(path, state) {

@@ -107,2 +66,5 @@ const projectRoot = possibleProjectRoot || state.file.opts.root || '';

}
else if (key.value.startsWith('EXPO_ROUTER_IMPORT_MODE')) {
path.replaceWith(t.stringLiteral(asyncRoutes ? 'lazy' : 'sync'));
}
if (

@@ -121,19 +83,2 @@ // Skip loading the app root in tests.

}
if (!t.isIdentifier(path.node.object, { name: 'process' }) ||
!t.isIdentifier(path.node.property, { name: 'env' })) {
return;
}
const parent = path.parentPath;
if (!t.isMemberExpression(parent.node)) {
return;
}
if (
// Expose the app route import mode.
platform &&
t.isIdentifier(parent.node.property, {
name: 'EXPO_ROUTER_IMPORT_MODE_' + platform.toUpperCase(),
}) &&
!parent.parentPath.isAssignmentExpression()) {
parent.replaceWith(t.stringLiteral(getExpoRouterImportMode(projectRoot, platform)));
}
},

@@ -140,0 +85,0 @@ },

{
"name": "babel-preset-expo",
"version": "0.0.1-canary-20231130-ede75a7-1",
"version": "0.0.1-canary-20231205-250b31f",
"description": "The Babel preset for Expo projects",

@@ -15,4 +15,5 @@ "main": "build/index.js",

"test": "expo-module test",
"prepare": "expo-module clean && expo-module build",
"prepublishOnly": "expo-module prepublishOnly"
"prepare": "expo-module prepare",
"prepublishOnly": "expo-module prepublishOnly",
"expo-module": "expo-module"
},

@@ -56,6 +57,6 @@ "repository": {

"@babel/core": "^7.20.0",
"expo-module-scripts": "0.0.1-canary-20231130-ede75a7-1",
"expo-module-scripts": "0.0.1-canary-20231205-250b31f",
"jest": "^29.2.1"
},
"gitHead": "ede75a72bdcfa7dcf593a0c98f201aa45871da42"
"gitHead": "250b31f516a04578a29c6bcda29aab80ef4d4e2d"
}
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