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

babel-plugin-transform-require-extensions

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-require-extensions

A Babel plugin that transforms specified require path file extensions.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-28.57%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-require-extensions

npm version CI status

A Babel plugin that transforms specified require path file extensions.

This is useful for building dual ESM/CJS packages. File names with extensions are mandatory in ESM import specifiers in .mjs files. After transpiling this to CJS in .js files, the hardcoded .mjs extensions in the require paths must be transformed to .js. Alternatively, sometimes it’s safe to remove the extensions as Node.js in CJS mode can automatically resolve .js file extensions.

Setup

To install from npm run:

npm install babel-plugin-transform-require-extensions --save-dev

Configure Babel to use the plugin:

{ "plugins": ["transform-require-extensions"] }

This plugin must run after any ESM to CJS transpilation occurs.

By default .mjs extensions are transformed to .js. The extensions option can be used to specify extension replacements. For example, to remove .mjs extensions:

{
  "plugins": [
    [
      "transform-require-extensions",
      {
        "extensions": {
          ".mjs": ""
        }
      }
    ]
  ]
}

Support

  • Node.js v10+

Keywords

FAQs

Package last updated on 06 Apr 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