Skip to content

Fix: Add module into the vmContext#1634

Closed
iamssen wants to merge 1 commit intojantimon:mainfrom
iamssen:main
Closed

Fix: Add module into the vmContext#1634
iamssen wants to merge 1 commit intojantimon:mainfrom
iamssen:main

Conversation

@iamssen
Copy link
Copy Markdown

@iamssen iamssen commented Apr 4, 2021

Problem

[1m�[31mERROR�[39m�[22m in �[1m  �[1m�[31mError�[39m�[22m�[1m: undefined:2
  module.exports = __webpack_require__.p + "javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;.1feff74faaf0efc6a044355c92cd15d9.bin";//# sourceURL=[module]
  ^
  ReferenceError: module is not defined
  
  
  - index.html:17 Object.data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;
    /Users/ssen/Workspace/rocket-scripts/packages/.fixtures/test/fixtures/web/start-1617556766984/src/app/index.html:17:1

In my case, this error occurs on html-webpack-plugin@^5.

I solved this error by add module to vmContext. (tested with packed .tgz package)

@jantimon
Copy link
Copy Markdown
Owner

jantimon commented Apr 4, 2021

What configuration did cause that module is undefined?

@iamssen
Copy link
Copy Markdown
Author

iamssen commented Apr 4, 2021

I think that, the error is related the webpack's eval() devtool. (maybe?)

This is log before the error on vm.runInContext().

(My webpack configuration is so complex, I made a tool such as create-react-app. but, .html was not affected by other loaders before the error)

loader.js..exports() <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="theme-color" content="#000000"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="manifest" href="manifest.json"/>
    <title>App</title>
  </head>
  
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="app"></div>
  </body>
</html>
loader.js..exports() { allLoadersButThisOne: [] }
index.js..evaluateCompilationResult() /*
 * ATTENTION: An "eval-source-map" devtool has been used.
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
var HTML_WEBPACK_PLUGIN_RESULT;
/******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ "data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;":
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\nmodule.exports = __webpack_require__.p + \"javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;.1feff74faaf0efc6a044355c92cd15d9.bin\";//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YTp0ZXh0L2phdmFzY3JpcHQsX193ZWJwYWNrX3B1YmxpY19wYXRoX18gPSBfX3dlYnBhY2tfYmFzZV91cmlfXyA9IGh0bWxXZWJwYWNrUGx1Z2luUHVibGljUGF0aDsuanMiLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9wYWNrYWdlcy9kYXRhOnRleHQvamF2YXNjcmlwdCxfX3dlYnBhY2tfcHVibGljX3BhdGhfXyA9IF9fd2VicGFja19iYXNlX3VyaV9fID0gaHRtbFdlYnBhY2tQbHVnaW5QdWJsaWNQYXRoOz84ZWJmIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gX193ZWJwYWNrX3B1YmxpY19wYXRoX18gKyBcImphdmFzY3JpcHQsX193ZWJwYWNrX3B1YmxpY19wYXRoX18gPSBfX3dlYnBhY2tfYmFzZV91cmlfXyA9IGh0bWxXZWJwYWNrUGx1Z2luUHVibGljUGF0aDsuMWZlZmY3NGZhYWYwZWZjNmEwNDQzNTVjOTJjZDE1ZDkuYmluXCI7Il0sIm1hcHBpbmdzIjoiO0FBQUEiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;\n");

/***/ }),

/***/ "../node_modules/html-webpack-plugin/lib/loader.js!./.fixtures/test/fixtures/web/start-1617556002362/src/app/index.html":
/***/ ((module) => {

eval("var _ = require(\"/Users/ssen/Workspace/rocket-scripts/node_modules/lodash/lodash.js\");module.exports = function (templateParams) { with(templateParams) {return (function(data) {\nvar __t, __p = '';\n__p += '<!DOCTYPE html>\\n<html lang=\"en\">\\n  <head>\\n    <meta charset=\"UTF-8\"/>\\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\\n    <meta name=\"theme-color\" content=\"#000000\"/>\\n    <link rel=\"shortcut icon\" href=\"favicon.ico\"/>\\n    <link rel=\"manifest\" href=\"manifest.json\"/>\\n    <title>App</title>\\n  </head>\\n  \\n  <body>\\n    <noscript>You need to enable JavaScript to run this app.</noscript>\\n    <div id=\"app\"></div>\\n  </body>\\n</html>';\nreturn __p\n})();}}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi4vbm9kZV9tb2R1bGVzL2h0bWwtd2VicGFjay1wbHVnaW4vbGliL2xvYWRlci5qcyEuLy5maXh0dXJlcy90ZXN0L2ZpeHR1cmVzL3dlYi9zdGFydC0xNjE3NTU2MDAyMzYyL3NyYy9hcHAvaW5kZXguaHRtbC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovL3BhY2thZ2VzLy4vLmZpeHR1cmVzL3Rlc3QvZml4dHVyZXMvd2ViL3N0YXJ0LTE2MTc1NTYwMDIzNjIvc3JjL2FwcC9pbmRleC5odG1sP2Q2ODciXSwic291cmNlc0NvbnRlbnQiOlsidmFyIF8gPSBfX25vbl93ZWJwYWNrX3JlcXVpcm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pack-plugin/lib/loader.js!./.fixtures/test/fixtures/web/start-1617556002362/src/app/index.html\n");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// 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) {
/******/ 			if (cachedModule.error !== undefined) throw cachedModule.error;
/******/ 			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
/******/ 		try {
/******/ 			__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 		} catch(e) {
/******/ 			module.error = e;
/******/ 			throw e;
/******/ 		}
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	/* webpack/runtime/make namespace object */
/******/ 	(() => {
/******/ 		// define __esModule on exports
/******/ 		__webpack_require__.r = (exports) => {
/******/ 			if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 				Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 			}
/******/ 			Object.defineProperty(exports, '__esModule', { value: true });
/******/ 		};
/******/ 	})();
/******/ 	
/******/ 	/* webpack/runtime/publicPath */
/******/ 	(() => {
/******/ 		__webpack_require__.p = "";
/******/ 	})();
/******/ 	
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module can't be inlined because the eval-source-map devtool is used.
/******/ 	__webpack_require__("data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;");
/******/ 	var __webpack_exports__ = __webpack_require__("../node_modules/html-webpack-plugin/lib/loader.js!./.fixtures/test/fixtures/web/start-1617556002362/src/app/index.html");
/******/ 	HTML_WEBPACK_PLUGIN_RESULT = __webpack_exports__;
/******/ 	
/******/ })()
;;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants