shannonhochkins / ha-component-kit

A Home Assistant React component library to generate dashboards with ease, This utilizises a massive list of Components / cards to use out of the box, a large range of hooks to build your own custom functionality, and a hell of a lot more! It's using web sockets to retrieve information from your home assistant instance so there's 0 latency!
https://shannonhochkins.github.io/ha-component-kit/
592 stars 30 forks source link

Getting a lot of errors when following the contribution documentation #89

Closed yann510 closed 11 months ago

yann510 commented 11 months ago

Cloning a fresh repo from master yields the following errors following the steps provided here: git@github.com:shannonhochkins/ha-component-kit.git

Exact repro steps:

  1. Clone repository
  2. npm install
  3. npm start
  4. Notice the following errors:
    [vite] Internal server error: Failed to resolve entry for package "@hakit/core". The package may have incorrect main/module/exports specified in its package.json.
    Plugin: vite:import-analysis
    File: /home/yann510/github/test/ha-component-kit/packages/components/src/Shared/ColorPicker/index.tsx
      at packageEntryFailure (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:28691:11)
      at resolvePackageEntry (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:28688:5)
      at tryNodeResolve (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:28419:20)
      at Context.resolveId (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:28180:28)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async Object.resolveId (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:44207:32)
      at async TransformContext.resolve (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:43923:23)
      at async normalizeUrl (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:41793:34)
      at async file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:41945:47
      at async Promise.all (index 7)
      at async TransformContext.transform (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:41870:13)
      at async Object.transform (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:44283:30)
      at async loadAndTransform (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:54950:29)
      at async viteTransformMiddleware (file:///home/yann510/github/test/ha-component-kit/node_modules/vite/dist/node/chunks/dep-df561101.js:64345:32)
shannonhochkins commented 11 months ago

I've just updated the contributing docs - sorry mate, i missed a vital step.

Because of the complexities with @hakit/core, storybook uses the distributable files from @hakit/core, so to kick off storybook, you must have a built version of @hakit/core

npm run build:core

Then you should be able to run npm start and load up the storybook instance.

I haven't quite solved this problem yet, and do be honest it really shouldn't be that difficult to fix, i simply haven't gotten around to it yet!

If you're working on a new feature with @hakit/core, what i normally do is cd into the core directory, and run npm run watch:build, then in a separate terminal, i run npm start and then you can work in tandom.

Also, storybook has a complete replica of the authentication and websocket flow, if you want to test against your home assistant instance there's a few solutions

  1. replace @hass-connect-fake with @hakit/core in the storybook stories
  2. Follow the steps here: https://github.com/shannonhochkins/ha-component-kit/blob/master/CONTRIBUTING.md#prep-for-local-development-with-a-test-dashboard

Hope this helps!

yann510 commented 11 months ago

I have been using NX for the past few years to solve these types of problems: https://github.com/nrwl/nx You should take a look at it :)

If it's something that interests you and would be beneficial for the project, I will help get you to get it up and running.

When I'm trying to build from a fresh master, I'm getting the following error now:

> @hakit/core@2.3.0 build:sync-script-cli
> tsup

CLI Building entry: scripts/sync-user-types/cli.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v7.2.0
CLI Using tsup config: /home/yann510/github/ha-component-kit/packages/core/package.json
CLI Target: es5
CLI Cleaning output folder
ESM Build start
Error: Bindings not found.
    at Compiler.<anonymous> (/home/yann510/github/ha-component-kit/node_modules/@swc/core/index.js:225:19)
    at Generator.next (<anonymous>)
    at /home/yann510/github/ha-component-kit/node_modules/@swc/core/index.js:34:71
    at new Promise (<anonymous>)
    at __awaiter (/home/yann510/github/ha-component-kit/node_modules/@swc/core/index.js:30:12)
    at Compiler.transform (/home/yann510/github/ha-component-kit/node_modules/@swc/core/index.js:202:16)
    at Object.transform (/home/yann510/github/ha-component-kit/node_modules/@swc/core/index.js:344:21)
    at Object.renderChunk (/home/yann510/github/ha-component-kit/node_modules/tsup/dist/index.js:2008:32)
    at /home/yann510/github/ha-component-kit/node_modules/tsup/dist/index.js:1912:53
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
shannonhochkins commented 11 months ago

I'll take a look at it tomorrow!

Can I ask what version of node / npm you're using?

After you first reported, I did checkout a clean repository and it did run through fine, so this may be environment specific

shannonhochkins commented 11 months ago

Also, what operating system?

shannonhochkins commented 11 months ago

Have you tried this solution? https://github.com/vitejs/vite-plugin-react-swc/issues/74

Hopefully, it's just as simply as removing the lock file then running npm install again

yann510 commented 11 months ago

Awesome, running npm i -D @swc/cli @swc/core fixed it for me, I'll create a PR.

shannonhochkins commented 11 months ago

Awesome, running npm i -D @swc/cli @swc/core fixed it for me, I'll create a PR.

Interesting!

What OS are you using? Obviously it works for me without installing these packages, just curious to know the differences between our setups, would you also mind letting me know your node / npm version?

yann510 commented 11 months ago

I'm running PopOS 22 (linux) with node 18 and npm 9