Socket
Book a DemoInstallSign in
Socket

babel-plugin-jsm-to-commonjs

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

babel-plugin-jsm-to-commonjs

Transforms imports and exports in Firefox .jsm to commonjs syntax

0.5.0
latest
npmnpm
Version published
Weekly downloads
192
37.14%
Maintainers
1
Weekly downloads
 
Created
Source

JSM to ES Module Common JS

Build Status

This module converts import and export statements with Components.utils.import and XPCOMUtils.defineLazyModuleGetter in .jsm modules to commonjs modules. For example:

Source:

const {utils: Cu} = Components;
const {Bar, Baz} = Cu.import("resource://activity-stream/addon/barbaz.jsm", {});

XPCOMUtils.defineLazyModuleGetter("Foo", "resource://activity-stream/addon/Foo.jsm")

this.Stuff = {};
this.Whatever = {};

this.EXPORTED_SYMBOLS = ["Stuff", "Whatever"];

Compiles to:

const {Bar, Baz} = require("addon/barbaz.jsm");
const {Foo} = require("addon/Foo.jsm")

var Stuff = {};
var Whatever = {};

module.exports = {Stuff, Whatever};

Options

basePath

Defaults to /^resource:\/\/. A RegEx or String that tests for which import paths to rewrite.

replace

Defaults to false. Remove the basePath component of the import string?

e.g. If the basePath is /^resource:\/\/, resource://activity-stream/foo.js will be rewritten to activity-stream/foo.js.

"plugins": ["transform-react-jsx", {basePath: "resource://activity-stream/"}],

removeOtherImports

Defaults to false. Should we remove non-matching imports?

FAQs

Package last updated on 29 Jan 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.