JSPM

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

expose loader module for webpack

Package Exports

  • expose-loader

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 (expose-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

expose loader for webpack

Usage

require("expose?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?React!react");

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?React" }
  ]
}

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

module: {
  loaders: [
    { test: require.resolve("jquery"), loader: "expose?$!expose?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

License

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