Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem: couldn't parse this bundle #16

Open
HaveF opened this issue Mar 18, 2017 · 1 comment
Open

problem: couldn't parse this bundle #16

HaveF opened this issue Mar 18, 2017 · 1 comment

Comments

@HaveF
Copy link

HaveF commented Mar 18, 2017

Hi, there :-)

Due to some reasons, I can not leak my js file out for this issue. 😟

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)

2017-03-18 10 57 20

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.

@davidbstein
Copy link

davidbstein commented May 6, 2018

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
);

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

No branches or pull requests

2 participants