Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

[xdl] fix expo export --dump-sourcemap for sdk 40+ and bare projects #3095

Merged
merged 2 commits into from
Jan 25, 2021

Conversation

esamelson
Copy link
Contributor

Fixes expo/expo#11652

Currently, JS bundles created from expo export --dump-sourcemap do not run in an SDK 40 bare project -- they fail with the familiar Module AppRegistry is not a registered callable module error. The cause seems to be the following lines:

await truncateLastNLines(iosJsPath, 1);
await truncateLastNLines(androidJsPath, 1);

The line that's being truncated is:

eric@Erics-iMac SelfHostTest % cat bundles/android-bcbcf3a727c6c6465382b49ddcf806e8.js
...
__r(0);

The bundles run fine without this line truncated. Since I'm not sure of the context/reasoning around truncating this line in the first place, I've simply added a gate that doesn't truncate for SDK 40+ bare projects.

Test plan

  • self-hosted update created with expo export --dump-sourcemap loads and runs
  • also verified there is only one sourceMappingURL present in the bundle (the one added right below the relevant code in expo-cli):
eric@Erics-iMac SelfHostTest % cat dist/bundles/android-ed94ad221ad84051ddc6d46b5aef6ada.js | grep "sourceMappingURL"
//# sourceMappingURL=android-ed94ad221ad84051ddc6d46b5aef6ada.map

@quinlanj , adding you as a reviewer just in case you remember any context around this from 2 years ago 😅

packages/xdl/src/Project.ts Outdated Show resolved Hide resolved
Copy link

@RodolfoGS RodolfoGS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested and now works. Thank you so much for the fix 🎉

Copy link
Member

@quinlanj quinlanj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i honestly dont remember why i was truncating the lines 😅 There could have been something there which we didn't want in the exported bundles, or it could have been for aesthetic reasons. i definitely should have left a comment in the code tho, sorry :(

packages/xdl/src/Project.ts Outdated Show resolved Hide resolved
packages/xdl/src/Project.ts Outdated Show resolved Hide resolved
@esamelson
Copy link
Contributor Author

thanks for the feedback, all 🙏 discussing with @brentvatne , we decided to change the logic slightly so the critical line now reads:
if (target === 'managed' && semver.lt(exp.sdkVersion, '40.0.0'))
meaning that we will only truncate lines for managed SDK 39 and lower projects -- or in other words, we won't truncate for projects that are either bare, or managed SDK 40+. (Confirmed this is an issue for managed SDK 40 projects as well, currently.)

@esamelson esamelson changed the title [xdl] fix expo export --dump-sourcemap for sdk 40+ bare projects [xdl] fix expo export --dump-sourcemap for sdk 40+ and bare projects Jan 21, 2021
@brentvatne brentvatne merged commit afcc27f into master Jan 25, 2021
@brentvatne brentvatne deleted the @eric/fix-export-sourcemap branch January 25, 2021 17:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[expo-updates] Crash when install an update via OTA and self-hosted
5 participants