oblador / react-native-vector-icons

Customizable Icons for React Native with support for image source and full styling.
https://oblador.github.io/react-native-vector-icons/
MIT License
17.31k stars 2.12k forks source link

Production build failure due to missing export. 'pick' is not exported from './object-utils' #1420

Open MartijnGevaert opened 2 years ago

MartijnGevaert commented 2 years ago

Environment

I have a react-native app which I also compile for web. This app uses create-react-app which provides the yarn build command, used to create a production build. The app is quite large and contains many dependencies which compile without issue, this makes me suspect that my setup is valid.

Description

When running yarn build, following error is thrown:

 yarn build
Creating an optimized production build...
Failed to compile.

Attempted import error: 'pick' is not exported from './object-utils' (imported as 'pick').

Possible solutions

solution 1

This can be solved by going into object-utils.js and adding export to the const pick and const omit.

export const pick = (obj, ...keys) =>
...
    }, {});

export const omit = (obj, ...keysToOmit) => {
...
};

module.exports = { pick, omit };

solution 2

Replacing module.exports = by export inside object-utils.js

export { pick, omit };

Motivation to implement one of these change

I noticed the files create-icon-set-from-fontawesome5.js and create-icon-source-cache.js already utilize an export {...} so I don't think the changes I suggested will break any functionality.

Reproducible Demo

Can't really create a snack app for this since it only occurs when running the build command

Information needed

I'm far form an expert when it comes to imports and module types. Feedback on which of the 2 provided solutions is best will allow me to create a PR for this.

shinnoki commented 2 years ago

+1

We're also using react-native-vector-icons with react-native-web, and facing same error for production build only.

williamdevitt7 commented 1 year ago
saumitra99 commented 11 months ago

any any update on this?? still facing this issue while running react-native-paper using react-native-web

williamdevitt7 commented 11 months ago

My team used Patch Package to implement MartijnGevaert's solution above in our build, and this has been working for us.

NothingToHere commented 11 months ago

Please try using the @babel/plugin-transform-modules-commonjs plugin