Skip to content

Replace os-locale with inline code #1354

@coreyfarrell

Description

@coreyfarrell

Due to yargs passing spawn: false to os-locale most of the functionality of that module is unused. The following could be used as a drop-in replacement for os-locale:

function osLocale() {
  const locale = env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE || 'en_US';
  return locale.replace(/[.:].*/, '');
}

The benefit is a large drop of production dependencies. Currently a project with yargs as the only dependency installs 53 modules / 1.8MB to node_modules. Without os-locale this becomes 26 modules / 1.1MB. The size reduction is not my primary interest of this issue, the goal is cutting the number of modules that have to be audited in half.

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