# expose-loader
**Repository Path**: mirrors_gaearon/expose-loader
## Basic Information
- **Project Name**: expose-loader
- **Description**: expose loader module for webpack
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-08-08
- **Last Updated**: 2026-07-11
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[![npm][npm]][npm-url]
[![deps][deps]][deps-url]
[![chat][chat]][chat-url]
Expose Loader
The expose loader adds modules to the global object. This is useful
for debugging, or supporting libraries that depend on libraries in
globals.
Install
```bash
npm i expose-loader --save
```
Usage
**Note**: Modules must be `require()`'d within in your bundle, or they will not
be exposed.
``` javascript
require("expose-loader?libraryName!./file.js");
// 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:
```
require("expose-loader?React!react");
```
Thus, `window.React` is then available to the Chrome React devtools extension.
Alternately, you can set this in your config file:
webpack v1 usage
```
module: {
loaders: [
{ test: require.resolve("react"), loader: "expose-loader?React" }
]
}
```
webpack v2 usage
```
module: {
rules: [{
test: require.resolve('react'),
use: [{
loader: 'expose-loader',
options: 'React'
}]
}]
}
```
Also for multiple expose you can use `!` in loader string:
webpack v1 usage
```
module: {
loaders: [
{ test: require.resolve("jquery"), loader: "expose-loader?$!expose-loader?jQuery" },
]
}
```
webpack v2 usage
```
module: {
rules: [{
test: require.resolve('jquery'),
use: [{
loader: 'expose-loader',
options: 'jQuery'
},{
loader: 'expose-loader',
options: '$'
}]
}]
}
```
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](http://webpack.github.io/docs/using-loaders.html)
Maintainers
[npm]: https://img.shields.io/npm/v/expose-loader.svg
[npm-url]: https://npmjs.com/package/expose-loader
[deps]: https://david-dm.org/webpack-contrib/expose-loader.svg
[deps-url]: https://david-dm.org/webpack-contrib/expose-loader
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg
[chat-url]: https://gitter.im/webpack/webpack