denoland / deno_emit

Transpile and bundle JavaScript and TypeScript under Deno and Deno Deploy
https://jsr.io/@deno/emit
MIT License
223 stars 23 forks source link

Protecting deno code when deploying to a Raspberry Pi. #185

Open elwoodhouse opened 4 months ago

elwoodhouse commented 4 months ago

Apologies if this is not the right forum to ask this question but after researching for a while, deno_emit seems to be the tool I need to achieve my goal (though I could be wrong).

I'm working on a smart home style product that a customer buys which includes a Raspberry Pi. I've made a Deno script that takes requests from a phone app and adjusts the smart home device. Initially I thought that using Deno compile would hide my source code, but opening up the Deno compile output in a text pad, my source code is easily readable, so I need a way to at least minify my code before deploying it to the Raspberry Pi.

I did read through the issues about minification and know it's not the goal of Deno to have a fully fledged bundler, so I gave esbuild a go but I don't think my use case of minifying deno code to then run with either a Deno exe or Deno run is supported. I was getting 'dynamic require not supported' errors and I couldn't see any other esbuild settings that could resolve that issue.

I've tried to bundle with deno emit and I'm unable to bundle due to node: specifiers not being supported yet, but say that is fixed and I am able to bundle, if I use the deno emit bundle options to minify, would my code be (somewhat) obfuscated and able to run with Deno or am I better off using different tools to achieve my goal?

Thanks for any guidance, Leon.