Rollup Fails on Travis but nowhere else

I am able to successfully run yarn and yarn build locally (on my arm Mac), on a Docker container that matches as exactly as possible Travis’s environment (Focal with Node v18.7.0), and on a Focal/amd64 machine. But on Travis, builds fail and I cannot for the life of me reproduce it.

Here is a failing build: Travis CI - Test and Deploy with Confidence

The error looks like it’s related to Babel or to my Rollup config, but I can’t see anything wrong and the fact that builds work everywhere else suggests that the config is fine. Could Travis be ignoring the .babelrc file?

On Travis:

$ yarn --frozen-lockfile
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ yarn run build
yarn run v1.22.19
$ rollup -c rollup.config.js
src/index.jsx → build/umd/index.js, build/mjs/index.mjs...
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
src/ModalProvider.jsx (27:4)
25: 
26:   return (
27:     <Provider
        ^

On Docker:

root@05bd9d7ca153:/opt/styled-react-modal# yarn --frozen-lockfile
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ yarn run build
yarn run v1.22.19
$ rollup -c rollup.config.js

src/index.jsx → build/umd/index.js, build/mjs/index.mjs...
created build/umd/index.js, build/mjs/index.mjs in 4.4s
Done in 6.21s.
Done in 84.03s.

On a Focal/amd64 machine:

alex@hsrv:~/tmp/AlexanderRichey/styled-react-modal$ yarn --frozen-lockfile
yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
$ yarn run build
yarn run v1.22.19
$ rollup -c rollup.config.js

src/index.jsx → build/umd/index.js, build/mjs/index.mjs...
created build/umd/index.js, build/mjs/index.mjs in 802ms
Done in 1.11s.
Done in 4.15s.

I had to switch to another CI provider to solve the problem. :frowning_face:

The exact same code worked fine with the other provider — CircleCI — so this seems like it could be a bug in Travis. I hope the team fixes this issue.