Skip to content

Commit

Permalink
fix: unbreak expo plugin (#161)
Browse files Browse the repository at this point in the history
get rid of relative import path of package.json

idea from @tomfinney

Co-authored-by: Mike McNamara <[email protected]>
  • Loading branch information
ottob and MikeMcNamara authored Mar 5, 2024
1 parent 8ffa6dd commit a8d20aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
17 changes: 16 additions & 1 deletion app.plugin.js
Original file line number Diff line number Diff line change
@@ -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);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"android",
"ios",
"cpp",
"app.plugin.js",
"intercom-react-native.podspec",
"!lib/typescript/example",
"!android/build",
Expand Down
19 changes: 3 additions & 16 deletions src/expo-plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IntercomPluginProps> = (_config, props) =>
withMainApplication(_config, (config) => {
Expand Down Expand Up @@ -122,19 +121,7 @@ const withIntercomReactNative: ConfigPlugin<IntercomPluginProps> = (
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;

0 comments on commit a8d20aa

Please sign in to comment.