0.5.0 • Published 5 years ago

babel-plugin-jsm-to-commonjs v0.5.0

Weekly downloads
73
License
MIT
Repository
-
Last release
5 years ago

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?

0.5.0

5 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.1

7 years ago