Skip to content

Platform checks should be done at build time instead of runtime #384

Closed

Description

@joshaber

We currently have some places where we'd doing platform checks at runtime (e.g., if (process.platform === 'win32') { ... })

That's less than ideal. We should be able to do those checks at build time instead of runtime.

Activity

  1. added
    tech-debt
    on Sep 23, 2016
  2. niik commented on Sep 23, 2016

    @niik
    Member

    👍 I wonder how clever uglifyjs is at detecting and removing dead code. Like, if we use webpack's subsitution stuff to substitute something like __WINDOWS__ and __DARWIN__ for boolean constants I'd expect it to remove code which looks like

    if(false) { ... }

    But I know we saw some warnings from uglify early on, can't quite remember if they were about dead code tho.

  3. joshaber commented on Sep 23, 2016

    @joshaber
    ContributorAuthor

    But I know we saw some warnings from uglify early on, can't quite remember if they were about dead code tho.

    Yup, it should. For example, when __DEV__ is false:

    Condition always false [./app/src/lib/dispatcher/dispatcher.ts:81,20]
    Dropping unreachable code [./app/src/lib/dispatcher/dispatcher.ts:82,17]
    
  4. self-assigned this
    on Sep 23, 2016
  5. removed their assignment
    on Sep 29, 2016
  6. locked as resolved and limited conversation to collaborators on Jul 23, 2018
  7. unlocked this conversation on Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions