Skip to content

Error updating Onyx in App #9163

Closed
Closed

Description

@luacmartins

Problem

Coming from this thread, updating Onyx to the latest hash f11e7c1949916a81c36c17dd87919dd532d4620f results in the following console error on Web (native platforms seem to work).

error2

Why is this important

We need to release new Onyx functionality that is blocking our roadmap.

Solution

Seems to have been introduced here - Expensify/react-native-onyx#132

We think that webpack is resolving to the browser entry point when using Onyx on web. We need to find a way to point it to react-native

Note: It's also possible that the cause of the issue is something else

Activity

  1. luacmartins commented on May 24, 2022

    @luacmartins
    ContributorAuthor

    @kidroca I can't assign you, but would you mind working on this?

  2. added
    Improvement
    on May 24, 2022
  3. kidroca commented on May 25, 2022

    @kidroca
    Contributor

    @luacmartins yes (You should be able to assign me after this comment)

  4. kidroca commented on May 25, 2022

    @kidroca
    Contributor

    Looks like we need to remove 'react-native-onyx' from the list of included modules here:

    const includeModules = [
    'react-native-animatable',
    'react-native-reanimated',
    'react-native-picker-select',
    'react-native-web',
    'react-native-webview',
    '@react-native-picker',
    'react-native-modal',
    'react-native-onyx',
    'react-native-gesture-handler',
    'react-native-flipper',
    'react-native-google-places-autocomplete',
    ].join('|');

    includeModules is a list of modules we tell webpack to transpile, but since Onyx (browser) is already transpiled (has no import/export statements) it messes up Webpack

    (This also means that for any Onyx update we should remember to run npm run build in order to update dist code)
    (dist code is imported by Webpack due to the browser package.json field in Onyx)
    (The PR here Expensify/react-native-onyx#133, didn't do so, so Onyx.update is not available in web)


    Another option might be to go back to the react-native-onyx/web idea, because it'll still allow us to import react-native-onyx in App (web and native) and edit its source in node_modules, while other projects can import Onyx from react-native-onyx/web

  5. kidroca commented on May 25, 2022

    @kidroca
    Contributor

    It seems we need to do 2 things

    • in Onyx: run npm run build in order to update the code in dist, then merge that to main
    • in App: open a PR that removes react-native-onyx from includeModules and updates package.json with the latest Onyx hash
  6. luacmartins commented on May 25, 2022

    @luacmartins
    ContributorAuthor

    Both PRs are merged and this issue is fixed! I'll move the discussion about the other solutions back to Slack. Thanks @kidroca!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

DailyImprovement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions