Skip to content
Nishant Mittal
Resume

Google Summer of Code 2020 with Oppia

GSoC, Webpack, TypeScript, Oppia4 min read

Oppia

Oppia is a platform that enables anyone to learn and teach anything they want in an effective and enjoyable way.

About the project

Oppia was initially written in AngularJs (1.X) but as Angular was released, it was decided to migrate the application to Angular. Also, as Angular uses TypeScript instead of JavaScript all the content of JavaScript files was copied as it is. But as the main feature of TypeScript is static typing. A part of my project was to ensure type safety in the typescript files with writing relevant unit tests and adding CI checks to ensure that this convention is followed in the future.

The other part of my project was related to webpack. In particular the goal was to make the webpack build faster and moving some libraries currently imported using script imports to webpack.

Milestone 1

In particular the work done in milestone 1 was

  • Write type definitions for the third party libraries that didn’t have those.
  • Coming up with a convention for declaring the types.
  • Declare types for about 50% of the TypeScript files.

This also involved writing lint checks to ensure that the third party libs have type definitions and when a contributor upgrades the version of a library, they would also have to update the types if relevant.

The convention that was decided for naming i.e. camelCase and snake_case was the following two things

  • HTTP requests should only be made only with the files suffixed with backend-api-service.ts.
  • All the HTTP backend api services should return domain objects instead of a backend dict.

So, in this milestone I covered the first part and also writing a lint check for ensuring that this convention is not broken.

PRs involved

Milestone 2

The work done in milestone 2 was

  • Add types for other TypeScript files.
  • Http backend api services should return domain objects instead of a backend dict.
  • Write documentation on various TypeScript conventions used.

Along with these goals we also realised that the use of ts-ignore shoould also be restricted. So, I also added a lint check that restricted the use of ts-ignore and using ts-expect-error at relevant places.

Also, as the types would be in place I added the checks ensuring that "any" type is not used anymore.

PRs involved

Documentation

I wrote a guide on defining types and published it in Oppia wiki. You can read it here.

Milestone 3

The work done in this milestone is

  • Integrate dependencies into webpack.
  • Increase the webpack compilation speed.
  • Documentation on webpack config.
  • Enable more TypeScript eslint rules.
  • Setup strict type checks.

The main changes in webpack config for getting more speed were introducing cache-loader and use faster devtools in webpack. Also, I introduced a flag in the scripts so that developers would be still able to build using source-maps in webpack. The compilation time in production was reduced from around 600s to around 300s in Travis CI (production build). Also the compilation time for development build is less than 30s. Due to cache-loader consecutive builds in both production and development evironment now take around 20s only.

Also we thought that it would be nice to enable "strict" type checks in the TypeScript config. But the problem was the huge number of errors due to that. So, we decided to implement this rule gradually file by file. I set up that strict config and we plan to make this a "good first issue".

PRs involved

Documentation

There was documentation on webpack already. I extended it to explain how our webpack config works. You can read it here.

Issues / Bugs found

I was also a part of release testing team in Oppia. Here are the various issues found by me while release testing and developing Oppia.

Related Links

For those more curious about this project, do checkout the following links.

Summary

This was an awesome learning experience working with Oppia this summer. Special thanks to Vojtěch Jelínek who was my mentor for helping me whenever I faced any problem in completing this project. I would also like to thank Oppia for giving me this opportunity.

I would also like to acknowledge the help from other members of the community, who were always available whenever needed, just a small chat away. I strongly intend to continue contributing to Oppia.

Also, thanks to Google for this amazing program.