Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Commit

Permalink
feat: Add Expo Support for React Native Preset (#183)
Browse files Browse the repository at this point in the history
#### Changes Made

This pull request introduces support for Expo in the React Native
preset. Expo projects typically utilize the `main` key in `package.json`
as their entry point, linking to `AppEntry.js`.

#### Purpose

The addition of Expo support ensures that unimported will seamlessly
integrate with Expo out of the box. This enhancement is crucial for Expo
React Native projects, providing a smoother development experience.

Please review the changes and provide any feedback or suggestions. Your
input is greatly appreciated.

Thank you!
  • Loading branch information
Fritsch-Tech authored Oct 1, 2023
1 parent 70ef403 commit 3bdca14
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/presets/react-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,40 @@ function getEntry(target: string, rootExtensions: string[]) {
},
};
}

function getExpo(options, rootExtensions: string[]) {
const expoEntry = options.packageJson.main;

if (!expoEntry) {
return;
}

const [file] = resolveFilesSync([expoEntry], rootExtensions);

if (!file) {
return;
}
return {
file,
label: 'expo',
extend: {
extensions: rootExtensions,
},
};
}
const preset: Preset = {
name: 'react-native',
isMatch: ({ hasPackage }) => hasPackage('react-native'),
getConfig: async (options) => {
const base = await nodePreset.getConfig(options);
const extensions = base.extensions as string[];

const hasExpo = options.hasPackage('expo');

const entry = [
getEntry('android', extensions),
getEntry('ios', extensions),
hasExpo ? getExpo(options, extensions) : undefined,
].filter(typedBoolean);

return {
Expand Down

0 comments on commit 3bdca14

Please sign in to comment.