JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 25400
  • Score
    100M100P100Q139942F
  • License

browserify transform that exposes globals added via a script tag as modules so they can be required.

Package Exports

  • exposify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (exposify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

exposify build status

browserify transform that exposes globals added via a script tag as modules so they can be required.

<!-- index.html -->
<head>
  <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r61/three.min.js"></script>
  <script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
  [..]
// main.js
var $ = require('jquery')
  , THREE = require('three')

console.log('THREE revision: ', THREE.REVISION);
console.log('jquery version: ', $().jquery);

Building via JavaScript

var browserify = require('browserify')
  , exposify   = require('exposify')

// configure what we want to expose
exposify.config = { jquery: '$', three: 'THREE' };

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

Building via Commandline

EXPOSIFY_CONFIG='{ "jquery": "$", "three": "THREE" }' browserify --debug -t exposify main.js > bundle.js

Or use it via browserify-shim which allows you to provide exposify config inside your package.json among other features.

Installation

npm install exposify

API

exposify::config

The config which is used by exposify to determine which require statemtents to replace and how. You need to set this or provide it via the EXPOSIFY_CONFIG environment variable.

 // setting from javascript
exposify.config = { jquery: '$', three: 'THREE' };
 # setting from command line
EXPOSIFY_CONFIG='{ "jquery": "$", "three": "THREE" }' browserify -t exposify ...
Source:

exposify::expose

Exposes the expose function that operates on a string

Source:

exposify::filePattern

Regex pattern of files whose content is exposified

Source:

exposify(file) → {TransformStream}

browserify transform which exposes globals as modules that can be required.

Parameters:
Name Type Description
file string

file whose content is to be transformed

Source:
Returns:

transform that replaces require statements found in the code with global assigments

Type
TransformStream

generated with docme

License

MIT