
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
ts-transform-default-export
Advanced tools
A TypeScript transformer that converts a default export such as one of these:
export default function foo() {}
export default foo
export { foo as default }
to its CommonJS counterpart:
export = foo
When such a module is then transpiled to CommonJS or UMD, the export will become module.exports = foo,
making the module consumable by require('foo') instead of require('foo').default.
Only files that match the files or include property of your tsconfig.json will be transformed.
This is an intentional restriction to make it possible to control which files are processed.
npm install --save-dev ts-transform-default-export
Currently there is no native way to add a custom transformer to your TypeScript compilation pipeline. Instead, you have to use a third-party tool (TTypescript, ts-patch) or a plugin for your bundler. For concrete instructions refer to the docs of the tool of your choice.
The type of this transformer is program, the most common one. To transform the module file, add it
to the before stage. To transform the emitted declaration file, add it to afterDeclarations.
tsconfig.json for TTypescript{
"compilerOptions": {
"module": "CommonJS",
"plugins": [{
"transform": "ts-transform-default-export",
"afterDeclarations": true,
"keepOriginalExport": true // Transformer option
}]
},
"include": ["src/index.ts"]
}
keepOriginalExport: booleanWhether to keep the original default export in the code when transforming it.
When false (default):
export default foo → export = foo
When true:
export default foo → export default foo; export = foo
allowNamedExports: booleanWhether to throw when there are named exports in the module along with the default one.
This is important because when a default export is converted to export =, named exports
could get lost. For example, export { foo as default, bar } becomes exports.bar = bar; module.exports = foo,
so bar is overwritten.
You can work around this by assigning the named exports to the default export's value
if possible (foo.bar = bar; export { foo as default, bar }) and setting this option to true.
When false (default):
export { foo as default, bar } → throws an error
When true (and keepOriginalExport is false):
export { foo as default, bar } → export { bar }; export = foo
When true (and keepOriginalExport is true):
export { foo as default, bar } → export { foo as default, bar }; export = foo
FAQs
export default foo → export = foo → module.exports = foo
We found that ts-transform-default-export demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.