Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Platform.os binding prevents inlining/optimization #239

Closed
@grabbou

Description

@grabbou

Metro bundler inlines(ReactNative.)Platform.OS and(ReactNative.)Platform.select, so that when packaging for one platform, the code for the other platform is optimized away.

So if I had

[@bs.module"react-native"] [@bs.scope"Platform"]externalos:string="OS";if (os==="ios") {Js.log("ios");}else {Js.log("android");};

this would get compiled by BuckleScript to

if(ReactNative.Platform.OS==="ios"){console.log("ios");}else{console.log("android");}

and Metro Bundler would inline ReactNative.Platform.OS and subsequently optimize the Android branch away for an iOS build.

However, with the current Rebolt bindings, I have

switch (Platform.os()) {|IOS(_)=>Js.log("ios")|Android=>Js.log("android")};

which gets compiled by BuckleScript to

varmatch=Platform$Rebolt.os(/* () */0);if(match){console.log("ios");return/* () */0;}else{console.log("android");return/* () */0;}

This prevents the inlining/optimization from working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp