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

esmify

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esmify

parse and handle import/export for browserify

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

esmify

A dead-simple tool to add import / export ES Module syntax for browserify.

This plugin does the following to your bundler:

  • Adds .mjs extension to module resolution
  • Resolves to "module" field when "browser" field is not defined
  • Transforms ES Module syntax (static import / export statements) into CommonJS

Here's how you use it:

browserify index.js -p esmify > bundle.js

Also works with budo, for example:

budo index.js --live -- -p esmify

The plugin ignores dynamic import expressions and skips files that don't include import / export expressions to maintain performance. It runs across your bundle (including node_modules) as one of the goals is to support ESM syntax that is beginning to appear in the wild in many npm modules.

Install

Use npm to install.

npm install esmify --save-dev

Also can be used via API like so:

browserify({
  plugin: [
    [ require('esmify'), { /* ... options ... */ } ]
  ]
});

Usage

plugin = esmify(bundler, opt = {})

Returns a browswerify plugin function that operates on bundler with the given options:

  • mainFields which describes the order of importance of fields in package.json resolution, defaults to [ 'browser', 'module', 'main' ]
  • plainImports (Experimental) this feature will map named imports directly to their CommonJS counterparts, without going through Babel's inter-op functions. This is generally needed for static analysis of fs, path and other tools like glslify in browserify. Defaults to [ 'fs', 'path', 'glslify' ].

How it Works

Under the hood, this is using Babel with a couple plugins specific to CommonJS/import/export.

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Package last updated on 10 Jul 2018

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