# Developing third-party custom components
Weixin Mini Program Supports installing third party packages using npm from the base library version {% version ('2.2.1')}, and therefore supports the development and use of third party custom component packages.For more information about npm features, read the documentation .
# Get ready
To develop an open source custom component package for others to use, you first need to clarify how the others are going to use the package. Skip this document if you are just copying the Weixin Mini Program directory for direct use.What follows in this document is described in the context of npm management of custom packages.
Before developing, developers are required to have a basic knowledge of node.js and npm, and they need to be ready with developer tools that support npm functionality. Click here to download .
# Download the template
To make it easier for developers to quickly build a custom component package project that can be developed, debugged, and tested, an project template is officially available. There are three ways to download the template:
- Download the zip file directly from github and extract it.
- Just clone the repository on github.
- Use the official command-line tools to initialize your project, as described below.
The build in the project template is executed based on gulp + webpack, supporting commands for development, build, testing, and more. For more information, see the project template's README.md file.
# Command-line Tools
The official command tool is available to quickly initiate a project.Execute the following command to install the command line tool:
npm install -g @wechat-miniprogram/miniprogram-cli
Then create an empty directory as the project s root directory, and execute from this root
miniprogram init --type custom-component
After executing the command, you will find that many files have been generated in the root directory of the project. This is the complete project generated from the official project template .
More usage of the command line tool can be found in the README.md file on the github repository.
PS: The first time you use
miniprogram initThe initial project will go to GitHub to pull the template, so you need to ensure that the network is smooth.
# Test Tools
For unit tests for custom components, see documentation for unit tests .
# Examples of custom components
The following are officially available custom components that you can refer to and use:
# Custom component extension example
The following are officially available custom component extensions that you can refer to and use: