-
Notifications
You must be signed in to change notification settings - Fork 54
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
Crash inside escodegen when minifying JavaScript class statement. #1303
Comments
Inserting a print statement into escodegen I see that the unknown type is |
% rg -w PropertyDefinition node_modules node_modules/acorn/dist/acorn.d.mts 375: body: Array<MethodDefinition | PropertyDefinition | StaticBlock> 479:export interface PropertyDefinition extends Node { 480: type: "PropertyDefinition" 565:export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock node_modules/acorn/dist/acorn.d.ts 375: body: Array<MethodDefinition | PropertyDefinition | StaticBlock> 479:export interface PropertyDefinition extends Node { 480: type: "PropertyDefinition" 565:export type AnyNode = Statement | Expression | Declaration | ModuleDeclaration | Literal | Program | SwitchCase | CatchClause | Property | Super | SpreadElement | TemplateElement | AssignmentProperty | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | ClassBody | MethodDefinition | MetaProperty | ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier | AnonymousFunctionDeclaration | AnonymousClassDeclaration | PropertyDefinition | PrivateIdentifier | StaticBlock node_modules/acorn/dist/acorn.js 1565: return this.finishNode(field, "PropertyDefinition") node_modules/acorn/dist/acorn.mjs 1559: return this.finishNode(field, "PropertyDefinition") node_modules/terser/lib/mozilla-ast.js 434: PropertyDefinition: function(M) { 448: throw new Error("Non-Identifier key in PropertyDefinition"); 720: : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty) 1606: type: "PropertyDefinition", 1618: type: "PropertyDefinition", node_modules/terser/dist/bundle.min.js 7410: PropertyDefinition: function(M) { 7424: throw new Error("Non-Identifier key in PropertyDefinition"); 7696: : p.type == "PropertyDefinition" || p.type === "FieldDefinition" ? (p.key === M && p.computed || p.value === M ? AST_SymbolRef : AST_SymbolClassProperty) 8582: type: "PropertyDefinition", 8594: type: "PropertyDefinition", node_modules/uglify-js/lib/mozilla-ast.js 176: PropertyDefinition: function(M) { 741: type: "PropertyDefinition", node_modules/estraverse/estraverse.js 130: PropertyDefinition: 'PropertyDefinition', 208: PropertyDefinition: ['key', 'value'], |
It seems like the latest I see estools/escodegen#438. However it creates a handler for I see estools/escodegen#443 which creates |
This same issue appears to exist on master |
@kevincox, would you be up for contributing a fix to escodegen? |
Unlikely to happen soon. But maybe at some point. |
In any case, that's where it has to be implemented. A good starting point would be to look at the estree spec for |
I guess we could also try to replace escodegen with another module, such as astring. That's just a bit more complicated, as we've exposed some of escodegen's flags in different places. |
I ended up implementing it: estools/escodegen#465 |
Excellent! 💪 |
Result:
Versions
assetgraph: 7.12.0
node: 20.11.1
package-lock.json
The text was updated successfully, but these errors were encountered: