Unable to publish using babel-plugin-module-resolver

Hi, I’m using module-resolver which is working fine in development but as soon as I try to run “expo publish” I hit:

Unable to resolve module models/TokenType from /mnt/c/dev/langcollab/app/build/app/src/pages/LoadingPageContainer.js:

In my babel.rc file I’ve set production to match the development config exactly. I’ve done all the other recommended steps (deleting .expo folder, cache, restarting pc, reinstalling node modules etc) but am having no luck. Can anyone help me?

{
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": [
        "transform-react-jsx-source",
        ["module-resolver", {
          "root": ["./"],
          "alias": {
            "app": "./build/app/src",
            "models": "./build/shared/models",
            "shared": "./build/shared"
          }
        }]
      ]
    },
    "production": {
      "plugins": [
        "transform-react-jsx-source",
        ["module-resolver", {
          "root": ["./"],
          "alias": {
            "app": "./build/app/src",
            "models": "./build/shared/models",
            "shared": "./build/shared"
          }
        }]
      ]
    }
  }
}

Thanks!

I added a unique prefix for all my aliases (eg. “@myappname/app”: “./build/app/src”) and it fixed the issue. There must have been a name conflict for “TokenType”. I’m curious as to why it didn’t fail in dev though!

NB: I also deleted the production config and removed the module-resolver plugin out of “env” into the top level “plugins” option.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.