smogon / Porygon-Z

The Bot for the Official Smogon Discord (WIP)
https://discord.gg/smogon
MIT License
13 stars 6 forks source link

Move typescript & type decl to devDeps #12

Closed thejetou closed 3 years ago

thejetou commented 4 years ago

dependencies should contain modules used in runtime; devDependencies should contain modules used for developing the application.

PostgresSQL falls under the former, while transpilers (such as tsc) and test frameworks (such as Jest) fall under the latter.

This can be seen in the official npm docs: https://docs.npmjs.com/files/package.json#dependencies where it says:

"Please do not put test harnesses or transpilers in your dependencies object."

In the devDependencies of the same docs it states:

"If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.

HoeenCoder commented 4 years ago

You need typescript to build the bot in a production environment though? Unless I'm misunderstanding something here, you wouldn't be able to clone and use this bot without installing typescript (and the other required types since it won't build without them).

thejetou commented 4 years ago

You need typescript to build the bot in a production environment though? Unless I'm misunderstanding something here, you wouldn't be able to clone and use this bot without installing typescript (and the other required types since it won't build without them).

dependencies should only contain modules what are required to run the bot, which is what "production" means in this case, rather than the production box.

HoeenCoder commented 4 years ago

dependencies should only contain modules what are required to run the bot, which is what "production" means in this case, rather than the production box.

The problem is still that the bot won't currently start if --production is passed to npm install since typescript isn't installed. (Freshly clone copy of the repo w/ your package.json changes) image

Since the startup file (bot) calls tsc from node_modules/

#!/usr/bin/env node
console.log('Building...');
require('child_process').execSync(__dirname + '/node_modules/.bin/tsc', {stdio: 'inherit', cwd: __dirname});
console.log('Starting...');
require('module')._load('./dist/app.js', module, true);
thejetou commented 4 years ago

Yes, you shouldn't be adding the --production flag if you plan to build the bot yourself, which is why I removed it from README.md.