facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.25k stars 626 forks source link

[BUG] Terser mangler issue after upgrading to RN 0.74.5 #1227

Closed dembeEdward closed 9 months ago

dembeEdward commented 9 months ago

What is the current behavior?

I am unable to create source maps after upgrading to RN 0.74.5. Getting the following terser error that did not occur before:

024-02-27T08:34:26.7576460Z                 Welcome to Metro v0.80.6
2024-02-27T08:34:26.7580510Z               Fast - Scalable - Integrated
2024-02-27T08:34:26.7581980Z 
2024-02-27T08:34:26.7583090Z 
2024-02-27T08:36:41.8443570Z error node_modules/ably/build/ably-reactnative.js: Cannot read properties of undefined (reading 'TYPE').
2024-02-27T08:36:41.9430800Z TypeError: Cannot read properties of undefined (reading 'TYPE')
2024-02-27T08:36:41.9484500Z     at shallow_cmp (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:11252:33)
2024-02-27T08:36:41.9490230Z     at equivalent_to (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:11257:10)
2024-02-27T08:36:41.9492390Z     at AST_Number.equivalent_to (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18771:12)
2024-02-27T08:36:41.9493750Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:20979:45
2024-02-27T08:36:41.9494340Z     at AST_Binary.optimize (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18732:19)
2024-02-27T08:36:41.9494900Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18710:24)
2024-02-27T08:36:41.9495460Z     at AST_Binary.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9496610Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:7017:27
2024-02-27T08:36:41.9497310Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9497910Z     at AST_Binary.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9498440Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:7018:29
2024-02-27T08:36:41.9499170Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9500050Z     at AST_Assign.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9500980Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6886:27
2024-02-27T08:36:41.9501890Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9502800Z     at AST_SimpleStatement.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9503650Z     at MAP (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:108:28)
2024-02-27T08:36:41.9504690Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6890:17
2024-02-27T08:36:41.9506290Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9507550Z     at AST_BlockStatement.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9508360Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6907:27
2024-02-27T08:36:41.9508970Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9509590Z     at AST_For.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9510140Z     at MAP (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:108:28)
2024-02-27T08:36:41.9511660Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6975:21
2024-02-27T08:36:41.9513900Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9515730Z     at AST_Function.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9516790Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:7044:45
2024-02-27T08:36:41.9517760Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9518730Z     at AST_ObjectKeyVal.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9519550Z     at MAP (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:108:28)
2024-02-27T08:36:41.9520430Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:7037:23
2024-02-27T08:36:41.9521890Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9522750Z     at AST_Object.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9523530Z     at MAP (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:108:28)
2024-02-27T08:36:41.9525550Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6981:17
2024-02-27T08:36:41.9526460Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9527190Z     at AST_Call.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9527730Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:7018:29
2024-02-27T08:36:41.9528470Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9529160Z     at AST_Assign.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9529740Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6962:45
2024-02-27T08:36:41.9530260Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9530800Z     at AST_VarDef.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9531320Z     at MAP (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:108:28)
2024-02-27T08:36:41.9531840Z     at /Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6957:24
2024-02-27T08:36:41.9532360Z     at Compressor.before (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:18705:9)
2024-02-27T08:36:41.9532940Z     at AST_Var.transform (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:6864:41)
2024-02-27T08:36:41.9533880Z     at MAP (/Users/runner/work/1/s/node_modules/terser/dist/bundle.min.js:108:28)
2024-02-27T08:36:41.9535240Z 
2024-02-27T08:36:41.9577090Z ##[error]Bash exited with code '1'.
2024-02-27T08:36:41.9596320Z ##[section]Finishing: Generate source map

Steps to reproduce

  1. Run react-native bundle --platform ios --dev false --entry-file index.js --bundle-output ios/main.jsbundle --sourcemap-output ios/main.jsbundle.map

Expected behavior

Successful ios source map generation

Operating System

macOS 13.6.4 Node version: v18.19.1 npm version: 10.2.4

Metro config js

const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');

const defaultConfig = getDefaultConfig(__dirname);
const {assetExts, sourceExts} = defaultConfig.resolver;

/**
 * Metro configuration
 * https://facebook.github.io/metro/docs/configuration
 *
 * @type {import('metro-config').MetroConfig}
 */
const config = {
  transformer: {
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
  },
  resolver: {
    assetExts: assetExts.filter(ext => ext !== 'svg'),
    sourceExts: [...sourceExts, 'svg'],
  },
};

module.exports = mergeConfig(defaultConfig, config);

Dependencies

"dependencies": {
    "@braze/react-native-sdk": "^8.3.0",
    "@gorhom/bottom-sheet": "^4.4.7",
    "@hookform/resolvers": "^3.3.2",
    "@intercom/intercom-react-native": "^1.0.4",
    "@notifee/react-native": "^7.8.0",
    "@react-native-clipboard/clipboard": "^1.10.0",
    "@react-native-community/blur": "^4.3.0",
    "@react-native-community/datetimepicker": "^7.6.2",
    "@react-native-community/hooks": "^2.8.0",
    "@react-native-community/netinfo": "^11.0.1",
    "@react-native-community/slider": "^4.5.0",
    "@react-native-firebase/analytics": "^16.7.0",
    "@react-native-firebase/app": "^16.7.0",
    "@react-native-firebase/crashlytics": "^16.7.0",
    "@react-native-firebase/dynamic-links": "^16.7.0",
    "@react-native-firebase/perf": "^16.7.0",
    "@react-native-firebase/remote-config": "^16.7.0",
    "@react-native-masked-view/masked-view": "^0.3.0",
    "@react-navigation/bottom-tabs": "6.4.3",
    "@react-navigation/drawer": "6.5.3",
    "@react-navigation/material-top-tabs": "^6.6.3",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/stack": "^6.2.0",
    "@sayem314/react-native-keep-awake": "^1.0.4",
    "@sentry/react-native": "3.4.3",
    "@shopify/flash-list": "^1.6.3",
    "ably": "^1.2.49",
    "appcenter": "^4.4.5",
    "appcenter-analytics": "^4.4.5",
    "appcenter-crashes": "^4.4.5",
    "axios": "^1.6.0",
    "country-list": "^2.3.0",
    "dayjs": "^1.10.6",
    "deprecated-react-native-prop-types": "^5.0.0",
    "libphonenumber-js": "^1.9.44",
    "lodash": "^4.17.21",
    "lottie-react-native": "^5.1.6",
    "momentjs": "^2.0.0",
    "open-terminal": "^0.1.11",
    "patch-package": "^6.5.0",
    "phone": "^3.1.39",
    "postinstall-postinstall": "^2.1.0",
    "promise.allsettled": "^1.0.3",
    "query-string": "^7.0.0",
    "react": "18.2.0",
    "react-dom": "^18.2.0",
    "react-hook-form": "^7.12.2",
    "react-native": "0.73.5",
    "react-native-actions-sheet": "^0.9.2",
    "react-native-agora": "^4.2.6",
    "react-native-app-auth": "^7.1.0",
    "react-native-biometrics": "^3.0.1",
    "react-native-blob-util": "^0.17.0",
    "react-native-bootsplash": "^4.7.2",
    "react-native-calendar-events": "^2.2.0",
    "react-native-calendars": "^1.1294.0",
    "react-native-chart-kit": "^6.12.0",
    "react-native-circular-progress": "^1.3.9",
    "react-native-code-push": "^8.2.1",
    "react-native-config": "^1.5.1",
    "react-native-country-flag": "^1.1.9",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-device-info": "^10.6.0",
    "react-native-document-picker": "9.1.1",
    "react-native-email-link": "^1.11.3",
    "react-native-fast-image": "8.6.3",
    "react-native-fbsdk-next": "^6.0.0",
    "react-native-freshchat-sdk": "^4.2.1",
    "react-native-fs": "^2.18.0",
    "react-native-gesture-handler": "^2.14.0",
    "react-native-get-random-values": "^1.7.1",
    "react-native-gifted-chat": "^2.0.1",
    "react-native-google-places-autocomplete": "^2.4.1",
    "react-native-hyperlink": "^0.0.19",
    "react-native-image-crop-picker": "^0.40.3",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.6.2",
    "react-native-localize": "^2.2.1",
    "react-native-markdown-display": "^7.0.2",
    "react-native-mmkv-storage": "^0.9.1",
    "react-native-modal-datetime-picker": "^13.0.0",
    "react-native-orientation-locker": "^1.4.0",
    "react-native-pager-view": "^6.2.0",
    "react-native-permissions": "^3.6.1",
    "react-native-phone-number-input": "^2.1.0",
    "react-native-popover-view": "^5.0.0",
    "react-native-reanimated": "^3.6.0",
    "react-native-render-html": "^6.1.0",
    "react-native-root-toast": "3.3.1",
    "react-native-safe-area-context": "^4.8.2",
    "react-native-screens": "^3.28.0",
    "react-native-skeleton-placeholder": "^5.2.4",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-status-bar-height": "^2.6.0",
    "react-native-sticky-parallax-header": "1.0.0-rc.9",
    "react-native-svg": "^14.0.0",
    "react-native-tab-view": "^3.5.2",
    "react-native-toast-message": "^2.1.6",
    "react-native-tracking-transparency": "^0.1.1",
    "react-native-vector-icons": "^9.1.0",
    "react-native-version-number": "^0.3.6",
    "react-native-video": "^5.2.1",
    "react-native-video-controls": "^2.8.1",
    "react-native-webview": "^13.6.1",
    "react-query": "^3.24.4",
    "rn-emoji-picker": "^1.1.6",
    "text-encoding-polyfill": "^0.6.7",
    "unique-names-generator": "^4.7.1",
    "url-parse": "^1.5.10",
    "uuid": "^8.3.2",
    "victory-native": "^36.8.2",
    "yup": "^1.3.2",
    "zustand": "^4.3.9"
  },
  "devDependencies": {
    "@babel/core": "^7.20.12",
    "@babel/plugin-transform-modules-commonjs": "^7.17.7",
    "@babel/plugin-transform-runtime": "^7.17.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.73.21",
    "@react-native/eslint-config": "0.73.2",
    "@react-native/metro-config": "0.73.5",
    "@react-native/typescript-config": "0.73.1",
    "@testing-library/jest-native": "4.0.4",
    "@testing-library/react-hooks": "^7.0.2",
    "@testing-library/react-native": "9.0.0",
    "@types/country-list": "^2.1.1",
    "@types/jest": "^29.2.1",
    "@types/lodash": "^4.14.182",
    "@types/promise.allsettled": "^1.0.3",
    "@types/react": "^18.2.6",
    "@types/react-dom": "^17.0.11",
    "@types/react-native": "0.66.3",
    "@types/react-native-snap-carousel": "^3.8.5",
    "@types/react-native-vector-icons": "^6.4.10",
    "@types/react-native-video": "^5.0.8",
    "@types/react-test-renderer": "^18.0.0",
    "@types/url-parse": "^1.4.8",
    "@types/uuid": "^8.3.3",
    "@typescript-eslint/eslint-plugin": "^5.12.1",
    "@typescript-eslint/parser": "^5.12.1",
    "babel-jest": "^29.6.3",
    "babel-plugin-inline-import": "^3.0.0",
    "babel-plugin-module-resolver": "^5.0.0",
    "detox": "^19.4.1",
    "eslint": "^8.19.0",
    "eslint-import-resolver-alias": "^1.1.2",
    "eslint-import-resolver-typescript": "^2.5.0",
    "eslint-plugin-flowtype": "7.0.0",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-react-native": "^4.0.0",
    "eslint-plugin-react-native-a11y": "^3.0.0",
    "husky": "^7.0.4",
    "jest": "^29.6.3",
    "jest-circus": "^27.4.6",
    "jest-extended": "^2.0.0",
    "jest-mock-axios": "^4.5.0",
    "lint-staged": "^12.1.2",
    "mockdate": "^3.0.5",
    "prettier": "2.8.8",
    "pretty-quick": "^3.1.2",
    "react-native-clean-project": "^4.0.1",
    "react-native-svg-transformer": "^1.1.0",
    "react-test-renderer": "18.2.0",
    "typescript": "5.0.4"
  },