Skip to content

[Bug] frontend/.babelrc shadows babel.config.js and breaks the web bundle #213

Description

@SakethSumanBathini

Summary

npx expo start --web fails to bundle on a clean install, before any application code is reached. The result is a blank page at localhost:8081.

Web Bundling failed 723ms index.js (3 modules)
ERROR  SyntaxError: node_modules/expo/src/Expo.ts: Support for the experimental syntax 'flow' isn't currently enabled (26:8):

> 26 | export type {
     |        ^

Cause

frontend/ contains two Babel configs.

babel.config.js — correct for Expo:

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
  };
};

.babelrc — preset-env only:

{
  "presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}

Babel gives .babelrc precedence for files inside its package root, so babel-preset-expo never loads. Without it there is no Flow support, and Expo's own Flow-typed source can't be parsed — the failure happens in node_modules, not in app code, which is why the error looks unrelated to anything in the repo.

Both files arrived together in #206. I suspect .babelrc was added so Jest could transform tests with preset-env, without it being obvious that it would also take priority over babel.config.js for the bundler.

Verified

Renaming .babelrc out of the way is sufficient:

Web Bundled 7555ms index.js (2505 modules)

and the app renders the login screen normally. With the file in place the bundle fails every time.

Impact

The web target doesn't run at all on a fresh clone.

That also explains how a missing navigation import reached main (#209): web-facing bugs can't be caught locally when the web build never starts. Anyone trying to reproduce #209 hits this first and sees a blank page rather than the reported ReferenceError.

Suggested fix

Remove .babelrc and give Jest its own transform configuration, so the two don't compete. babel-preset-expo handles both the bundler and tests when it's the only config in play.

Worth noting there's currently no jest.config.js and no jest key in package.json, so whatever .babelrc was solving needs re-solving deliberately rather than just deleted.

A separate but related problem

frontend/package.json declares:

"@babel/core": "^8.0.1",
"@babel/preset-env": "^8.0.2",

while expo ~56.0.4 requires Babel 7. npm install prints fifteen ERESOLVE warnings, all of the form peer @babel/core@"^7.0.0-0".

This is not the cause of the bundling failure — I tested with Babel 7 pinned and the identical error appeared, which is what led me to the .babelrc shadowing. But it should be reconciled in the same pass, since it's the kind of mismatch that produces confusing failures later.

Happy to take this if it's free.

Activity

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

Metadata

Metadata

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions