kristerkari / react-native-svg-transformer

Import SVG files in your React Native project the same way that you would in a Web application.
MIT License
1.58k stars 115 forks source link

TypeError: Cannot read properties of undefined (reading 'has') #295

Open komailabbas12 opened 1 year ago

komailabbas12 commented 1 year ago

I am using monorepo(NX). nx automatically update the metro packages which are inside node_module/@nx/react-native. my react native package is 0.71.8 and my metro.config.js file is `const { withNxMetro } = require('@nx/react-native'); const { getDefaultConfig } = require('metro-config'); const exclusionList = require('metro-config/src/defaults/exclusionList');

module.exports = (async () => {
  const {
    resolver: { sourceExts, assetExts },
  } = await getDefaultConfig();
  return withNxMetro(
    {
      transformer: {
        getTransformOptions: async () => ({
          transform: {
            experimentalImportSupport: false,
            inlineRequires: true,
          },
        }),
        babelTransformerPath: require.resolve('react-native-svg-transformer'),
      },
      resolver: {
        assetExts: assetExts.filter((ext) => ext !== 'svg'),
        sourceExts: [...sourceExts, 'svg'],
        blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
      },
    },
    {
      // Change this to true to see debugging info.
      // Useful if you have issues resolving modules
      debug: false,
      // all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
      extensions: [],
      // the project root to start the metro server
      projectRoot: __dirname,
      // Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
      watchFolders: [],
    }
  );
})();

now the error is in isAssetFile.js which are in node_modules/@nx/react-native/node_modules/metro-resolver/src/utils/isAssetFile.js

MrCox007 commented 8 months ago

Got the same when building for android, not ios.

Edit: Upgraded to expo: 50.0.4 and the error is gone.

alexlevy0 commented 6 months ago

same issue without expo

LukasMik commented 2 months ago

Have the same problem, but with expo-updates package