npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@balena/es-version

v1.0.3

Published

This module provides the ability to specify the default es version to include for balena modules.

Downloads

64,654

Readme

@balena/es-version

This module allows specifying a target es version for other modules to require, currently supported target versions:

  • es3 (default)
  • es5
  • es2015
  • es2016
  • es2017
  • es2018
  • es2019
  • es2020
  • es2021
  • es2022
  • esnext

Usage as a client

  1. Add @balena/es-version to your package.json with a ^ version specifier, eg
"@balena/es-version": "^1.0.0",

Note: If using locked dependences, eg package-lock.json/npm-shrinkwrap.json/etc, then make sure to also dedupe the module so that the same instance of the module is used everywhere.

  1. Within your module require it before anything else and set the desired version:
// Must be set before the first require of an @balena/es-version supporting module
require('@balena/es-version').set('es5');

and then the closest matching version will be used by any module that supports choosing the target version, with the priority being:

  1. exact match
  2. closest match under the desired version
  3. lowest supported version

Usage as a module provider

  1. Add @balena/es-version to your package.json with a ^ version specifier, eg
"@balena/es-version": "^1.0.0",
  1. Generate builds for the es versions you wish to support along with types for the shim you'll create, eg
"build-es5": "tsc --target es5 --outDir es5",
"build-es2015": "tsc --target es2015 --outDir es2015",
"build-es2018": "tsc --target es2018 --outDir es2018",
"build-types": "tsc --emitDeclarationOnly --outDir .",
"build": "npm run build-es5 && npm run build-es2015 && npm run build-es2018 && npm run build-types",
  1. Create a shim to use as your entry-point which loads the desired version, eg
// First get the es version to use:
var esVersion = require('@balena/es-version').get(['es5', 'es2015', 'es2018');
// Then include/return the correct version of your module, eg
module.exports = module.exports = require('./' + esVersion);

Note: This must be compatible with your lowest supported es version

  1. Point your package.json to the new shim and types, eg
"main": "index.js",
"types": "index.d.ts",
  1. It is also recommended to add a "browser" entry to a fixed es version in your package.json in order to support browser bundlers with default config, eg
"browser": "es5"