Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

export-helper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

export-helper

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

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by75%
Maintainers
1
Weekly downloads
 
Created
Source

export-helper

Rather pretentious name for a tiny nodejs module that edits the last line of a file. It turns export = myModule; into default export myModule; between tsc compilations (both ways supported).
code style: prettier Known Vulnerabilities

Compatibility

node >= 10

Install

npm install export-helper

Use

// 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 be replaced by "export default constant;" (testFile.ts)

Options

This function accepts an option object :

const options = { 
  mode: "es6", // available options: "es5", "es6"
  path: "testFile.ts", // path to file (no need ./)
  silent: false, // pass it to true to silent the console.log; false by default
  linesToTrim: 1 /* default to 1;
    you usually don't need to touch this, but if your IDE puts an extra blank line 
    between your module export and EOF, pass it to 2 and it should do the trick.
   */
};

Interpolate something like the node helper.js shown above between them to alter your source code between two tsc calls.

The goal is to generate stuff that can be imported with either require("module") or import module from "module.

In other words, this is to avoid asking people to require("module").default your module when they're just fine with the syntax of Old.

Originally built for another module, this is a link to the tsconfig-cjs.json file.

WIP, USE AT YOUR OWN PERIL !!!!!!!!!

... I MEAN IT !!!

Keywords

FAQs

Package last updated on 24 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc