The MakeHaus JS Development Environment
This documentation assumes that you are at least fundamentally familiar with the following tools and that they are installed on your system, if applicable:
- Bash / command prompt
Any commands below must be run from the project’s working directory unless otherwise specified.
For all npm commands, depending on local permissions and your operating system, you may have to execute with elevated privileges (sudo npm ...)
- node.js version 12
- Typescript 3.6.x
- Rollup 1.31.x
Initial Setup For Typescript Based Projects
Typescript files (
dist/ folder is the designated build folder and should not be checked into the cloud repository.
Although Typescript has been included as a development dependency in all typescript based projects, it is highly advised to install typescript at a global level on your development machine. Read the instructions here on how to do this.
commonjs” and “
es6”. These module formats can be toggled in the tsconfig.json file in the “module” section. Due to several reasons outside the scope of this document, please ensure the following:
- During development, the module format to be used must be “
- Before making a production deployment, the module format to be used must be “
Once you’ve ensured that the module format specified is
commonjs, execute the following command:
Typical Development Workflow For Typescript Projects
- Now, you no longer need to keep calling the typescript compiler after every change you make.
- Prettier is a code formatting plugin. makehaus-js uses the prettier.config.js to specify code formatting rules. It is highly recommended to install the Prettier extension by Esben Petersen to leverage the prettier config file included in the repository.
- Breakpoint debugging is possible by adding breakpoints to your typescript files directly.
Deployment For Typescript Projects
Rollup is a popular module bundler for node js packages and all typescript packages described here use rollup for their primary building needs. Although the rollup command has been used by all the build related scripts, it is highly recommended to install rollup globally by executing:
npm install -g rollup
Making A Standalone Build
To make a standalone build, run the following command:
npm run build
Rollup will do all the bundling and packaging in this step.
Publishing A New Version
Before publishing a new version:
- Ensure that the “
module” section of the
tsconfig.jsonfile has been set to “
es6”. If not,
rollupwill complain about the same.
- Delete the
dist/folder to have a clean workspace.
- Update the package version in
npmwill complain about an already existing version in its package repository.
This will prompt you to enter credentials for the npm account you wish to publish to. Once you’ve logged in, execute:
This will create a new standalone build and deploy the bundled npm package to the npm registry under your account.