xmader / retidy Goto Github PK
View Code? Open in Web Editor NEWExtract, unminify, and beautify ("retidy") each file from a webpack/parcel bundle (JavaScript reverse engineering)
License: MIT License
Extract, unminify, and beautify ("retidy") each file from a webpack/parcel bundle (JavaScript reverse engineering)
License: MIT License
Hello, it would be fantastic to have support for files in the form of
(window.webpackJsonp = window.webpackJsonp || []).push(/* ... */);
Any way of making this work, please? ๐๐ป
unminify-if-statements.ts
return x || a() -> if (!x) { return a() }
when x is true, it returns undefined
I disabled this transformer to make it work
run retidy -i document.min.js -entryPoint 0
/home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/node_modules/yargs-parser/index.js:495
Object.defineProperty(argvReturn, key, {
^
TypeError: Cannot redefine property: i
at Function.defineProperty (<anonymous>)
at /home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/node_modules/yargs-parser/index.js:495:16
at Array.forEach (<anonymous>)
at setArg (/home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/node_modules/yargs-parser/index.js:494:12)
at parse (/home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/node_modules/yargs-parser/index.js:272:11)
at Function.Parser.detailed (/home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/node_modules/yargs-parser/index.js:1022:10)
at Object.parseArgs [as _parseArgs] (/home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/node_modules/yargs/build/lib/yargs.js:998:31)
at Object.get [as argv] (/home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/node_modules/yargs/build/lib/yargs.js:986:25)
at Object.<anonymous> (/home/i/.nvm/versions/node/v13.11.0/lib/node_modules/retidy/cli/cli.js:47:48)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
Hello,
I'm trying to debundle a very short react file using retidy.
This is my test.js file:
test.js
import retidy from "retidy"
import fs from "fs"
const code = fs.readFileSync("vendor-bundle.js", "utf-8")
retidy.retidy(code, { type: "webpack-jsonp", outDir: "./out/", bundleAstReferenceKeys: ["body", 0, "expression"] })
This is the file to be unbundled:
vendor-bundle.js
!function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var t=window.webpackJsonp;window.webpackJsonp=function(a,l){for(var p,c,s=0,i=[];s<a.length;s++)c=a[s],o[c]&&i.push.apply(i,o[c]),o[c]=0;for(p in l)e[p]=l[p];for(t&&t(a,l);i.length;)i.shift().call(null,n);return l[0]?(r[0]=0,n(0)):void 0};var r={},o={4:0,6:0};n.e=function(e,t){if(0===o[e])return t.call(null,n);if(void 0!==o[e])o[e].push(t);else{o[e]=[t];var r=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.src=n.p+""+e+"."+({5:"bundle",6:"common-bundle"}[e]||e)+".js",r.appendChild(a)}},n.m=e,n.c=r,n.p=""}([]);
This is my package.json:
package.json
{
"name": "testapp",
"version": "1.0.0",
"type": "module",
"description": "",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"retidy": "^1.5.1"
}
}
And I have a common-bundle.js file:
common-bundle.js
webpackJsonp([6,4],[]);
This is the error i get running node --trace-warnings test.js
:
(node:9928) UnhandledPromiseRejectionWarning: TypeError: not a webpackBootstrap function call AST.
at Object.exports.notWebpackBootstrapAstErr (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:17:58)
at Object.exports.extractModules (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:41:23)
at exports.webpackExtractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\webpack-extractor.js:6:43)
at Object.exports.extractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\extractor.js:20:12)
at C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:124:46
at step (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:33:23)
at Object.next (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:14:53)
at fulfilled (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:5:58)
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:9928) TypeError: not a webpackBootstrap function call AST.
at Object.exports.notWebpackBootstrapAstErr (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:17:58)
at Object.exports.extractModules (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\extract-modules.js:41:23)
at exports.webpackExtractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\webpack\webpack-extractor.js:6:43)
at Object.exports.extractor (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\extractor\extractor.js:20:12)
at C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:124:46
at step (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:33:23)
at Object.next (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:14:53)
at fulfilled (C:\Users\Roberto\Desktop\retidy\node_modules\retidy\dist\index.js:5:58)
(node:9928) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
I'm doing something wrong for sure, but I don't know what.
And I have no idea of what to write in the bundleAstReferenceKeys (and maybe in entryPoint option too)
Could someone help me?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.