Discussions » Development

Can I use 'eval-source-map' for webpack user scripts?

§
Posted: 2020-07-28

Can I use 'eval-source-map' for webpack user scripts?

It is said that "Code posted to this site must not be obfuscated or minified. " in the rules.

With 'eval-source-map', codes is harder to read directly, but actally not obfuscated or minified. Besides, it provides more specific source info and debugging info.

§
Posted: 2020-07-29

Source:

declare const userScriptMainSource: string;

const request = new XMLHttpRequest();
request.open('GET', userScriptMainSource, false);
request.send(null);
if (request.status === 200) {
    eval(request.responseText);
}

Output:

/***/ "./src/user-script/debug.ts":
/*!**********************************!*\
  !*** ./src/user-script/debug.ts ***!
  \**********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
eval("\r\nconst request = new XMLHttpRequest();\r\nrequest.open('GET', \"https://localhost:48792/ehsyringe.user.js\", false);\r\nrequest.send(null);\r\nif (request.status === 200) {\r\n    eval(request.responseText);\r\n}\r\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9zcmMvdXNlci1zY3JpcHQvZGVidWcudHM/NzNhNyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBRUEsTUFBTSxPQUFPLEdBQUcsSUFBSSxjQUFjLEVBQUUsQ0FBQztBQUNyQyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssRUFBRSwyQ0FBb0IsRUFBRSxLQUFLLENBQUMsQ0FBQztBQUNqRCxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDO0FBQ25CLElBQUksT0FBTyxDQUFDLE1BQU0sS0FBSyxHQUFHLEVBQUU7SUFDeEIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxZQUFZLENBQUMsQ0FBQztDQUM5QiIsImZpbGUiOiIuL3NyYy91c2VyLXNjcmlwdC9kZWJ1Zy50cy5qcyIsInNvdXJjZXNDb250ZW50IjpbImRlY2xhcmUgY29uc3QgdXNlclNjcmlwdE1haW5Tb3VyY2U6IHN0cmluZztcblxuY29uc3QgcmVxdWVzdCA9IG5ldyBYTUxIdHRwUmVxdWVzdCgpO1xucmVxdWVzdC5vcGVuKCdHRVQnLCB1c2VyU2NyaXB0TWFpblNvdXJjZSwgZmFsc2UpO1xucmVxdWVzdC5zZW5kKG51bGwpO1xuaWYgKHJlcXVlc3Quc3RhdHVzID09PSAyMDApIHtcbiAgICBldmFsKHJlcXVlc3QucmVzcG9uc2VUZXh0KTtcbn1cbiJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./src/user-script/debug.ts\n");

/***/ }),

Post reply

Sign in to post a reply.