Issue with 'exp publish' and 'babel-plugin-module-alias' on detached app

Hey y’all,
First time poster here, moderately long user of Expo. I recently decided to detach my app due to some missing features (IAP being a large one). I was successful in using fastlane to publish a prod version of it, but I saw the following issue:

From here, I saw that meant I needed to run exp publish since the JS was missing, basically.

I am able to successfully run exp start -c in both dev & non-dev mode, however, when I try exp publish, I see the following error:

➜  mobile-app git:(master) ✗ exp publish
[exp] Publishing...
[exp] Building iOS bundle
[exp] Unable to resolve module `utils/Config` from `/Users/stevenfrancus/workspace/Chronaly_UI/mobile-app/App.js`: Module does not exist in the module map
[exp] This might be related to
[exp] To resolve try the following:
[exp]   1. Clear watchman watches: `watchman watch-del-all`.
[exp]   2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
[exp]   3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
[exp] Packager URL http://localhost:19001/./node_modules/react-native-scripts/build/bin/crna-entry.bundle?dev=false&minify=true&hot=false&assetPlugin=expo/tools/hashAssetFiles&platform=ios returned unexpected code 500. Please open your project in the Expo app and see if there are any errors. Also scroll up and make sure there were no errors or warnings when opening your project.

This seems to be related to my use of babel-plugin-module-alias. It seems to work properly but exp publish fails. Any idea why it can’t compile in this case?

Here’s my .babelrc:

  "presets": ["babel-preset-expo"],
  "env": {
    "production": {
      "plugins": [
        "transform-react-jsx-source", ["module-alias", [
          { "src": "./images", "expose": "images" },
          { "src": "./src/actions", "expose": "actions" },
          { "src": "./src/components", "expose": "components" },
          { "src": "./src/configs", "expose": "configs" },
          { "src": "./src/constants", "expose": "constants" },
          { "src": "./src/containers", "expose": "containers" },
          { "src": "./src/i18n", "expose": "i18n" },
          { "src": "./src/stores", "expose": "stores" },
          { "src": "./src/styles", "expose": "styles" },
          { "src": "./src/themes", "expose": "themes" },
          { "src": "./src/utils", "expose": "utils" },
          { "src": "./src", "expose": "src" }

Btw this is also on Expo SDK 19 for iOS.

Thanks in advance!

@notbrent or @ide any familiarity with this?

I suspect the problem is that module-alias wasn’t being used at all till you published because it’s under the production env in your config. Try moving it out to apply to all envs and debug from there.

One other difference is that publishing enables minification in addition to non-dev mode, you could try that. We also recommend module-resolver instead of module-alias, the former is what we use for the expo preset itself.

1 Like

I had the same problem using module-resolver until I changed my utils folder name to utilities. Maybe there’s a naming clash?