Skip to content

Uniwind causes build failure on Expo 55 when enabling tree shaking #500

@brianangulo

Description

@brianangulo

What happened?

When exporting the JS bundle Expo 55 builds fail if tree shaking is enabled, refer to: https://docs.expo.dev/guides/tree-shaking/

In other words when setting the following 2 environment variables:

EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH=1 EXPO_UNSTABLE_TREE_SHAKING=1

We get the following error:

Failed to generate Hermes bytecode for: /Users/brian/Main/Repos/min-repro-uniwind/node_modules/expo-router/entry.js

/var/folders/kp/nztmcczn5yz24k6mkw358kd00000gp/T/expo-bundler-0.9447713334643474-1776695548458/index.js:76766:1: error: 'import' statement requires module mode
import { Uniwind } from 'uniwind';
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: /Users/brian/Main/Repos/min-repro-uniwind/node_modules/hermes-compiler/hermesc/osx-bin/hermesc -emit-binary -out /var/folders/kp/nztmcczn5yz24k6mkw358kd00000gp/T/expo-bundler-0.9447713334643474-1776695548458/index.hbc /var/folders/kp/nztmcczn5yz24k6mkw358kd00000gp/T/expo-bundler-0.9447713334643474-1776695548458/index.js -O exited with non-zero code: 2

We would expect uniwind to not cause a failure in this case, when tree shaking is disabled the build succeeds.

Steps to Reproduce

  1. Clone reproducible repo
  2. Install packages via bun i
  3. Run a JS bundle export step via with tree shaking enabled EXPO_UNSTABLE_METRO_OPTIMIZE_GRAPH=1 EXPO_UNSTABLE_TREE_SHAKING=1 npx expo export --platform android
  4. See failure

Snack or Repository Link

https://github.com/brianangulo/min-repro-uniwind

Uniwind version

1.6.2

React Native Version

0.83.2

Platforms

Android, iOS

Expo

Yes

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions