wakaru: [unminify-bugs] Multiple errors during unminify with CLI 0.0.5
Describe the bug
Summary of warnings/errors:
???
- Multiple exports of “default” found, only the last one will be kept
- @pionxzh It would be useful if this message mentioned what module was being processed at the time
- Multiple exports of “default” found, only the last one will be kept
stage2-unpacked/pages/_app/module-85695.js
- Error running rule
un-parameters-lebab
onmodule-85695.js
SyntaxError: Unexpected token yyyy - Failed to parse rule
module-85695.js
with jscodeshift in ruleun-jsx
SyntaxError: Unexpected token, expected “,” (4948:12)- @pionxzh Instead of “Failed to parse rule” this probably should be “Failed to parse module” or similar I think?
- Failed to parse rule
module-85695.js
with jscodeshift in ruleun-iife
SyntaxError: Unexpected token, expected “,” (4948:12) - Failed to parse rule
module-85695.js
with jscodeshift in ruleun-es6-class
SyntaxError: Unexpected token, expected “,” (4948:12) - Failed to parse rule
module-85695.js
with jscodeshift in ruleun-async-await
SyntaxError: Unexpected token, expected “,” (4948:12) - Error running rule prettier on
module-85695.js
SyntaxError: Unexpected token, expected “,” (4948:13)
- Error running rule
stage2-unpacked/pages/_app/module-73797.js
- Error running rule
un-parameters-lebab
onmodule-73797.js
SyntaxError: Identifier ‘Z’ has already been declared - Failed to parse rule
module-73797.js
with jscodeshift in ruleun-jsx
SyntaxError: Identifier ‘Z’ has already been declared. (104:13) - Failed to parse rule
module-73797.js
with jscodeshift in ruleun-iife
SyntaxError: Identifier ‘Z’ has already been declared. (104:13) - Failed to parse rule
module-73797.js
with jscodeshift in ruleun-es6-class
SyntaxError: Identifier ‘Z’ has already been declared. (104:13) - Failed to parse rule
module-73797.js
with jscodeshift in ruleun-async-await
SyntaxError: Identifier ‘Z’ has already been declared. (104:13)
- Error running rule
stage2-unpacked/pages/_app/module-33562.js
- Error running rule
un-parameters-lebab
onmodule-33562.js
SyntaxError: Identifier ‘Z’ has already been declared - Failed to parse rule
module-33562.js
with jscodeshift in ruleun-jsx
SyntaxError: Identifier ‘Z’ has already been declared. (91:13) - Failed to parse rule
module-33562.js
with jscodeshift in ruleun-iife
SyntaxError: Identifier ‘Z’ has already been declared. (91:13) - Failed to parse rule
module-33562.js
with jscodeshift in ruleun-es6-class
SyntaxError: Identifier ‘Z’ has already been declared. (91:13) - Failed to parse rule
module-33562.js
with jscodeshift in ruleun-async-await
SyntaxError: Identifier ‘Z’ has already been declared. (91:13)
- Error running rule
stage2-unpacked/pages/_app/module-34408.js
- Error running rule
un-parameters-lebab
onmodule-34408.js
SyntaxError: Identifier ‘Z’ has already been declared - Failed to parse rule
module-34408.js
with jscodeshift in ruleun-jsx
SyntaxError: Identifier ‘Z’ has already been declared. (46:13) - Failed to parse rule
module-34408.js
with jscodeshift in ruleun-iife
SyntaxError: Identifier ‘Z’ has already been declared. (46:13) - Failed to parse rule
module-34408.js
with jscodeshift in ruleun-es6-class
SyntaxError: Identifier ‘Z’ has already been declared. (46:13) - Failed to parse rule
module-34408.js
with jscodeshift in ruleun-async-await
SyntaxError: Identifier ‘Z’ has already been declared. (46:13)
- Error running rule
stage2-unpacked/pages/_app/module-65100.js
- Error running rule
un-parameters-lebab
onmodule-65100.js
SyntaxError: Unexpected token $ - Failed to parse rule
module-65100.js
with jscodeshift in ruleun-jsx
SyntaxError: Missing semicolon. (310:15) - Failed to parse rule
module-65100.js
with jscodeshift in ruleun-iife
SyntaxError: Missing semicolon. (310:15) - Failed to parse rule
module-65100.js
with jscodeshift in ruleun-es6-class
SyntaxError: Missing semicolon. (310:15) - Failed to parse rule
module-65100.js
with jscodeshift in ruleun-async-await
SyntaxError: Missing semicolon. (310:15) - Error running rule prettier on
module-65100.js
SyntaxError: Missing semicolon. (310:16)
- Error running rule
stage2-unpacked/pages/_app/module-80894.js
- Error running rule
un-parameters-lebab
onmodule-80894.js
SyntaxError: Identifier ‘Z’ has already been declared - Failed to parse rule
module-80894.js
with jscodeshift in ruleun-jsx
SyntaxError: Identifier ‘Z’ has already been declared. (103:13) - Failed to parse rule
module-80894.js
with jscodeshift in ruleun-iife
SyntaxError: Identifier ‘Z’ has already been declared. (103:13) - Failed to parse rule
module-80894.js
with jscodeshift in ruleun-es6-class
SyntaxError: Identifier ‘Z’ has already been declared. (103:13) - Failed to parse rule
module-80894.js
with jscodeshift in ruleun-async-await
SyntaxError: Identifier ‘Z’ has already been declared. (103:13)
- Error running rule
???
- Multiple exports of “default” found, only the last one will be kept
stage2-unpacked/pages/_app/module-32004.js
- Error running rule
un-parameters-lebab
onmodule-32004.js
SyntaxError: Identifier ‘Z’ has already been declared - Failed to parse rule
module-32004.js
with jscodeshift in ruleun-jsx
SyntaxError: Identifier ‘Z’ has already been declared. (50:13) - Failed to parse rule
module-32004.js
with jscodeshift in ruleun-iife
SyntaxError: Identifier ‘Z’ has already been declared. (50:13) - Failed to parse rule
module-32004.js
with jscodeshift in ruleun-es6-class
SyntaxError: Identifier ‘Z’ has already been declared. (50:13) - Failed to parse rule
module-32004.js
with jscodeshift in ruleun-async-await
SyntaxError: Identifier ‘Z’ has already been declared. (50:13)
- Error running rule
stage2-unpacked/pages/_app/module-49948.js
- Error running rule
un-parameters-lebab
onstage2-unpacked/pages/_app/module-49948.js
Error: did not recognize object of type “PropertyDefinition”
- Error running rule
- Error: ENOENT: no such file or directory, open ‘out/perf.json’
Input code
From this commit:
- https://github.com/0xdevalias/chatgpt-source-watch/commit/48088035667d123c839b05871be5cb37de75dd5f
- `unpacked/_next/static/chunks/pages/_app.js`
Direct file link:
- https://github.com/0xdevalias/chatgpt-source-watch/blob/48088035667d123c839b05871be5cb37de75dd5f/unpacked/_next/static/chunks/pages/_app.js
Reproduction
No response
Steps to reproduce
See above
Expected behavior
Unpack/Unminify works properly.
Actual behavior
The error described above occurs.
About this issue
- Original URL
- State: closed
- Created 6 months ago
- Comments: 18 (12 by maintainers)
Commits related to this issue
- fix: should stale the scope after renaming or adding new varaible #100 — committed to pionxzh/wakaru by pionxzh 6 months ago
- fix: handle escaped character in template literal #100 — committed to pionxzh/wakaru by pionxzh 6 months ago
- fix: print filename on warning "Multiple exports of ..." #100 — committed to pionxzh/wakaru by pionxzh 6 months ago
- fix(un-esm): properly handle the export order of mixed exports #100 — committed to pionxzh/wakaru by pionxzh 6 months ago
- fix(unminify): add error handling to early exit the rule loop #100 — committed to pionxzh/wakaru by pionxzh 6 months ago
- fix: bump `lebab` to 3.2.4 closes #51, #100 — committed to pionxzh/wakaru by pionxzh 6 months ago
- fix: `ast-types` does not recognize `PropertyDefinition` #100 — committed to pionxzh/wakaru by pionxzh 6 months ago
yes, currently looks like this (webpack 5 doesn’t have that many tests because the logic is mostly the same) feel free to expand if you find any more
exports
imports
module 19841 has to be converted to one of these:
there’s no commonjs/mixed export so no
module.exports =
either, which should get rid of the issueexample for comparison (webpack 4):
I recently bundled all possible import/export/esm/commonjs combinations and we both need to fix quite a bit to do it “properly” 😅
https://github.com/lebab/lebab/issues/353
But I might want to re-implement these rules in the long run…
@0xdevalias This is related to
lebab
. I’m still working on creating a minimal reproduction. But no more repeated parsing error in CLI0.0.6
.All released in CLI
0.0.7
All errors are fixed. I will move @j4k0xb 's CJS/ESM part to a new issue.
It’s caused by the combination of the private field and the numeric comment. I will have to spend some time digging into
ast-types
😞 and patch it by myself.Thanks for the detailed test cases 🙏 Especially for those re-export cases, I haven’t seen them before.
lol damm. Thanks. I was so confused about this.
Did you make a test suite or something that we can use as a reference?
Oh, hm, should early return the result when there is a parsing error.
I have updated the log to print out the filename.
The
module.exports = x
assignment will overwrite the default export, which means the first line will be dropped. This is either something wrong orwakaru
wrong. So a warning was printed to hint to users.BUG: because of the AST scanning order, we actually chose the first one… will fix it
This one looks similar to #51, lebab failed to parse the code.
I’m 100% sure about the root cause. It’s quite interesting. If you change the
3e5
to35
, then wakaru won’t generate a/* 3e5 */
comment, then everything works fine 😅This is caused by the new rule runner. Some scopes are not naturally reset between rules because of the sharing AST. Fixed. This is not easy to cover with normal unit tests. Maybe we can only count on the time and samples.
This is an unhandled case in which backticks and other special characters need to be escaped. Fixed.
We will need a logger injected by the context which will automatically print the file and rule name.