tomayac / joy-con-webhid

Use the Nintendo Switch Joy-Cons via the WebHID API
https://tomayac.github.io/joy-con-webhid/demo/
Apache License 2.0
139 stars 19 forks source link

Building with vite fails #20

Closed danjenkins closed 1 year ago

danjenkins commented 1 year ago

I've added this into a vite react project, importing as instructed in the README with import * as JoyCon from 'joy-con-webhid'; and I'm getting this error...

Any ideas?

✘ [ERROR] Could not resolve "./connectRingCon.js"

    node_modules/joy-con-webhid/dist/joycon.js:1:66:
      1 │ ..."./parse.js";import{connectRingCon}from"./connectRingCon.js";const concatTypedArrays=(a,b)=>{const ...
        ╵                                           ~~~~~~~~~~~~~~~~~~~~~

14:26:53 [vite] error while updating dependencies:
Error: Build failed with 1 error:
node_modules/joy-con-webhid/dist/joycon.js:1:66: ERROR: Could not resolve "./connectRingCon.js"
    at failureErrorWithLog (<path>/node_modules/esbuild/lib/main.js:1649:15)
    at <path>/node_modules/esbuild/lib/main.js:1058:25
    at <path>/node_modules/esbuild/lib/main.js:1525:9
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
danjenkins commented 1 year ago

Ah I think I worked it out.... the file is missing.

Might be good to remove the demo from the npm package too :)

Screenshot 2023-08-15 at 14 32 25
danjenkins commented 1 year ago

I'll make a PR when I get a moment...

    "build:connectRingCon": "npx terser ./src/connectRingCon.js --toplevel --comments /@license/ --ecma=8 -o ./dist/connectRingCon.js",
    "build": "npm run clean && npm run build:index && npm run build:joycon && npm run build:parse && npm run build:madgwick && npm run build:connectRingCon",

Add these to the package.json file

tomayac commented 1 year ago

Thanks for investigating! Please do open a PR, greatly appreciate the help!