Skip to content

Mardak/babel-plugin-jsm-to-commonjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/"}],

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%