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).
Compatibility
node >= 10
Install
npm install export-helper
Use
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",
path: "testFile.ts",
silent: false,
linesToTrim: 1
};
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 !!!