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

[unpacker] SyntaxError: Private name #Y is not defined #98

Closed
0xdevalias opened this issue Jan 6, 2024 · 7 comments
Closed

[unpacker] SyntaxError: Private name #Y is not defined #98

0xdevalias opened this issue Jan 6, 2024 · 7 comments
Labels
bug Something isn't working scope: unminify

Comments

@0xdevalias
Copy link

0xdevalias commented Jan 6, 2024

Describe the bug

⇒ npm run-script wakaru-chunk pages/_app

> [email protected] wakaru-chunk
> f() { CHUNK="$1"; npx @wakaru/cli all unpacked/_next/static/chunks/${CHUNK}.js --unpacker-output stage2-unpacked/${CHUNK} --unminify-output stage3-unminified/${CHUNK} --perf; }; f pages/_app


┌   Wakaru CLI v0.0.3
│
└  Selected features: Unpacker, Unminify

┌   Unpacker
│
◇  Unpacking...
SyntaxError: Private name #Y is not defined. (161:11)
    at constructor (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:18018:23)
    at FlowParserMixin.raise (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:20914:23)
    at ClassScopeHandler.exit (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:21006:25)
    at FlowParserMixin.parseClassBody (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:31194:25)
    at FlowParserMixin.parseClass (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:31137:26)
    at FlowParserMixin.parseExprAtom (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:28944:25)
    at FlowParserMixin.parseExprAtom (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:24656:24)
    at FlowParserMixin.parseExprSubscripts (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:28646:27)
    at FlowParserMixin.parseUpdate (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:28628:25)
    at FlowParserMixin.parseMaybeUnary (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/chunk-KOQHKJQW.cjs:28604:27) {
  code: 'BABEL_PARSER_SYNTAX_ERROR',
  reasonCode: 'InvalidPrivateFieldResolution',
  loc: Position { line: 161, column: 11, index: 4169 },
  pos: 4169
}

Input code

From this commit:

Direct file link:

Reproduction

No response

Steps to reproduce

CHUNK="pages/_app"; npx @wakaru/cli all unpacked/_next/static/chunks/${CHUNK}.js --unpacker-output stage2-unpacked/${CHUNK} --unminify-output stage3-unminified/${CHUNK} --perf;

Expected behavior

Unpack/Unminify works properly.

Actual behavior

The error described above occurs.

@pionxzh pionxzh added bug Something isn't working and removed pending triage labels Jan 6, 2024
@pionxzh
Copy link
Owner

pionxzh commented Jan 6, 2024

This is related to #32, it shouldn't rename the Y to module.

@pionxzh pionxzh closed this as completed in 6d0930d Jan 6, 2024
@0xdevalias
Copy link
Author

0xdevalias commented Jan 6, 2024

@pionxzh That's fair. Any workarounds for it in the meantime? Or is it just broken till #32 is solved?

@pionxzh
Copy link
Owner

pionxzh commented Jan 6, 2024

Already fixed by handling private field. I also improved the error handling and logging, the file will be generated even though there is a parsing error. Will release a new version with the runner performance improvement PR.

@0xdevalias
Copy link
Author

Awesome, thanks! :)

@pionxzh
Copy link
Owner

pionxzh commented Jan 6, 2024

Released 🚀

@0xdevalias
Copy link
Author

Thanks :)

For future reference, this was released in:

Which I believe is also included in:

(It might be useful to include the version of unpacker/unminify used by the CLI in the CLI release notes to remove ambiguity)

@0xdevalias
Copy link
Author

0xdevalias commented Jan 6, 2024

Confirming that it works with CLI 0.0.5 🎉

Though still seeing the out/perf.json issue:

And there were a bunch of unminify errors that I will open a new issue for.

Edit: Here is the issue for those errors:


⇒ npm run-script wakaru:unminify-chunk pages/_app

> [email protected] wakaru:unminify-chunk
> f() { CHUNK="$1"; npx @wakaru/cli all unpacked/_next/static/chunks/${CHUNK}.js --unpacker-output stage2-unpacked/${CHUNK} --unminify-output stage3-unminified/${CHUNK} --perf; }; f pages/_app


