AdonisJS package development

AdonisJS package development

1hr 5mins
10 lessons
Start course

Packages provide a way to add functionality on top of AdonisJS and easily reuse them across multiple projects. In this course, we'll learn how to create an AdonisJS package and publish it to npm. By the end of this course, we'll have a production-ready package that anyone can install and use in their AdonisJS projects. Also, we'll have an AdonisJS package development starter boilerplate that you can use to create your AdonisJS packages.

Comfirm password

adonis-mrm is a preset of tasks for mrm which is a command line tool for scaffolding new projects and keeping their configurations in sync. We’ll be using it to scaffold the package.

Now, let's start building the package. We'll copy over the package implementation from the tutorial and register it with the AdonisJS IoC container.

In the lesson, we’ll be covering how to make the package configurable. That is, using node ace configure.

5m 47s

Before we start using the package in an AdonisJS project, let’s add types for the package so it plays nicely with TypeScript.

What you'll learn

  • How to create a TypeScript ambient module
  • How to add types to types to AdonisJS packages

Now, let's test what we have so far. Instead of having to first publish the package to npm, we will be using an npm package called Yalc, which allows us to test or use npm packages locally.

What you'll learn

  • How to use Yalc to publish and use install packages locally.

There are times we might want our package to make use of user-defined configurations. You might have seen that in most Adonis packages. In this lesson, we will cover how to do that.

What you'll learn

  • How to use template files in AdonisJS packages

In the last lesson, we saw how to work with template files using the automatic method. In this lesson, we are going to cover how to do the same thing and more using the manual method.

What you'll learn

  • How to use instructions.ts to manually create template files
  • How to accept users' input when configuring AdonisJS packages
  • How to use user-provided values in template files

There are times we might want to pass additional instructions or information after users might have installed and configured our package. We can achieve that using the file and in this lesson, we’ll cover how to do just that.

What you'll learn

  • How to display post-configuration instructions in AdonisJS packages

The package is now feature complete. What’s left is making it available to the world by publishing it to npm.

What you'll learn

  • How to publish AdonisJS packages to npm

To wrap up this course, I have put together a package development skeleton based off of this course for quickly scaffolding and building AdonisJS packages.

Chimezie Enyinnaya

Hi, I'm Chimezie Enyinnaya, your teacher.

I’m a self-taught software developer based in Lagos, Nigeria, with over 8 years of experience. In the last couple of years, I've been doing more teaching because I enjoy sharing my knowledge so that others can benefit from it. Come along as I teach you all I know about AdonisJS, Node.js, and JavaScript at large!