fix: ESM module compatibility for EAS builds#30
fix: ESM module compatibility for EAS builds#30V3RON merged 1 commit intocallstackincubator:mainfrom
Conversation
|
@tarikfp is attempting to deploy a commit to the Callstack Team on Vercel. A member of the Team first needs to authorize it. |
|
Please split the pull request into two: one for the target name and a second for the ESM. The first change introduces a new feature, the second is a fix. They should live as separate commits on the main branch. |
a0e0af7 to
5dae58a
Compare
|
There is one issue: when you build your module using the
|
1. Added postprepare script to create build/package.json with {"type": "module"}
This marks the build/ directory as ESM and survives expo-module rebuilds
2. Changed static import to dynamic import for voltra/server in prerender.ts
Fixes build errors during EAS builds:
- "Cannot use import statement outside a module"
- "Cannot find module 'voltra/server'"
5dae58a to
69a1336
Compare
Right, updated the PR. |
Summary
Fix ESM module compatibility issues that cause build failures during EAS builds.
Issues Fixed
Error 1: Cannot use import statement outside a module
The
voltra/build/server.jsuses ESM syntax (import/export) but Node.js treats it as CommonJS because there's nopackage.jsonwith"type": "module"in thebuild/directory.Error 2: Cannot find module 'voltra/server'
Static import of
voltra/serverin the plugin fails when compiled to CommonJS.Fix
postpreparescript to createbuild/package.jsonwith{"type": "module"}expo-modulerebuilds (unlike a static file that gets cleared)prerenderWidgetStatefunctionChanges
package.json- Addedpostpreparescript to create ESM marker after buildsplugin/src/features/ios/files/swift/prerender.ts- Dynamic import for ESM compatibilityChecklist