Skip to content

Commit a8d20aa

Browse files
ottobMikeMcNamara
andauthored
fix: unbreak expo plugin (#161)
get rid of relative import path of package.json idea from @tomfinney Co-authored-by: Mike McNamara <[email protected]>
1 parent 8ffa6dd commit a8d20aa

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

app.plugin.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
module.exports = require('./lib/commonjs/expo-plugins');
1+
const packageJson = require('./package.json');
2+
3+
const pkg = {
4+
// Prevent this plugin from being run more than once.
5+
// This pattern enables users to safely migrate off of this
6+
// out-of-tree `@config-plugins/intercom-react-native` to a future
7+
// upstream plugin in `intercom-react-native`
8+
name: packageJson.name,
9+
// Indicates that this plugin is dangerously linked to a module,
10+
// and might not work with the latest version of that module.
11+
version: packageJson.version,
12+
};
13+
14+
const plugin = require('./lib/commonjs/expo-plugins');
15+
16+
module.exports = plugin.default(pkg);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"android",
1414
"ios",
1515
"cpp",
16+
"app.plugin.js",
1617
"intercom-react-native.podspec",
1718
"!lib/typescript/example",
1819
"!android/build",

src/expo-plugins/index.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
insertContentsInsideObjcFunctionBlock,
1717
} from '@expo/config-plugins/build/ios/codeMod';
1818
import type { IntercomPluginProps, IntercomRegion } from './@types';
19-
import packageJson from '../../package.json';
2019

2120
const mainApplication: ConfigPlugin<IntercomPluginProps> = (_config, props) =>
2221
withMainApplication(_config, (config) => {
@@ -122,19 +121,7 @@ const withIntercomReactNative: ConfigPlugin<IntercomPluginProps> = (
122121
return newConfig;
123122
};
124123

125-
const pkg = {
126-
// Prevent this plugin from being run more than once.
127-
// This pattern enables users to safely migrate off of this
128-
// out-of-tree `@config-plugins/intercom-react-native` to a future
129-
// upstream plugin in `intercom-react-native`
130-
name: packageJson.name,
131-
// Indicates that this plugin is dangerously linked to a module,
132-
// and might not work with the latest version of that module.
133-
version: packageJson.version,
134-
};
124+
const configPlugin = (pkg: { name: string; version: string }) =>
125+
createRunOncePlugin(withIntercomReactNative, pkg.name, pkg.version);
135126

136-
export default createRunOncePlugin(
137-
withIntercomReactNative,
138-
pkg.name,
139-
pkg.version
140-
);
127+
export default configPlugin;

0 commit comments

Comments
 (0)