No Description

metro.config.windows.js 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * Metro configuration for React Native
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. */
  7. const fs = require('fs');
  8. const path = require('path');
  9. const blacklist = require('metro-config/src/defaults/blacklist');
  10. const rnPath = fs.realpathSync(
  11. path.resolve(require.resolve('react-native/package.json'), '..'),
  12. );
  13. const rnwPath = fs.realpathSync(
  14. path.resolve(require.resolve('react-native-windows/package.json'), '..'),
  15. );
  16. module.exports = {
  17. resolver: {
  18. extraNodeModules: {
  19. // Redirect react-native to react-native-windows
  20. 'react-native': rnwPath,
  21. 'react-native-windows': rnwPath,
  22. },
  23. // Include the macos platform in addition to the defaults because the fork includes macos, but doesn't declare it
  24. platforms: ['ios', 'android', 'windesktop', 'windows', 'web', 'macos'],
  25. // Since there are multiple copies of react-native, we need to ensure that metro only sees one of them
  26. // This should go in RN 0.61 when haste is removed
  27. blacklistRE: blacklist([
  28. new RegExp(
  29. `${(path.resolve(rnPath) + path.sep).replace(/[/\\]/g, '/')}.*`,
  30. ),
  31. // This stops "react-native run-windows" from causing the metro server to crash if its already running
  32. new RegExp(
  33. `${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`,
  34. ),
  35. // Avoid error EBUSY: resource busy or locked, open '...\vnext\msbuild.ProjectImports.zip' when building 'vnext\Microsoft.ReactNative.sln' with '/bl'
  36. /.*\.ProjectImports\.zip/,
  37. ]),
  38. },
  39. transformer: {
  40. getTransformOptions: async () => ({
  41. transform: {
  42. experimentalImportSupport: false,
  43. inlineRequires: false,
  44. },
  45. }),
  46. },
  47. };