提交 517a414b 编写于 作者: 5 592767809

更新

上级 c68de85f
node webpack_mixer.js -l runtime_Page.8070bd8b2e010619dd4b.js -m vendor.chunk.9a1ccc7ef30852dbe5bb.js -o webpack_out.js
\ No newline at end of file
因为 它太大了无法显示 source diff 。你可以改为 查看blob
!function(e){function t(t){for(var a,n,i=t[0],f=t[1],d=t[2],l=0,s=[];l<i.length;l++)n=i[l],Object.prototype.hasOwnProperty.call(o,n)&&o[n]&&s.push(o[n][0]),o[n]=0;for(a in f)Object.prototype.hasOwnProperty.call(f,a)&&(e[a]=f[a]);for(u&&u(t);s.length;)s.shift()();return c.push.apply(c,d||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],a=!0,n=1;n<r.length;n++){var f=r[n];0!==o[f]&&(a=!1)}a&&(c.splice(t--,1),e=i(i.s=r[0]))}return e}var a={},n={17:0},o={17:0},c=[];function i(t){if(a[t])return a[t].exports;var r=a[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[];n[e]?t.push(n[e]):0!==n[e]&&{1:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,10:1,11:1,12:1,13:1,14:1,15:1,16:1,18:1,19:1,20:1,21:1,22:1}[e]&&t.push(n[e]=new Promise((function(t,r){for(var a="css/"+({1:"common",3:"album",4:"albumDetail",5:"album_mall",6:"category",7:"index",8:"mv",9:"mvList",10:"mv_toplist",11:"notfound",12:"player",13:"playlist",14:"playlist_edit",15:"profile",16:"radio",18:"search",19:"singer",20:"singer_list",21:"songDetail",22:"toplist"}[e]||e)+"."+{1:"956c8c84ac74db99b129",3:"5cf0d69eaf29bcab23d2",4:"798353db5b0eb05d5358",5:"df4c243f917604263e58",6:"20d532d798099a44bc88",7:"ea0adb959fef9011fc25",8:"8bdb1df6c5436b790baa",9:"47ce9300786df1b70584",10:"4aee33230ba2d6b81dce",11:"e6f63b0cf57dd029fbd6",12:"705a44083e632be531e3",13:"9484fde660fe93d9f9f0",14:"67fb85e7f96455763c83",15:"5e8c651e74b13244f7cf",16:"3befd83c10b19893ec66",18:"1a731fd5e08c19a0ecef",19:"c7a38353c5f4ebb47491",20:"df0961952a2d3f022894",21:"4c080567e394fd45608b",22:"8edb142553f97482e00f"}[e]+".chunk.css?max_age=2592000",o=i.p+a,c=document.getElementsByTagName("link"),f=0;f<c.length;f++){var d=(u=c[f]).getAttribute("data-href")||u.getAttribute("href");if("stylesheet"===u.rel&&(d===a||d===o))return t()}var l=document.getElementsByTagName("style");for(f=0;f<l.length;f++){var u;if((d=(u=l[f]).getAttribute("data-href"))===a||d===o)return t()}var s=document.createElement("link");s.rel="stylesheet",s.type="text/css",s.onload=t,s.onerror=function(t){var a=t&&t.target&&t.target.src||o,c=new Error("Loading CSS chunk "+e+" failed.\n("+a+")");c.code="CSS_CHUNK_LOAD_FAILED",c.request=a,delete n[e],s.parentNode.removeChild(s),r(c)},s.href=o,0!==s.href.indexOf(window.location.origin+"/")&&(s.crossOrigin="anonymous"),document.getElementsByTagName("head")[0].appendChild(s)})).then((function(){n[e]=0})));var r=o[e];if(0!==r)if(r)t.push(r[2]);else{var a=new Promise((function(t,a){r=o[e]=[t,a]}));t.push(r[2]=a);var c,f=document.createElement("script");f.charset="utf-8",f.timeout=120,i.nc&&f.setAttribute("nonce",i.nc),f.src=function(e){return i.p+"js/"+({1:"common",3:"album",4:"albumDetail",5:"album_mall",6:"category",7:"index",8:"mv",9:"mvList",10:"mv_toplist",11:"notfound",12:"player",13:"playlist",14:"playlist_edit",15:"profile",16:"radio",18:"search",19:"singer",20:"singer_list",21:"songDetail",22:"toplist"}[e]||e)+".chunk."+{1:"3bbe45a7e3580e4405ca",3:"0acee4fabdfa36506f98",4:"f066bacaf25f74afa568",5:"506e014e5282494b4ce1",6:"89e1169942fe4c015111",7:"e38cd63a501bf592f475",8:"ebcebcd3d87786608ef7",9:"28112d52ce522bbcc4c8",10:"3ec39e752046e8d02700",11:"fce914a84b0935dbca45",12:"210e7be36ad1f3e893a1",13:"8d944b69a0a4ab99917f",14:"8e8058705767da5d7d23",15:"c70f62a8e5eba89177c6",16:"9099d15652b4bc87b3f9",18:"e84e5b84ce6aa9e80c7b",19:"370441a7d659334e59d8",20:"8bddba65b3be621faa68",21:"3ca313a36ea5f8814a47",22:"7f5bf4e73d9b39ae9241"}[e]+".js?max_age=2592000"}(e),0!==f.src.indexOf(window.location.origin+"/")&&(f.crossOrigin="anonymous");var d=new Error;c=function(t){f.onerror=f.onload=null,clearTimeout(l);var r=o[e];if(0!==r){if(r){var a=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;d.message="Loading chunk "+e+" failed.\n("+a+": "+n+")",d.name="ChunkLoadError",d.type=a,d.request=n,r[1](d)}o[e]=void 0}};var l=setTimeout((function(){c({type:"timeout",target:f})}),12e4);f.onerror=f.onload=c,document.head.appendChild(f)}return Promise.all(t)},i.m=e,i.c=a,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)i.d(r,a,function(t){return e[t]}.bind(null,a));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/ryqq/",i.oe=function(e){throw e};var f=window.webpackJsonp=window.webpackJsonp||[],d=f.push.bind(f);f.push=t,f=f.slice();for(var l=0;l<f.length;l++)t(f[l]);var u=d;r()}([]);
\ No newline at end of file
let n = require('./webpack_out');
let o = n('350').default;
let data = `{"comm":{"cv":4747474,"ct":24,"format":"json","inCharset":"utf-8","outCharset":"utf-8","notice":0,"platform":"yqq.json","needNewCode":1,"uin":0,"g_tk_new_20200303":5381,"g_tk":5381},"req_1":{"method":"GetCommentCount","module":"GlobalComment.GlobalCommentReadServer","param":{"request_list":[{"biz_type":1,"biz_id":"215059567","biz_sub_type":0}]}},"req_2":{"module":"music.globalComment.CommentReadServer","method":"GetNewCommentList","param":{"BizType":1,"BizId":"215059567","LastCommentSeqNo":"","PageSize":25,"PageNum":0,"FromCommentId":"","WithHot":1}},"req_3":{"module":"music.globalComment.CommentReadServer","method":"GetHotCommentList","param":{"BizType":1,"BizId":"215059567","LastCommentSeqNo":"","PageSize":15,"PageNum":0,"HotType":2,"WithAirborne":1}}}`;
console.log(data);
console.log(o(data));
因为 它太大了无法显示 source diff 。你可以改为 查看blob
const parser = require("@babel/parser");
const t = require("@babel/types");
const generator = require("@babel/generator");
const traverse = require("@babel/traverse").default;
const fs = require("fs");
function wtofile(path, flags, code) {
var fd = fs.openSync(path,flags);
fs.writeSync(fd, code);
fs.closeSync(fd);
}
function run(loader_path, out_path, modular_path) {
let js_code = fs.readFileSync(loader_path, {
encoding: "utf-8"
});
// 转换为AST语法树
let loader_ast = parser.parse(js_code);
// 获取加载器代码
let loader_body;
if (loader_ast.program.body[0].expression.type === 'UnaryExpression'){
loader_body = loader_ast.program.body[0].expression.argument.callee.body.body;
}else{
loader_body = loader_ast.program.body[0].expression.callee.body.body;
}
for (let i = 0; i < loader_body.length; i++){
if (loader_body[i].type === 'VariableDeclaration'){
let j = i + 1;
while (j < loader_body.length){
if (loader_body[j].type === 'VariableDeclaration'){
loader_body.splice(j, (loader_body.length - j));
loader_body.splice(0, i);
let tempname = '';
loader_body.forEach(function (item, index) {
if (item.type === 'FunctionDeclaration'){
tempname = item.id.name;
}
});
loader_body.push(t.assignmentExpression("=", t.identifier("export_function"), t.identifier(tempname)));
}else {
j++;
}
}
break;
}
}
// 导入加载器中的函数体
let loader_arguments;
if (loader_ast.program.body[0].expression.type === 'UnaryExpression'){
loader_arguments = loader_ast.program.body[0].expression.argument.arguments[0];
}else{
loader_arguments = loader_ast.program.body[0].expression.arguments[0];
}
if (loader_arguments.type === 'ArrayExpression'){
let tempobjectexpression = t.objectExpression([]);
loader_arguments.elements.forEach(function (item, index) {
if (item && item.type === 'FunctionExpression'){
tempobjectexpression.properties.push(t.objectProperty(
t.numericLiteral(index),
item,
false,
false
));
}
});
loader_arguments = tempobjectexpression;
}
// 加载外部函数体
modular_path.forEach(function (item, index) {
var jscode = fs.readFileSync(item, {
encoding: "utf-8"
});
let modular_ast = parser.parse(jscode);
modular_ast.program.body[0].expression.arguments[0].elements.forEach(function (item2, index2) {
if (item2.type === 'ArrayExpression'){
item2.elements.forEach(function (item3, index3) {
if (item3 && item3.type === 'FunctionExpression'){
loader_arguments.properties.push(t.objectProperty(
t.numericLiteral(index3),
item3,
false,
false
));
}
});
}else {
item2.properties.forEach(function (item3, index3) {
loader_arguments.properties.push(item3)
})
}
});
});
if (loader_ast.program.body[0].expression.type === 'UnaryExpression'){
loader_ast.program.body[0].expression.argument.arguments[0] = loader_arguments;
}else{
loader_ast.program.body[0].expression.arguments[0] = loader_arguments;
}
// 申请全局导出函数
loader_ast.program.body.splice(0, 0, t.variableDeclaration("var",[t.variableDeclarator(t.identifier("export_function"))]));
// 导出函数
loader_ast.program.body.push(t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.identifier("module"), t.identifier("exports"), false), t.identifier("export_function"))));
let code = generator.default(loader_ast, {
compact: false, // 压缩格式
comments: false, // 注释
jsescOption: {
minimal: false // 转义
}
}).code;
wtofile(out_path, 'w', code);
}
!function () {
let loader_path, out_path;
let modular_path = [];
for(let i = 0; i < process.argv.length; i++){
if (process.argv[i] === '-l'){
loader_path = process.argv[i + 1];
i += 1;
}else if(process.argv[i] === '-m'){
modular_path.push(process.argv[i + 1]);
i += 1;
}else if(process.argv[i] === '-o'){
out_path = process.argv[i + 1];
i += 1;
}
}
if (loader_path && out_path){
run(loader_path, out_path, modular_path)
}
}();
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册