Skip to content

Instantly share code, notes, and snippets.

@ryan-roemer
Last active March 4, 2021 05:44
Show Gist options
  • Save ryan-roemer/c2b507ef0e17c392b9f09b7a03e1371c to your computer and use it in GitHub Desktop.
Save ryan-roemer/c2b507ef0e17c392b9f09b7a03e1371c to your computer and use it in GitHub Desktop.
Webpack: Various ways to have multiple exports.
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!**********************!*\
!*** ./lib/entry.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
// Matches
var a = __webpack_require__(/*! ./mod-a */ 1);
var b = __webpack_require__(/*! ./mod-b */ 4);
var c = __webpack_require__(/*! ./mod-c */ 5);
var d = __webpack_require__(/*! ./mod-d */ 6);
var e = __webpack_require__(/*! ./mod-e */ 7);
var f = __webpack_require__(/*! ./mod-f */ 8);
// Non matches
var nma = __webpack_require__(/*! ./nomatch-a */ 9);
var nmb = __webpack_require__(/*! ./nomatch-b */ 10);
var nmc = __webpack_require__(/*! ./nomatch-c */ 11);
/***/ },
/* 1 */
/*!**********************!*\
!*** ./lib/mod-a.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
// MATCH: Basic object structure.
module.exports = {
first: __webpack_require__(/*! ./first */ 2),
second: __webpack_require__(/*! ./second */ 3)
};
/***/ },
/* 2 */
/*!**********************!*\
!*** ./lib/first.js ***!
\**********************/
/***/ function(module, exports) {
module.exports = "first";
/***/ },
/* 3 */
/*!***********************!*\
!*** ./lib/second.js ***!
\***********************/
/***/ function(module, exports) {
module.exports = "second";
/***/ },
/* 4 */
/*!**********************!*\
!*** ./lib/mod-b.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
// MATCH: Basic declaration structure.
module.exports.first = __webpack_require__(/*! ./first */ 2);
module.exports.second = __webpack_require__(/*! ./second */ 3);
/***/ },
/* 5 */
/*!**********************!*\
!*** ./lib/mod-c.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
// MATCH: Mixed structure with closure.
module.exports = {
first: __webpack_require__(/*! ./first */ 2)
};
(function () {
module.exports.second = __webpack_require__(/*! ./second */ 3);
}());
/***/ },
/* 6 */
/*!**********************!*\
!*** ./lib/mod-d.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
// MATCH: Stretch goal: mixed structure with variable passing.
module.exports = {
first: __webpack_require__(/*! ./first */ 2)
};
(function (exps) {
exps.second = __webpack_require__(/*! ./second */ 3);
}(module.exports));
/***/ },
/* 7 */
/*!**********************!*\
!*** ./lib/mod-e.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
// MATCH: Variable import at top.
var second = __webpack_require__(/*! ./second */ 3);
module.exports = {
first: __webpack_require__(/*! ./first */ 2),
second: second
};
/***/ },
/* 8 */
/*!**********************!*\
!*** ./lib/mod-f.js ***!
\**********************/
/***/ function(module, exports, __webpack_require__) {
// MATCH: Variable import at top with closure.
var second = __webpack_require__(/*! ./second */ 3);
module.exports = {
first: __webpack_require__(/*! ./first */ 2)
};
(function () {
module.exports.second = second;
}());
/***/ },
/* 9 */
/*!**************************!*\
!*** ./lib/nomatch-a.js ***!
\**************************/
/***/ function(module, exports, __webpack_require__) {
// NO MATCH: Only one require.
module.exports = {
first: __webpack_require__(/*! ./first */ 2),
third: "third"
};
/***/ },
/* 10 */
/*!**************************!*\
!*** ./lib/nomatch-b.js ***!
\**************************/
/***/ function(module, exports, __webpack_require__) {
// NO MATCH: Only one require.
module.exports.first = __webpack_require__(/*! ./first */ 2);
module.exports.third = "third";
/***/ },
/* 11 */
/*!**************************!*\
!*** ./lib/nomatch-c.js ***!
\**************************/
/***/ function(module, exports, __webpack_require__) {
// NO MATCH: Two requires, but of _same_ module.
module.exports = {
first: __webpack_require__(/*! ./first */ 2),
firstAgain: __webpack_require__(/*! ./first */ 2)
};
/***/ }
/******/ ]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment