diff --git a/app.plugin.js b/app.plugin.js index 11482ff0..7020f912 100644 --- a/app.plugin.js +++ b/app.plugin.js @@ -1 +1,16 @@ -module.exports = require('./lib/commonjs/expo-plugins'); +const packageJson = require('./package.json'); + +const pkg = { + // Prevent this plugin from being run more than once. + // This pattern enables users to safely migrate off of this + // out-of-tree `@config-plugins/intercom-react-native` to a future + // upstream plugin in `intercom-react-native` + name: packageJson.name, + // Indicates that this plugin is dangerously linked to a module, + // and might not work with the latest version of that module. + version: packageJson.version, +}; + +const plugin = require('./lib/commonjs/expo-plugins'); + +module.exports = plugin.default(pkg); diff --git a/package.json b/package.json index efc83159..f638f70d 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "android", "ios", "cpp", + "app.plugin.js", "intercom-react-native.podspec", "!lib/typescript/example", "!android/build", diff --git a/src/expo-plugins/index.ts b/src/expo-plugins/index.ts index f230866e..c2d40b61 100644 --- a/src/expo-plugins/index.ts +++ b/src/expo-plugins/index.ts @@ -16,7 +16,6 @@ import { insertContentsInsideObjcFunctionBlock, } from '@expo/config-plugins/build/ios/codeMod'; import type { IntercomPluginProps, IntercomRegion } from './@types'; -import packageJson from '../../package.json'; const mainApplication: ConfigPlugin = (_config, props) => withMainApplication(_config, (config) => { @@ -122,19 +121,7 @@ const withIntercomReactNative: ConfigPlugin = ( return newConfig; }; -const pkg = { - // Prevent this plugin from being run more than once. - // This pattern enables users to safely migrate off of this - // out-of-tree `@config-plugins/intercom-react-native` to a future - // upstream plugin in `intercom-react-native` - name: packageJson.name, - // Indicates that this plugin is dangerously linked to a module, - // and might not work with the latest version of that module. - version: packageJson.version, -}; +const configPlugin = (pkg: { name: string; version: string }) => + createRunOncePlugin(withIntercomReactNative, pkg.name, pkg.version); -export default createRunOncePlugin( - withIntercomReactNative, - pkg.name, - pkg.version -); +export default configPlugin;