diff --git a/test/unit/wildcard-require2/input.js b/test/unit/wildcard-require2/input.js new file mode 100644 index 0000000..f815f25 --- /dev/null +++ b/test/unit/wildcard-require2/input.js @@ -0,0 +1,5 @@ +const num = Math.ceil(Math.random() * 3, 0); + +const path = `path${num}`; +const m = require(`./modules/${path}/index.js`); +console.log(m); diff --git a/test/unit/wildcard-require2/modules/path1/index.js b/test/unit/wildcard-require2/modules/path1/index.js new file mode 100644 index 0000000..aec857f --- /dev/null +++ b/test/unit/wildcard-require2/modules/path1/index.js @@ -0,0 +1 @@ +module.exports = 'module1'; \ No newline at end of file diff --git a/test/unit/wildcard-require2/modules/path2/index.js b/test/unit/wildcard-require2/modules/path2/index.js new file mode 100644 index 0000000..5c5b13f --- /dev/null +++ b/test/unit/wildcard-require2/modules/path2/index.js @@ -0,0 +1 @@ +module.exports = 'module2'; diff --git a/test/unit/wildcard-require2/modules/path3/index.js b/test/unit/wildcard-require2/modules/path3/index.js new file mode 100644 index 0000000..f5c0d20 --- /dev/null +++ b/test/unit/wildcard-require2/modules/path3/index.js @@ -0,0 +1 @@ +module.exports = 'module3'; diff --git a/test/unit/wildcard-require2/output-coverage.js b/test/unit/wildcard-require2/output-coverage.js new file mode 100644 index 0000000..58f4506 --- /dev/null +++ b/test/unit/wildcard-require2/output-coverage.js @@ -0,0 +1,75 @@ +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ 805: +/***/ ((module) => { + +module.exports = 'module1'; + +/***/ }), + +/***/ 387: +/***/ ((module) => { + +module.exports = 'module2'; + + +/***/ }), + +/***/ 455: +/***/ ((module) => { + +module.exports = 'module3'; + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat */ +/******/ +/******/ if (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + "/";/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +function __ncc_wildcard$0 (arg) { + if (arg === "path1") return __webpack_require__(805); + else if (arg === "path2") return __webpack_require__(387); + else if (arg === "path3") return __webpack_require__(455); +} +const num = Math.ceil(Math.random() * 3, 0); + +const path = `path${num}`; +const m = __ncc_wildcard$0(path); +console.log(m); + +})(); + +module.exports = __webpack_exports__; +/******/ })() +; \ No newline at end of file diff --git a/test/unit/wildcard-require2/output.js b/test/unit/wildcard-require2/output.js new file mode 100644 index 0000000..58f4506 --- /dev/null +++ b/test/unit/wildcard-require2/output.js @@ -0,0 +1,75 @@ +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ 805: +/***/ ((module) => { + +module.exports = 'module1'; + +/***/ }), + +/***/ 387: +/***/ ((module) => { + +module.exports = 'module2'; + + +/***/ }), + +/***/ 455: +/***/ ((module) => { + +module.exports = 'module3'; + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat */ +/******/ +/******/ if (typeof __webpack_require__ !== 'undefined') __webpack_require__.ab = __dirname + "/";/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +function __ncc_wildcard$0 (arg) { + if (arg === "path1") return __webpack_require__(805); + else if (arg === "path2") return __webpack_require__(387); + else if (arg === "path3") return __webpack_require__(455); +} +const num = Math.ceil(Math.random() * 3, 0); + +const path = `path${num}`; +const m = __ncc_wildcard$0(path); +console.log(m); + +})(); + +module.exports = __webpack_exports__; +/******/ })() +; \ No newline at end of file