Shopify / flash-list

A better list for React Native
https://shopify.github.io/flash-list/
MIT License
5.36k stars 276 forks source link

Tslib issue after upgrading react-native #896

Open mbrimmer83 opened 1 year ago

mbrimmer83 commented 1 year ago

Current behavior

Bundle error: cannot read property '__extends' of undefined Error doesn't make sense to me, I wouldn't think this tslib version would cause this error. I can remove FlashList and replace it with Flatlist and the error goes away. I can also fix the error by using yarn resolutions "@shopify/flash-list/tslib": "2.6.1"

Expected behavior

FlashList loads without resolutions

To Reproduce

Upgrade React Native to 72.3.2

Platform:

Environment

"@shopify/flash-list": "~1.5.0",

thenglong commented 1 year ago

Also face the same issue.

israromar commented 11 months ago

facing the same issue and it's pointing to the usage of FlashList

simulator_screenshot_624367B6-18F9-4DB3-8D13-2F5EAFC09A32

nvsd commented 9 months ago

I'm also getting this error.

rohanddave commented 9 months ago

Facing the same problem

mbrimmer83 commented 9 months ago

@thenglong @nvsd @rohanddave @israromar Currently I'm still using resolutions to resolve this. I haven't looked at any of the new releases, but I'm assuming the issue hasn't been resolved.

"resolutions": {
    "@shopify/flash-list/tslib": "2.6.1"
  }
ludwig-pro commented 4 months ago

So do I ... weird error

MattiaDellOca commented 3 months ago

I was facing an error very similar to yours: TypeError: Cannot read property '__extends' of undefined, js engine: hermes. Note that I'm not using @shopify/flash-list, but I think that the root problem is common here.

I managed to solve the issue thanks to this well-written article.

As suggested in the article, what fixed the error for me was modifying my Webpack config when resolving tslib:

alias: {
    "tslib": "./node_modules/tslib/tslib.es6.js",
},
ArvidAnderson commented 2 months ago

I have the same issue.

bertoabist commented 1 month ago

Resolve the issue in you metro config resolve request. For example like this (expo): Full docs

const { getDefaultConfig } = require('expo/metro-config');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

const ALIASES = {
  tslib: path.resolve(__dirname, "node_modules/tslib/tslib.es6.js"),
};

config.resolver.resolveRequest = (context, moduleName, platform) => {
  // Ensure you call the default resolver.
  return context.resolveRequest(
    context,
    // Use an alias if one exists.
    ALIASES[moduleName] ?? moduleName,
    platform
  );
};

module.exports = config;