dsheiko / nw-autoupdater

⛔️ [DEPRECATED] Library provides low-level API to control NW.js app auto-updates
MIT License
75 stars 36 forks source link

Remove dependencies, compile into one file #17

Closed Arti3DPlayer closed 7 years ago

Arti3DPlayer commented 7 years ago

In my project i use nwjc to protect my source code. I uglify all my js files to one and then use

nwjc app/all.min.js app/app.bin

But after i installed your library I get about new 30 folders with a lot of dependencies .... Is this possible somehow to include in your project .min.js version, that doesn't need any dependencies ?

I tried, but they are so deep, that i can't make it work after minimize file

Thanks

dsheiko commented 7 years ago

So compiled the sources, that's fine. How do you dunle the app? If you use nw-builder, then your resulting package is an executable, which gets replaced with new one during the update. If it's just an archive (zip, gz) you can go with custom swap https://github.com/dsheiko/nw-autoupdater#writing-custom-swap-script - make it simply replace your *.bin file.

You can examine the demos included in the package, When you run on a client npm run package it creates the app package on the server. During updates client downloads the archive, unpacks temporarily, and run swap in a detached process to replace old app folder with newly downloaded and unpacked one

Arti3DPlayer commented 7 years ago

I do not know is this the right way to protect source. But to not lose startup speed, I configured nw-builder to use next sources:

src: [
            'app/**',
            '!app/**/*.js',
            'icons/**',
            'package.json',
            'node_modules/angular.js/angular.js.min.js',
        ]

So i compiled my .js files to bin and exclude them, to protect. And external libraries like yours, just include. So what i want is to do like:

'node_modules/nw-autoupdater/nw-autoupdater.min.js',. Now this doesn't work, because module has a lot of dependencies

dsheiko commented 7 years ago

You are as they themselves say you lose about 30% of performance. Besides, it's easy to decompile. I believe with JAvaScript there is no alternative to obfuscation. I personally rely on https://jscrambler.com for production code

Arti3DPlayer commented 7 years ago

@dsheiko no, they fixed issue with loose performance in 0.22+. Now it works perfectly)

https://nwjs.io/blog/js-src-protect-perf/

Arti3DPlayer commented 7 years ago

So is this possible to get rid of dependencies and use your library as one file ?

dsheiko commented 7 years ago

I assume you can bundle it together with all the dependencies by using Webpack in a single file, but why?!

Arti3DPlayer commented 7 years ago

@dsheiko Thanks, i didn't know about webpack:)