There are two ways that we can build the Alien Attack game environment: continuously and on demand.
On demand compilation is done by running
npm run build from inside the cdk folder each time you change a .ts (typescript) file. This is not very efficient, so we will opt for continuous compilation.
Continuous compilation, the recommended approach, means that the environment will automatically be compiled with every file change. This allows you to check for possible errors right away.
To set up continuous compilation, we recommend using two separate terminal windows for the duration of the workshop. Be sure to keep both terminals open until the workshop is complete. The first terminal will be used to issue commands. The second terminal will be used to monitor the progress of development and the corresponding compilation of your code.
At the bottom of the page in your Cloud9 IDE, click the (+) icon, and then New Terminal to add a second terminal to your Cloud9 environment.
Use the following command to navigate to your cdk folder (if you are not there yet)
npm run watch
This command kicks off continuous compilation of your Alien Attack environment. It may take a few seconds for you to receive results.
Confirm that the output contains 0 errors. If there are errors of the type TS6192 or TS6133, then you’re fine to proceed. These errors appear when certain classes are imported but not used, e.g. when part of your code is commented out. This will not break the code during runtime.
Once you’ve successfully kicked off compilation, you can proceed to the next page. A successful compilation will look something like the output below:
If you decide to not use this continuous compilation approach, remember to run npm run build each time you edit and save a file