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 🙏

© 2025 – Pkg Stats / Ryan Hefner

export-helper

v1.0.0

Published

Nodejs utility to help compile TS modules into sweet es5 & es6 exports

Readme

export-helper

Pretentious name for a tiny nodejs module that edits the last line of a file.

Why ?

It basically turns export = myModule; into export { myModule }; between tsc compilations (both ways supported)
Use it to compile into the syntax of Old (require(), NOT require().default) and a valid es6 module, in a single build command.
https://nodei.co/npm/export-helper.png?downloads=true&downloadRank=true&stars=true code style: prettier Known Vulnerabilities

Compatibility

node >= 10

Install

npm install --save-dev export-helper

Use (CLI)

npx export-helper es5 index.ts
  • first argument can be either "es5" or "es6"
  • second argument is target file path
  • accepts an optional 'verbose' 3rd param, that enables a log:
npx export-helper es6 testFile.ts verbose
# npmjs/export-helper: "export = constant;" has successfully been replaced by "export { constant };" (testFile.ts)

Use (from JS)

Javascript file helper.js:

const exportHelper = require("export-helper");

exportHelper({ mode: "es6", path: "testFile.ts" }).then((res) => res);

In terminal:

$ node helper.js
$ npmjs/export-helper: "export = constant;" has successfully been replaced by "export { constant };" (testFile.ts)

Options

This function accepts an option object :

const options = {
  mode: "es6", // needed. Available options: "es5", "es6". Untested options: "es5:withbrackets", "es6:default", "es6asDefault"
  path: "testFile.ts", // needed. Path to file (./ is optional)
  silent: false, // default to false; set to true to remove the log
  linesToTrim: 1 /* default to 1.
    You usually don't need this, but in case your IDE insert 
    an extra blank line between your module export and EOF, 
    incrementing that value should do the trick.
   */,
};

... more examples ?

This script in my package.json :

{
  ...
  "npm run build": "node rebuild.js && npx export-helper es5 src/index.ts && tsc -p tsconfig-cjs.json && px export-helper es6 src/index.ts  && tsc -p tsconfig.json"
}
  • rebuild.js is a simple utility that wipes the /lib folder before compilation.
  • tsc -p tsconfig-cjs.json: I'm calling tsc with this config file
  • Now that I've compiled proper cjs with module.exports, I call npx export-helper es6 src/index.ts to change the source code once more.
  • Finally I call tsc to build the es6 module.