externalify

Browserify transform that lets you require external modules from any function that follows the require API.

Usage no npm install needed!

<script type="module">
  import externalify from 'https://cdn.skypack.dev/externalify';
</script>

README

externalify

Browserify transform that lets you require external modules from any function that follows the require API.

Much like the external option to Browserify, but lets you specify a custom name for the require function to avoid creating a global require symbol.

Using via JavaScript

var browserify = require('browserify');

// configure what we want to externalize
var externalifyConfig = { external: { jquery: '

, three: 'THREE' } };

browserify()
  .require(require.resolve('./main'), { entry: true })
  .transform('exposify', externalifyConfig)
  .bundle({ debug: true })
  .pipe(fs.createWriteStream(path.join(__dirname, 'bundle.js'), 'utf8'))

Using via Commandline

Use the Browserify transform option:

browserify --debug -t [ exposify --external [ --jquery=$ --three=THREE ] ] exposify main > bundle.js

Installation

npm install exposify

License

MIT