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

escodegen fails on Class fields usage #174

Closed
thescientist13 opened this issue Nov 14, 2024 · 0 comments · Fixed by #176
Closed

escodegen fails on Class fields usage #174

thescientist13 opened this issue Nov 14, 2024 · 0 comments · Fixed by #176
Assignees
Labels
bug Something isn't working v0.15.1
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Nov 14, 2024

Type of Change

Bug

Summary

Observed while working on ProjectEvergreen/greenwood#1321 / ProjectEvergreen/greenwood#1183 that it looks like various Class related features don't seem to work

class Counter extends HTMLElement {
  static staticProperty = 'foo';
  #count;

  // ...
}

customElements.define('wcc-counter', Counter);
    1) Run WCC For 
       "before all" hook in "Run WCC For ":
     TypeError: this[type] is not a function
      at CodeGenerator.generateExpression (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:2514:24)
      at file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:1131:34
      at withIndent (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:579:5)
      at CodeGenerator.ClassBody (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:1126:9)
      at CodeGenerator.generateStatement (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:2527:29)
      at CodeGenerator.ClassDeclaration (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:1157:26)
      at CodeGenerator.generateStatement (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:2527:29)
      at CodeGenerator.Program (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:1716:39)
      at CodeGenerator.generateStatement (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:2527:29)
      at generateInternal (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:2548:24)
      at generate (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/@projectevergreen/escodegen-esm/escodegen.js:2616:14)
      at Object.ExpressionStatement (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/src/wcc.js:130:19)
      at c (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:24:41)
      at Object.skipThrough (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:180:37)
      at c (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:23:22)
      at base.Program.base.BlockStatement.base.StaticBlock (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:192:5)
      at c (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:23:22)
      at Module.simple (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:25:5)
      at registerDependencies (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/src/wcc.js:101:8)
      at Object.ImportDeclaration (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/src/wcc.js:115:9)
      at c (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:24:41)
      at Object.skipThrough (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:180:37)
      at c (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:23:22)
      at base.Program.base.BlockStatement.base.StaticBlock (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:192:5)
      at c (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:23:22)
      at Module.simple (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/node_modules/acorn-walk/dist/walk.mjs:25:5)
      at registerDependencies (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/src/wcc.js:101:8)
      at initializeCustomElement (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/src/wcc.js:203:5)
      at renderToString (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/src/wcc.js:241:33)
      at async Context. (file:///Users/owenbuckley/Workspace/project-evergreen/wcc/test/cases/attributes/attributes.spec.js:26:22)
  

Details

It looks this is a known issue with ecodegen but unfortunately there are PRs open, but their review / merging has gone stale 😞

It looks like there may be a way to patch this behavior
estools/escodegen#438 (comment)

which would have to be done in our fork
https://www.npmjs.com/package/@projectevergreen/escodegen-esm

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

Successfully merging a pull request may close this issue.

1 participant