Skip to content

Commit 9509f5e

Browse files
[feat] add expo plugin config options (#172)
I'd like to be able to configure if v8 is applied to iOS build. I would expect to be able to configure like this in my expo app.config.js. ``` plugins: [ ['react-native-v8', { android: true, ios: false }] ] ```
1 parent 2a70a75 commit 9509f5e

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

plugin/build/withV8ExpoAdapter.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import type { ConfigPlugin } from 'expo/config-plugins';
2-
declare const _default: ConfigPlugin<void>;
2+
export type PluginOptions = {
3+
android?: boolean;
4+
ios?: boolean;
5+
};
6+
declare const _default: ConfigPlugin<PluginOptions>;
37
export default _default;
48
/**
59
* Updates **android/app/build.gradle** to add the packaging options

plugin/build/withV8ExpoAdapter.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
exports.updateIosAppDelegate = exports.updateAndroidAppGradle = void 0;
44
const config_plugins_1 = require("expo/config-plugins");
55
const generateCode_1 = require("./generateCode");
6-
const withV8ExpoAdapter = (config) => {
7-
config = withAndroidGradles(config);
8-
config = withIosAppDelegate(config);
6+
const withV8ExpoAdapter = (config, opts) => {
7+
const { android = true, ios = true } = opts ?? {};
8+
if (android) {
9+
config = withAndroidGradles(config);
10+
}
11+
if (ios) {
12+
config = withIosAppDelegate(config);
13+
}
914
return config;
1015
};
1116
const pkg = require('react-native-v8/package.json');

plugin/src/withV8ExpoAdapter.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,19 @@ import type { ConfigPlugin } from 'expo/config-plugins';
44

55
import { mergeContents, MergeResults } from './generateCode';
66

7-
const withV8ExpoAdapter: ConfigPlugin = (config) => {
8-
config = withAndroidGradles(config);
9-
config = withIosAppDelegate(config);
7+
export type PluginOptions = {
8+
android?: boolean;
9+
ios?: boolean;
10+
}
11+
12+
const withV8ExpoAdapter: ConfigPlugin<PluginOptions> = (config, opts) => {
13+
const { android = true, ios = true } = opts ?? {};
14+
if (android) {
15+
config = withAndroidGradles(config);
16+
}
17+
if (ios) {
18+
config = withIosAppDelegate(config);
19+
}
1020
return config;
1121
};
1222

0 commit comments

Comments
 (0)