PXT packages

Packages are PXT’s dynamic/static library mechanism for extending a target, such as the pxt-micro:bit:

pxt-microbit

Here is an example of a simple package that extends the pxt-microbit target so that the micro:bit can drive a NeoPixel strip:

pxt-neopixel

To see how this package is surfaced, visit https://makecode.microbit.org/ and select the “Extensions” option from the gear menu. You will see the package “neopixel” listed in the available options. If you click on it, a new block category named “Neopixel” will be added to the editor.

In this scenario, PXT dynamically loads the neopixel packages directly from GitHub, compiles it and incorporates it into the web app. Packages also can be bundled with a web app (the analog of static linking). For dynamically loaded packages, targets can provide a white list of approved packages (see pxtarget.json).

Authoring packages

Editor extensions

Packages may provide an optional editor extension. An editor extension is an HTML page that gets loaded inside an iFrame by the editor. It allows to interact with the project or access serial data via messages. Package extensions are hosted on GitHub pages.