browser-unpack
browser-unpack copied to clipboard
problem: couldn't parse this bundle
Hi, there :-)
Due to some reasons, I can not leak my js file out for this issue. :worried:
Maybe you can give me a little advice about this.
I encounter this error at command line: couldn't parse this bundle
, and after that, clone this repo, do debug to find where throw this error, finally, I find this line, it will return when ast.body.length not equal 1, but here is my ast.body(see the picture below)
There are "ExpressionStatement"
, "IfStatement"
there. Because I know nothing about ast things, but maybe you can give me a advice how to fix this? Thanks in advance.
Are you still having this error? Your problem is that your input bundle is not a file. The AST is a list of the statements in your js
file,
for example:
1| console.log("foo");
2|
3| if (window.location !== "bar") {
4| var a = 3;
5| alert(a);
6| }
would return an ast.body of length 2
(one element is an ExpressionStatement
for line 1, one is an IfStatement
for lines 3-6)
A bundle needs to be a single UnaryExprssion
. Specifically, it should looks like the output of browserify or similar
(function e(t,n,r){/*A COUPLE LINES OF MAGIC*/})(
//ALL OF YOUR CODE
);