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

esm-es5

v0.0.5

Published

Converts ES2015 module syntax to ES5 code that can be used in an AMD or CommonJS module system.

Downloads

11

Readme

esm-es5

Converts ES2015 module syntax to ES5 code that can be used in an AMD or CommonJS module system.

Does not support all of ES2015 syntax, like classes or fat arrows, just does some light translation work related to import and export.

Used in some amodro-lifecycle projects to validate lifecycle and module system interoperability.

Usage

// source is the String contents of a module, options is an object.
var esmResult = esmEs5(source, options);

// esmResult has these properties:
// Indicates if import or export use was detected and converted.
esmResult.translated = Boolean;

// The converted soure. If translated is false, this is just
// the input source.
esmResult.source = String;

// If tranlated, an array of import dependency IDs.
esmResult.ids = Array;

Options

Right now there are no options, but a simulateCycle option is planned. It will replace the identifier for an import with a module meta get call, to simulate the kind of cycle support possible in a true ES2015 module system. It will not be an exact simulation (for example, it cannot handle export var assignments outside the initial export statement), but will help the most common type of cycle resolution with declarative exports that only assign in the export statement.

Transforms not supported

No export * support. May be added later. Instead, use named exports for clearer expression of intention, split exports into separate files for better granular consumption.

export default ClassDeclaration not supported because supporting class transpiling is not a goal of this project.

There could be some other cases not handled yet, but likely just mistakenly overlooked, feel free to file issues with examples.

See the test/source directory for source forms supported, and test/expected for the translated ES5 result.

todo

  • replace identifiers for simulateCycle option. Won't support var a; export a; a = 5;, but still useful.
  • hack in support for a module meta? import { require, normalize } from module?