I'd like to be able to do this without webpack, gulp, etc, just "tsc [args] mycode.ts". Is that even possible?
In my package.json, I have a build command like this:
"build:mycode": "tsc --allowSyntheticDefaultImports --lib es2018 --lib dom -m amd -t es2018 --moduleResolution node --outFile ./mycode.js ./mycode.ts",
(The reason all of the above config is done with tsc command line arguments, instead of being set up in tsconfig.json, is that I'm generating a build script that's apart from my main project, which does use tsconfig.json, webpack, etc.)
I tried to use -m commonjs, but that's not allowed with --outFile, only amd or system.
The problem is that the code generated this way produces this error when invoked by node:
ReferenceError: define is not defined
I can't figure out how to define define. Is there an argument to the node command that will supply the necessary definition? Everything I've googled so far invokes extra tools I'd rather avoid if possible, or is targeted at a web browser rather than creating a command-line tool.
Note: Any solution which involves a <scr ipt> tag is NOT applicable.
deno bundledoes this, and you can supply your own TSConfig as an argumentwindow, etc.) is up to your TSConfig.<script>tags, and also bundled in such a way that nothing would execute automatically by including a bundle, it would just provide definitions that could be invoked. I want "node mycode.js" to immediately execute code, not just return me a function that I could call to execute that code.