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

convert-extension

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-extension

Convert JS source file extensions and imports

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
decreased by-38.78%
Maintainers
1
Weekly downloads
 
Created
Source

convert-extension npm version build status coverage status

Convert JS source file extensions and imports.

This module was created to allow you to convert the output of Typescript to .mjs or .cjs, for better support with node ES6 modules.

Installation

npm install convert-extension

or

yarn add convert-extension

Usage

Run the command, providing a file extension (here mjs) and a directory:

npx convert-extension mjs build/

This will convert any .js files and their relative imports to .mjs. It will also convert source maps, if they exist.

You can also specify a custom extension of input files with --input-extension:

npx convert-extension mjs build/ --input-extension=xyz

Programmatic usage

import convertExtension from 'convert-extension';

(async function() {
    await convertExtension('build/', 'mjs', 'js');
})();

You can also supply Babel transform options as a fourth argument:

import convertExtension from 'convert-extension';

(async function() {
    await convertExtension('build/', 'mjs', 'js', { minified: true });
})();
With CommonJS / require()
const convertExtension = require('convert-extension');

(async function() {
    await convertExtension('build/', 'mjs', 'js');
})();

Keywords

FAQs

Package last updated on 03 Jun 2021

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