Skip to content

Commit

Permalink
[feat] add expo plugin config options (#172)
Browse files Browse the repository at this point in the history
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 }] 
]
```
  • Loading branch information
kmartinezmedia authored Mar 27, 2023
1 parent 2a70a75 commit 9509f5e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
6 changes: 5 additions & 1 deletion plugin/build/withV8ExpoAdapter.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { ConfigPlugin } from 'expo/config-plugins';
declare const _default: ConfigPlugin<void>;
export type PluginOptions = {
android?: boolean;
ios?: boolean;
};
declare const _default: ConfigPlugin<PluginOptions>;
export default _default;
/**
* Updates **android/app/build.gradle** to add the packaging options
Expand Down
11 changes: 8 additions & 3 deletions plugin/build/withV8ExpoAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.updateIosAppDelegate = exports.updateAndroidAppGradle = void 0;
const config_plugins_1 = require("expo/config-plugins");
const generateCode_1 = require("./generateCode");
const withV8ExpoAdapter = (config) => {
config = withAndroidGradles(config);
config = withIosAppDelegate(config);
const withV8ExpoAdapter = (config, opts) => {
const { android = true, ios = true } = opts ?? {};
if (android) {
config = withAndroidGradles(config);
}
if (ios) {
config = withIosAppDelegate(config);
}
return config;
};
const pkg = require('react-native-v8/package.json');
Expand Down
16 changes: 13 additions & 3 deletions plugin/src/withV8ExpoAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ import type { ConfigPlugin } from 'expo/config-plugins';

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

const withV8ExpoAdapter: ConfigPlugin = (config) => {
config = withAndroidGradles(config);
config = withIosAppDelegate(config);
export type PluginOptions = {
android?: boolean;
ios?: boolean;
}

const withV8ExpoAdapter: ConfigPlugin<PluginOptions> = (config, opts) => {
const { android = true, ios = true } = opts ?? {};
if (android) {
config = withAndroidGradles(config);
}
if (ios) {
config = withIosAppDelegate(config);
}
return config;
};

Expand Down

0 comments on commit 9509f5e

Please sign in to comment.