Skip to content

Plan and start ES6 migration#4

Merged
marevol merged 2 commits into
mainfrom
claude/es6-migration-plan-01NaKQ66wk7DQ6hsvFGkU8re
Nov 29, 2025
Merged

Plan and start ES6 migration#4
marevol merged 2 commits into
mainfrom
claude/es6-migration-plan-01NaKQ66wk7DQ6hsvFGkU8re

Conversation

@marevol

@marevol marevol commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

This commit implements ES6/ECMAScript 2015+ support for YUICompressor:

  • Upgrade language version from VERSION_1_8 to VERSION_ES6
  • Add ES6 reserved words (let, const, await, yield, of, async, etc.)
  • Arrow functions with proper => syntax preservation
  • Template literals with backticks and interpolation
  • All comparison, logical, and bitwise operators
  • Control flow statements (if/else, for, while, switch, try/catch)
  • For-in/for-of loops with proper variable scoping
  • Destructuring pattern variable extraction
  • Generator functions with function* syntax
  • Add ES6SupportTest.java with 40+ test cases
  • Add comprehensive ES6_MIGRATION_PLAN.md

This commit implements ES6/ECMAScript 2015+ support for YUICompressor:

- Upgrade language version from VERSION_1_8 to VERSION_ES6
- Add ES6 reserved words (let, const, await, yield, of, async, etc.)
- Arrow functions with proper => syntax preservation
- Template literals with backticks and interpolation
- All comparison, logical, and bitwise operators
- Control flow statements (if/else, for, while, switch, try/catch)
- For-in/for-of loops with proper variable scoping
- Destructuring pattern variable extraction
- Generator functions with function* syntax
- Add ES6SupportTest.java with 40+ test cases
- Add comprehensive ES6_MIGRATION_PLAN.md
@marevol marevol requested a review from Copilot November 28, 2025 23:04
@marevol marevol self-assigned this Nov 28, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements ES6/ECMAScript 2015+ support for YUICompressor by upgrading the language version from ES5.1 to ES6, adding comprehensive support for modern JavaScript syntax including arrow functions, template literals, and enhanced control flow handling.

Key changes:

  • Upgraded Rhino parser from VERSION_1_8 to VERSION_ES6 for ES6+ syntax parsing
  • Added ES6 reserved words (let, const, await, yield, of, async, etc.) to prevent munging
  • Implemented explicit code generation for 40+ ES6 features including arrow functions, template literals, all operators, and control structures

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ES6SupportTest.java Comprehensive test suite with 40+ test cases covering ES6 features including arrow functions, template literals, operators, control flow, and AST parsing
ScopeBuilder.java Enhanced scope tracking for ES6 features including destructuring patterns, for-in/of loops, try-catch blocks, and object property handling
MungedCodeGenerator.java Extended code generation with explicit handlers for ES6 syntax including arrow functions, template literals, all operators, control statements, and proper precedence handling
JavaScriptCompressor.java Updated parser configuration to VERSION_ES6 and added ES6 reserved words to prevent munging
ES6_MIGRATION_PLAN.md Detailed migration plan documenting ES6 support implementation phases, priorities, and completion status

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

break;

// For-in and For-of loops
case 162: // Token.FOR_IN (may vary by Rhino version)

Copilot AI Nov 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a magic number (162) for Token.FOR_IN is fragile and error-prone. This should use the proper token constant like Token.FOR_IN or a documented constant. If the token value truly varies by Rhino version, this needs version detection logic or a configuration option.

Suggested change
case 162: // Token.FOR_IN (may vary by Rhino version)
case Token.FOR_IN:

Copilot uses AI. Check for mistakes.
Comment on lines +209 to +211
if (element != null && !(element instanceof EmptyExpression)) {
declareVariableIdentifiers(element, scope);
}

Copilot AI Nov 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EmptyExpression check is present in declareVariableIdentifiers for arrays but not in declareParameterIdentifiers (line 182). Consider adding the same check to declareParameterIdentifiers for consistency, or document why array parameters don't need this check.

Copilot uses AI. Check for mistakes.
…estructuring

- Handle ForInLoop correctly by checking instanceof before ForLoop
- Add Scope block handling alongside Block for let/const scopes
- Fix getter/setter detection using isGetterMethod/isSetterMethod
- Skip empty elements in array destructuring parameters ([a, , b])
- Add comprehensive ES6 tests and @ignore unsupported features
- Add .serena/ to .gitignore

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@marevol marevol merged commit 2177b06 into main Nov 29, 2025
6 checks passed
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

Successfully merging this pull request may close these issues.

3 participants