Closed domoskanonos closed 1 year ago
could you post some reproduction code please? :)
Seems like currClass
https://github.com/open-wc/custom-elements-manifest/blob/e5eca5bbd4407b90c2801e0c9634cba7bcfe7b8e/packages/analyzer/src/features/framework-plugins/lit/static-properties.js#L75
which we get from here https://github.com/open-wc/custom-elements-manifest/blob/e5eca5bbd4407b90c2801e0c9634cba7bcfe7b8e/packages/analyzer/src/features/framework-plugins/lit/static-properties.js#L18
is not found for some reason, gotta figure out why, but need some reproduction code/playground url to be able to investigate
Not sure why different node versions would have anything to do with it though, we don't really do anything exotic in that regard.
import {LitElement, TemplateResult, html} from "lit"; import {customElement, property} from "lit/decorators.js"; import {environment} from "../environments/environment"; import {OpenidService} from "../service/openid-service";
@customElement("si-ui-blueprint-webcomponent") export class SiUiBlueprintWebcomponent extends LitElement {
@property({type: String})
status: string = "success";
public render(): TemplateResult {
return html`Something to render `;
}
private login(): void {
}
private newListItem(text: string) {
return html`
something`;
}
}
lit version is: "lit": "2.2.1",
Im not able to reproduce locally or in the playground
Do note that you're importing
import {customElement, property} from "lit/decorators.js";
but using it with a capital:
@CustomElement("si-ui-blueprint-webcomponent")
@CustomElement -> git automatically capitalized it
in my code it's lowercase "c"
ok i will try to find out where the problem is and i will report here. If i remove "--litElement" flag it works...
exact environment : node: v16.14.2, npm: 8.5.0
@domoskanonos Have you found a solution for this? I'm having the same issue, but I'm trying for days to find the source since it randomly appeared without really changing or updating anything.
As soon as I find a minimal example without 300 lines of code, I'll post it here.
To add to this: The error already happens when running "npm install", not even while transpiling with run/build
I fixed this issue in the createClass.js by checking for classTemplate.members existence and initialize it with empty array if undefined
old:
if (!existingMember) {
if (hasIgnoreJSDoc(statement)) return;
if (isBindCall(statement)) return;
existingMember = {
kind: 'field',
name: expression?.left?.name?.getText(),
}
classTemplate.members.push(existingMember);
}
new:
if (!existingMember) {
if (hasIgnoreJSDoc(statement)) return;
if (isBindCall(statement)) return;
existingMember = {
kind: 'field',
name: expression?.left?.name?.getText(),
}
if(!classTemplate.members){
classTemplate.members = [];
}
classTemplate.members.push(existingMember);
}
I tried to push a fix branch to create a pullrequest, but I don't have the rights
I had this issue (independent of which node version I was running, i tried 14 and 16).
Version: "@custom-elements-manifest/analyzer": "^0.6.4"
I was able to fix by being verify specific about what code to include via --glob.
For a project im working on
This works:
cem analyze --litelement --globs packages/*/* --exclude packages/*/dist
This does not
cem analyze --litelement --exclude packages/*/dist
and this does not
cem analyze --litelement --globs packages/*/*
Obviously YMMV but changing this command got me up and running again. Im assuming there is some code in my project that is causing the issue and I should have been using globs all along
NPM command: custom-elements-manifest analyze --outdir public/ --litelement --dev
with node version 14.17.0 everything works fine, version 16.14.2 broken with error:
TypeError: Cannot read properties of undefined (reading 'push') at mapClassMember (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:242:27) at file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:211:35 at Array.forEach ()
at visitNode (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:211:12)
at visitNodes (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules\@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:29004:30)
at Object.forEachChild (C:\machineroom\git\ui-blueprint-webcomponent\blueprint-frontend\node_modules\@custom-elements-manifest\analyzer\node_modules\typescript\lib\typescript.js:29316:21)
at visitNode (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:216:8)
at getDefaultValuesFromConstructorVisitor (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js:200:3)
at analyzePhase (file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js:75:11)
at file:///C:/machineroom/git/ui-blueprint-webcomponent/blueprint-frontend/node_modules/@custom-elements-manifest/analyzer/src/create.js:104:23