babel-plugin-transform-require-on-use

2.1.0 • Public • Published

transform-require-on-use

This is a babel transform that conceptually transforms this:

const module = require("module");
 
function somewhere () {
  if (condition) {
    module.doSomething();
  }
}

into this:

const module = () => require("module");
 
function somewhere () {
  if (condition) {
    module().doSomething();
  }
}

That's it!

Caveats

Modules with that have require-time side-effects will obviously not play well with this.

v1.0.0 is super naive, let's see where it goes.

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-transform-require-on-use

Weekly Downloads

3

Version

2.1.0

License

ISC

Last publish

Collaborators

  • fasterthanlime