Does this work with TypeScipt too?
Cant find any documentation on it..
I don't believe so, no. But as long as you compile the TypeScript to JavaScript, then use the JavaScript file as the entry point for pkg, then it will work.
Just note that I was targeting my TypeScript to es2015, but pkg failed because (I think) it couldn't parse the import statement (either that or I was doing something wrong). I changed the TypeScript to target es5, and pkg was able to build the executable successfully.
@NikoMontana look here TypeScript & zeit/pkg.
I'm testing it right now, I'll post an update on this when I finish testing
@NikoMontana @reduckted in order to create a .exe with pkg you must do first:
tsc to compile to JS.pkg inside de dist folder created in step 1.That is working very well.
@wolfmaster8 this worked. But my problem is not solved because I got dependencies which are downloading additional stuff platform corresponding. So assuming I am on a mac and pkg it, it would only work on mac..
@wolfmaster8 this worked. But my problem is not solved because I got dependencies which are downloading additional stuff platform corresponding. So assuming I am on a mac and
pkgit, it would only work on mac..
docker ~~
@NikoMontana the best option is to use Docker as @zuohuadong said. You can try also with nexe if it helps. I'm using now nexe.
I haven't tried, but my guess is that you can control what process npm uses using the npm_config environment variables. node-gyp can control which OS by using the "target" option. Maybe check out how (electron-builder)[https://github.com/electron-userland/electron-builder/blob/6067accb36fc8a94da607403bef8132ef635fbcb/packages/app-builder-lib/src/util/yarn.ts#L33] handles installation. Of course, that would probably depend on what your dependencies use for detecting the os.
To get the node-gyp target for pkg:
npm view node dist-tagsnpm_config_target environment variable to that full semver version, i.e. targeting node10 you would set npm_config_target="10.15.3"@NikoMontana the best option is to use Docker as @zuohuadong said. You can try also with nexe if it helps. I'm using now nexe.
Thanks for this idea.
Note: this package installs 279 other packages and 1 of them has a "high" vulnerability (decompress). I'll pass until it is more mature.
Most helpful comment
I don't believe so, no. But as long as you compile the TypeScript to JavaScript, then use the JavaScript file as the entry point for
pkg, then it will work.Just note that I was targeting my TypeScript to es2015, but
pkgfailed because (I think) it couldn't parse theimportstatement (either that or I was doing something wrong). I changed the TypeScript to target es5, andpkgwas able to build the executable successfully.