fix: Cannot access 'pageInterpolatorCube' before initialization #38
+109
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This "fix" contains scripts related to the build process.
fix-exports.js
Purpose
Fixes the "exports before definition" issue in CommonJS compiled output.
The Problem
When using TypeScript with named exports of functions, the CommonJS compilation often places exports at the top of the file, before the actual function definitions:
This causes runtime errors in JavaScript environments with the error message:
Attempted Solutions
We tried several approaches with Babel configuration before settling on this post-build script:
Using
lazy: truein the CommonJS transform plugin@babel/plugin-transform-modules-commonjswithlazy: trueoptionCustom Babel presets and plugins
Modifying react-native-builder-bob configuration
Proposed Solution
The
fix-exports.jsscript runs after the build process and:This approach:
Usage
The script is automatically called in the
buildcommand in package.json:If you can fix this in a better way, please help. Otherwise feel free to use this script as a post package install band-aid