bitfocus / companion-module-discord-api

MIT License
5 stars 2 forks source link

Module fails to load #4

Closed Julusian closed 2 years ago

Julusian commented 2 years ago

Describe the bug

It looks like the png64 folder is not being handled by typescript properly, resulting in the module being unimportable.

To Reproduce

julus@julus-thinkpad:~/Projects/companion-22$ node
Welcome to Node.js v14.19.2.
Type ".help" for more information.
> require('companion-module-discord-api')
Uncaught Error: Cannot find module './png64'
Require stack:
- /home/julus/Projects/companion-22/node_modules/companion-module-discord-api/dist/feedback.js
- /home/julus/Projects/companion-22/node_modules/companion-module-discord-api/dist/index.js
- <repl>

The same is also happening on my ubuntu-server installation of companion.

Expected behaviour A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

System (please complete the following information):

Additional context Add any other context about the problem here.

thedist commented 2 years ago

I've been trying to look in to it, but it builds perfectly fine for me so is a bit hard to debug. I may try just putting all the png64 stuff into a single file rather than a folder as that's all I can think of.

Julusian commented 2 years ago

Ooh interesting.. It works when doing it from module-local-dev, but not when a dependency of companion (inside of node_modules).. how strange

Julusian commented 2 years ago

It looks like in module-local-dev tsc is making sure all dependency files are compiled, even if they arent referenced in the tsconfig includes (src/png64/index.ts isnt covered by the include rule). But when in node_modules it is only compiling those in the tsconfig include.

I cant explain why it is doing this, and a quick google is not coming up with anything.. I think the easiest solution here would be to inline those files. Also to make the line be "include": ["src/**/*.ts"], in tsconfig.json so that it will definitely compile all ts files in subdirectories.

Another thing of note, is that you have "typescript": "^4.5.5" as your devDependency (yarn.lock says it is currently 4.6.2), but are doing npx typescript@^4.2.3 in the yarn build, which for me is being done wih 4.7.4. I would recommend making them both be ~4.6 to lock it to a specific minor version number, as typescript frequently have breaking changing in minor releases. What compiles today under 4.7 may not work under 4.8, and npx typescript@^4.2.3 will be using 4.8 once it is released.

thedist commented 2 years ago

This should now be fixed.