expose loader module for webpack
Latest commit 3c5011b Nov 17, 2016 @SpaceK33z SpaceK33z committed on GitHub Merge pull request #26 from kevinzwhuang/master
Update README with -loader suffix on examples to reflect the change in Webpack 2
Failed to load latest commit information.
README.md Update README with -loader suffix on examples to reflect the change i… Nov 17, 2016
index.js minor changes May 21, 2015
package.json 0.7.1 Nov 4, 2015


expose loader for webpack

The expose loader adds modules to the global object. This is useful for debugging, or supporting libraries that depend on libraries in globals.

Note: Modules must be require()'d within in your bundle, or they will not be exposed.


// Exposes the exports for file.js to the global context on property "libraryName".
// In web browsers, window.libraryName is then available.

This line works to expose React to the web browser to enable the Chrome React devtools:


Thus, window.React is then available to the Chrome React devtools extension.

Alternately, you can set this in your config file:

module: {
  loaders: [
    { test: require.resolve("react"), loader: "expose-loader?React" }

Also for multiple expose you can use ! in loader string:

module: {
  loaders: [
    { test: require.resolve("jquery"), loader: "expose-loader?$!expose-loader?jQuery" },

The require.resolve is a node.js call (unrelated to require.resolve in webpack processing -- check the node.js docs instead). require.resolve gives you the absolute path to the module ("/.../app/node_modules/react/react.js"). So the expose only applies to the react module. And it's only exposed when used in the bundle.

Documentation: Using loaders


MIT (http://www.opensource.org/licenses/mit-license.php)