DevMentor
DevMentor2w ago

deno dnt not including a TS file when building a NPM package

Hello I have 2 release problems I need help with. I have a project with a file located under "lib/utils/" folder that is called "logger-worker.ts". This file is loaded from a call in another source file when creating a worker thread, like:
this.worker = new Worker(path.join(process.cwd(), 'lib/utils', 'logger-worker.ts'), {
this.worker = new Worker(path.join(process.cwd(), 'lib/utils', 'logger-worker.ts'), {
However dnt is not builing "logger-worker.ts", because I assume it doesn't get imported, so is being ignored. I don't see it in the NPM output folder. So how can I get dnt to build this typescript file when building a NPM package? This all works fine when I am developing and running my project from deno. The other prepliexity I have (2nd problem), when "logger-worker.ts" gets built by dnt, since my code is loading, "logger-workers.ts" and dnt will transpile it to "logger-worker.js", the code will break when run from the NPM import library, since it looking for a ".ts" file for the worker thread. So what can I do, so my typescript project will work from deno under development and from another project using the NPM package library with Node.js?
1 Reply
DevMentor
DevMentorOP2w ago
The work around I found was to write the worker thread code in pure JavaScript and then have the file copied over as a post build step in the npm build script. However I would be interested to know if there was other valid solution, thank you. If there a way to tell dnt to copy file(s) itself to the various build folder without an explict copy post build step?

Did you find this page helpful?