Simple npm scripts
and common devDependencies
to help build a Node TypeScript app.
Inspired by Create React App's react-scripts package 👏
- TypeScript
- Jest
- Eslint
- Prettier
- Along with other TypeScript supporting dependencies. See the package.json file for the full list.
Compiles your TypeScript. Expects a tsconfig.json
file with an include
property and a compilerOptions.outDir
property.
Deletes your compiled TypeScript. Expects a tsconfig.json
file with a compilerOptions.outDir
property.
Runs prettier
against all files. Uses your .gitignore
file if it exists to ignore. Semi-customizable with args.
Runs eslint
against all files. Uses your .gitignore
file if it exists to ignore. Semi-customizable with args.
Cleans, builds, and starts your Node project with debugging enabled. Targets the main
property in your package.json
first and falls back to the outDir
property second. Semi-customizable with args.
Essentially the same as start
except your project will re-build/start when changes are seen in your outDir
. Semi-customizable with args.
At a minimum the properties below are required. The values can be customized.
{
"compilerOptions": {
"outDir": "./build"
},
"include": ["./src"]
}
At least ignore the folders below. NOTE: If you customized the outDir
in your tsconfig.json
, update the build
line here to match.
build
coverage
node_modules
An eslint config is required. Below is the simplest setup.
module.exports = {
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
};
The config below is required.
module.exports = {
'.ts, .js': {
style: 'module',
parser: 'typescript',
},
};
At a minimum the config below is required. NOTE: If you customized the outDir
in your tsconfig.json
, update '<rootDir>/build/'
to match.
module.exports = {
preset: 'ts-jest',
testPathIgnorePatterns: ['<rootDir>/build/', '<rootDir>/node_modules/'],
};
It's recommended you setup a Prettier configuration file.
Using nvm
along with an .nvmrc
file to automatically switch to the appropriate version of Node can be extremely helpful.
If you're using VS Code, a project-level settings file may be helpful to customize your experience.