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

TypeError: Cannot read properties of undefined (reading 'line') at Object.fixFaultyLocations (node_modules/recast/lib/util.js:153:23) #51

Closed
0xdevalias opened this issue Nov 20, 2023 · 7 comments
Labels
bug Something isn't working upstream

Comments

@0xdevalias
Copy link

0xdevalias commented Nov 20, 2023

Attempting to unpack/unminify some webpacked code (Ref):

 cd ./unpacked/_next/static/chunks

 npx @wakaru/unpacker pages/_app.js -o ./pages/_app-unpacked/
Generated 213 modules from pages/_app.js to pages/_app-unpacked (24,049ms)

 npx @wakaru/unminify ./pages/_app-unpacked/* -o ./pages/_app-unminified
# ..snip..

I got the following error while attempting to unminify:

# ..snip..
• Transforming pages/_app-unminified/pages/_app-unpacked/module-76984.js (203.7ms)
TypeError: Cannot read properties of undefined (reading 'line')
    at Object.fixFaultyLocations (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/util.js:153:23)
    at TreeCopier.TCp.copy (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:138:10)
    at TreeCopier.TCp.copy (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:190:30)
    at TreeCopier.TCp.copy (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:190:30)
    at TreeCopier.TCp.copy (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:190:30)
    at TreeCopier.TCp.copy (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:190:30)
    at TreeCopier.TCp.copy (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:190:30)
    at TreeCopier.TCp.copy (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:190:30)
    at TreeCopier.<anonymous> (/Users/devalias/dev/0xdevalias/REDACTED/node_modules/recast/lib/parser.js:131:30)
    at Array.forEach (<anonymous>)
• Transforming pages/_app-unminified/pages/_app-unpacked/module-7718.js (2,651.5ms)
# ..snip..
@pionxzh pionxzh added the bug Something isn't working label Nov 21, 2023
@pionxzh
Copy link
Owner

pionxzh commented Nov 26, 2023

This is not stable to reproduce, it only happened on the CLI... Still investigating

And the file will still be generated, not sure what exactly is wrong.

@pionxzh
Copy link
Owner

pionxzh commented Nov 26, 2023

This issue is either from lebab or recast or espree.
The main issue is with the code new.target.

See lebab/lebab#352

@pionxzh
Copy link
Owner

pionxzh commented Jan 11, 2024

This seems fixed by the new version of lebab, or by some mystery factor. I can run the sample without error now.

@pionxzh
Copy link
Owner

pionxzh commented Jan 11, 2024

Hold on. I can still reproduce the error in a smaller sample, bet ye, not sure why the CLI is working fine now. Will track this in lebab side.

@pionxzh
Copy link
Owner

pionxzh commented Jan 11, 2024

I have submitted a PR to lebab to allow passing a custom parser, which can fix this issue by using the babel parser.

@pionxzh pionxzh reopened this Jan 11, 2024
@pionxzh
Copy link
Owner

pionxzh commented Jan 13, 2024

Patched recast 😓

@pionxzh
Copy link
Owner

pionxzh commented Jan 21, 2024

released #103

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

No branches or pull requests

2 participants