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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught SyntaxError: Unexpected token ')' in watch mode #7916

Closed
jtojnar opened this issue Apr 6, 2022 · 4 comments 路 Fixed by #7931
Closed

Uncaught SyntaxError: Unexpected token ')' in watch mode #7916

jtojnar opened this issue Apr 6, 2022 · 4 comments 路 Fixed by #7931

Comments

@jtojnar
Copy link
Contributor

jtojnar commented Apr 6, 2022

馃悰 bug report

When I try to build a module depending on netlify-cms using parcel, I get the following error:

Uncaught SyntaxError: Unexpected token ')' (at index.b379fa61.js:135076:47)

It seems to work when building using parcel build.

馃帥 Configuration (.babelrc, package.json, cli command)

Building with npx parcel admin/index.html --dist-dir public/admin/ --public-url .

No special configuration, see the minimal example.

馃 Expected Behavior

The code should be produced without error.

馃槸 Current Behavior

Viewing the generated file in Firefox or Chromium reveals a syntax error.

馃敠 Context

The line points to the following code:

function oe() {
    var e, t, n, r = 35 * G + 0, o = Z[r];
    if (o) return G = o.nextPos, o.result;
    for(e = G, t = [], n = ae(); n !== i674;)t.push(n), n = ae();
    return t !== i674 && (), e = t, Z[r] = {
    //                   ^
    // It鈥檚 these parens causing the error.
        nextPos: G,
        result: e
    }, e;
}

For some reason neither Chromium nor Firefox seems to use the source maps for this so I cannot determine the original source code.

馃捇 Code Sample

https://github.com/jtojnar/repro/tree/738c2d442b504378b145edde2fdc52c8b2e217a0/parcel-netlify-cms

馃實 Your Environment

Software Version(s)
Parcel 2.4.1
Node 16.14.2
npm/Yarn 8.5.0
Operating System NixOS
@devongovett
Copy link
Member

Possibly fixed by #7886, which hasn't been released yet. You could try the latest nightly version and see if that fixes it?

jtojnar added a commit to jtojnar/repro that referenced this issue Apr 7, 2022
To try to fix parcel-bundler/parcel#7916.

Also remove pointless --dist-dir and npx from build scripts.
@jtojnar
Copy link
Contributor Author

jtojnar commented Apr 7, 2022

I can still reproduce this on 2.0.0-nightly.1039+211502e55.

@devongovett
Copy link
Member

devongovett commented Apr 7, 2022

Original code (from https://unpkg.com/netlify-cms@2.10.190/dist/cms.js):

function oe() {
    var e, t, n, r = 35 * G + 0,
        o = Z[r];
    if (o) return G = o.nextPos, o.result;
    for (e = G, t = [], n = ae(); n !== i;) t.push(n), n = ae();
    return t !== i && (e, t = t), e = t, Z[r] = {
        nextPos: G,
        result: e
    }, e
}

Probably due to:

paren_remover(Some(&comments)),
// Simplify expressions and remove dead branches so that we
// don't include dependencies inside conditionals that are always false.
expr_simplifier(Default::default()),
dead_branch_remover(),

Should the paren_remover be after the expr simplifier? cc. @mischnic

@mischnic
Copy link
Member

mischnic commented Apr 7, 2022

As far as I understand it, paren_remover doesn't actually remove comments, it just attaches the comments correctly so that they doesn't get removed. swc-project/swc#3115 (comment)

Also, this is caused by the dead_branch_remover: swc-project/swc#4272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants