Giter Site home page Giter Site logo

Comments (9)

andreialecu avatar andreialecu commented on May 2, 2024

bundling failed seems like a weird message, and looks related to building the project, not using it.

Can you explain step by step what you did to receive this error?

from react-native-collapsible-tab-view.

PedroBern avatar PedroBern commented on May 2, 2024

@andreialecu it seems to happen because we are exporting createMaterialCollapsibleTopTabNavigator and MaterialTopTabsCollapsibleTabView even if react-navigation isen't installed. So, if react-navigation is not added as a dependency, it will break the build.

It's easy to reproduce:

  1. Create a new expo project
  2. Add react-native-collapsible-tab-view and the peers (without react-navigation)
  3. Copy the quick start code
  4. expo start should error
  5. add the @react-navigation/... peers
  6. expo start works

Note that the quick start code does not use the navigator. So it should work.

I think the solution is to conditionally export createMaterialCollapsibleTopTabNavigator and MaterialTopTabsCollapsibleTabView , but I was not successful.

The other option is to remove the peerDependenciesMeta , @andreialecu what you think? (thanks for the help)

from react-native-collapsible-tab-view.

andreialecu avatar andreialecu commented on May 2, 2024

I see. I don't use expo so I wasn't familiar with that error signature.

Normally if the material tab files are not imported there shouldn't be any error but I suspect that typescript is interfering. I will take a look in a couple of hours, currently away for a bit.

from react-native-collapsible-tab-view.

PedroBern avatar PedroBern commented on May 2, 2024

Thanks @andreialecu! But don't worry, it's not a priority

from react-native-collapsible-tab-view.

andreialecu avatar andreialecu commented on May 2, 2024

I'm still on mobile but I figured out what the problem is. It's related to these exports:

export { default as MaterialTopTabsCollapsibleTabView } from './MaterialTopTabsCollapsibleTabView';

They should be in a separate file instead of the index. Perhaps one named navigation.tsx so that end users would import them from "react-native-collapsible-tab-view/navigation" instead.

from react-native-collapsible-tab-view.

andreialecu avatar andreialecu commented on May 2, 2024

Upon further investigation, the problem with my proposed approach above is that because of the path structure of the published package, the imports would end up looking like:

import { createMaterialCollapsibleTopTabNavigator } from "react-native-collapsible-tab-view/lib/module/navigation"

Which isn't a great experience...

There's a proposal here that would allow rewriting the imports so that react-native-collapsible-tab-view/navigation would work, but I'm not sure if react native and the metro bundler can use it:
https://nodejs.org/api/packages.html#packages_package_entry_points

Alternatives:

  1. Could make the peer non optional, but users still need to ensure it's installed in their projects. Peers usually just show a warning while installing, which most users ignore. And having it non-optional isn't a great approach for people that don't need react-navigation integration.

  2. Could publish a separate npm package just with the react-navigation integration. Might be do-able, but would need restructuring this project to be a monorepo (via yarn workspaces, for example).

from react-native-collapsible-tab-view.

PedroBern avatar PedroBern commented on May 2, 2024

@andreialecu thanks for the help. Did a quick modification, adding a navigation.tsx to export the navigator, published the @beta version to test, and didn't work. Need to import from .../lib/module/navigation, and something was broken, because the navigator stopped working in my project.

Seems like the best alternative is the 2 you have pointed, I will look into it in the future, but as right now I don't have much time, I will follow the alternative 1.

from react-native-collapsible-tab-view.

PedroBern avatar PedroBern commented on May 2, 2024

As it isn't an optional dependency anymore (in v1.4.2), I'm closing. When there is some extra time, I will look into refactoring into a monorepo.

from react-native-collapsible-tab-view.

345ml avatar 345ml commented on May 2, 2024

Good job guys!!!

from react-native-collapsible-tab-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.