┌   Wakaru CLI v0.0.5
│
└  Selected features: Unpacker, Unminify

┌   Unpacker
│
◇  Unpacking unpacked/_next/static/chunks/pages/_app.js
│
◇  Finished
│
◆  Successfully generated 1224 modules (3m2s)
│
└  Output directory: ./stage2-unpacked/pages/_app

┌   Unminify
│
◇  Unminifying... (concurrency: 1)
│
◒  ..Multiple exports of "default" found, only the last one will be kept
◐

..snip: many unminify errors here (will open a new issue for them)..

◇  Finished
│
◆  Successfully unminified 1224 files (19m44s)
│
└  Output directory: ./stage3-unminified/pages/_app


┌─────────┬──────────────────────────┬────────┐
│ (index) │           key            │  time  │
├─────────┼──────────────────────────┼────────┤
│    0    │     'un-while-loop'      │  2070  │
│    1    │  'un-flip-comparisons'   │  2079  │
│    2    │   'un-numeric-literal'   │  2160  │
│    3    │       'un-return'        │  2167  │
│    4    │  'un-bracket-notation'   │  2181  │
│    5    │       'un-boolean'       │  2203  │
│    6    │  'un-template-literal'   │  2220  │
│    7    │     'un-use-strict'      │  2287  │
│    8    │      'un-undefined'      │  2634  │
│    9    │  'un-variable-merging'   │  2823  │
│   10    │ 'un-assignment-merging'  │  2990  │
│   11    │     'module-mapping'     │  3587  │
│   12    │     'un-async-await'     │  4060  │
│   13    │        'un-iife'         │  4164  │
│   14    │       'un-typeof'        │  4247  │
│   15    │      'un-infinity'       │  4316  │
│   16    │    'un-esmodule-flag'    │  4557  │
│   17    │  'un-type-constructor'   │  6155  │
│   18    │    'un-conditionals'     │  6688  │
│   19    │        'un-enum'         │  6848  │
│   20    │      'un-es6-class'      │  8848  │
│   21    │    'un-export-rename'    │ 10312  │
│   22    │     'un-parameters'      │ 11368  │
│   23    │  'un-builtin-prototype'  │ 12446  │
│   24    │       'prettier-1'       │ 14311  │
│   25    │        'prettier'        │ 15642  │
│   26    │         'un-jsx'         │ 16243  │
│   27    │      'smart-inline'      │ 16392  │
│   28    │    'un-curly-braces'     │ 17804  │
│   29    │ 'un-nullish-coalescing'  │ 21042  │
│   30    │  'un-optional-chaining'  │ 21216  │
│   31    │      'smart-rename'      │ 26297  │
│   32    │   'jscodeshift-print'    │ 30003  │
│   33    │   'un-runtime-helper'    │ 70873  │
│   34    │ 'un-sequence-expression' │ 76342  │
│   35    │  'un-parameters-lebab'   │ 96794  │
│   36    │    'un-indirect-call'    │ 130591 │
│   37    │         'lebab'          │ 134495 │
│   38    │         'un-esm'         │ 141852 │
│   39    │        'unpacker'        │ 182051 │
│   40    │   'jscodeshift-parse'    │ 235709 │
└─────────┴──────────────────────────┴────────┘
Error: ENOENT: no such file or directory, open 'out/perf.json'
    at Object.openSync (node:fs:592:3)
    at Object.writeFileSync (node:fs:2323:35)
    at Object.writeFileSync (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/jsonfile/index.js:78:13)
    at writePerfStats (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/cli.cjs:2421:21)
    at nonInteractive (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/cli.cjs:2372:5)
    at async Object.handler (/Users/devalias/dev/0xdevalias/chatgpt-source-watch/node_modules/@wakaru/cli/dist/cli.cjs:2014:5) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'out/perf.json'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scope: unminify
Projects
None yet
Development

No branches or pull requests

2 participants