Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when migrating from v0.54.0 to v0.55.0 #476

Open
AshwinDeTaeye opened this issue Jul 26, 2022 · 7 comments
Open

Issue when migrating from v0.54.0 to v0.55.0 #476

AshwinDeTaeye opened this issue Jul 26, 2022 · 7 comments
Labels
🤞 maybe fixed? Maybe it is fixed 🤷‍♂️ more info required More info is required

Comments

@AshwinDeTaeye
Copy link

AshwinDeTaeye commented Jul 26, 2022

When updating the mobx-keystone package in a react native app from v0.54.0 to v0.55.0 i have the following error:

ERROR    TypeError: undefined is not a function, js engine: hermes
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes

I have previously migrated most of my other apps without issue ( node, electron )
It seems to only be with react native.

babel.config.js

module.exports = {
  presets: [
    // If you use TypeScript
    ["@babel/preset-typescript", { allowDeclareFields: true }],
    [
      "module:metro-react-native-babel-preset",
      {
        unstable_disableES6Transforms: true,
      },
    ],
  ],
  env: {
    production: {},
  },
  plugins: [
    // MobX 5/6
    [
      "@babel/plugin-proposal-decorators",
      {
        legacy: true,
      },
    ],
    ["@babel/plugin-proposal-class-properties", { loose: true }],
    ["@babel/plugin-proposal-optional-catch-binding"],
  ],
}

package.json

    "react-native": "^0.63.4",
    "react": "16.14.0",
    "mobx": "^6.6.1",
    "mobx-keystone": "^0.55.0",
    "mobx-keystone-persist": "^1.2.0",
    "mobx-react": "^7.5.2",
    "mobx-react-lite": "^3.4.0",

Does anybody have similar experiences?
All versions from 0.55.0 on have this issue.

Kr,

@xaviergonz
Copy link
Owner

does it also happen if you use another engine instead of hermes?

@AshwinDeTaeye
Copy link
Author

When i set /android/build/build.gradle to:

project.ext.react = [
enableHermes: false, // clean and rebuild if changing
]

It stays the same. I also updated the hermes engine from 0.5.2 to 0.11.0 without effect.

@xaviergonz
Copy link
Owner

If you edit this line from the package.json inside node_modules/mobx-keystone to this:
"react-native": "./src/index.ts",
does it work then?

@AshwinDeTaeye
Copy link
Author

AshwinDeTaeye commented Jul 29, 2022

With Hermes 'off' and "react-native": "./src/index.ts", it gives following error:

[email protected] & 0.60.5 without Hermes

ERROR    TypeError: (0, _mobxKeystone.prop_dateString) is not a function. (In '(0, _mobxKeystone.prop_dateString)()', '(0, _mobxKeystone.prop_dateString)' is undefined)
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

For this, I should refactor quite a bit, I've done it before in other migrations. I'll do it in the next week and try again.
However the two last errors seem similar to the ones before.

When I set Hermes back on I have the same error as initially
[email protected] & 0.60.5 with Hermes

ERROR    TypeError: undefined is not a function, js engine: hermes
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication), js engine: hermes

[email protected]

error: Error: While trying to resolve module `mobx-keystone` from file `/home/u/git/CamePrinterLast/app/models/root-store.ts`, the package `/home/u/git/CamePrinterLast/node_modules/mobx-keystone/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved...

Logic, since the src doesn't exist in 0.50

Thanks for the support yet, your package has been very helpful since the start!

@xaviergonz
Copy link
Owner

What if besides the other change you also set "sideEffects": true in the package.json?

@xaviergonz
Copy link
Owner

I just published v0.69.7 which has some changes that make it work for expo (the previous one was not), could you check if it works now?

@AshwinDeTaeye
Copy link
Author

AshwinDeTaeye commented Aug 1, 2022

It's the same with 0.69.7

ERROR    TypeError: (0, _mobxKeystone.prop_dateString) is not a function. (In '(0, _mobxKeystone.prop_dateString)()', '(0, _mobxKeystone.prop_dateString)' is undefined)
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
  • Hermes off

In node_modules/mox-keystone package.json:

  • "sideEffects": true
  • "react-native": "./src/index.ts"

@xaviergonz xaviergonz added 🐛 bug Something isn't working 👨‍💻 has PR A PR that potentially fixes the issue exists 🎈 released A fix that should close the issue has been released 📑 merged to master Feature done and merged to master and removed 🐛 bug Something isn't working 👨‍💻 has PR A PR that potentially fixes the issue exists 🎈 released A fix that should close the issue has been released 📑 merged to master Feature done and merged to master labels Oct 7, 2022
@xaviergonz xaviergonz added 🤞 maybe fixed? Maybe it is fixed 🤷‍♂️ more info required More info is required labels Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤞 maybe fixed? Maybe it is fixed 🤷‍♂️ more info required More info is required
Projects
None yet
Development

No branches or pull requests

2 participants