Namespaced Imports

Any import where the beginning portion (up to the first slash) of the URL does not contain a . is considered a namespaced import.

A namespaced import means that the IMPORT_SERVER (which defaults to https://import.pw) is prepended to the import URL. For example, these two import invocations are identical:

  • import assert
  • import https://import.pw/assert

Example

Let's take a look at importing this tootallnate/hello "Hello World" import from GitHub:

#!/usr/bin/env import

import tootallnate/hello

hello
# Hello, from @TooTallNate!
Run this code

The import.pw server

The default IMPORT_SERVER is https://import.pw, which serves GitHub repositories that are "import-compatible" according to its conventions:

  • The main import syntax is import <org>/<repo>
  • The entry point of the import is the file with the name of the repo with a .sh suffix
  • If there is no / in the import path, then the default org (importpw) is applied
  • Specific tags may be referenced by appending an @<version> to the end

Top-level imports

The importpw GitHub organization houses the top-level namespace imports. A top-level import happens when there is no / in the import path.

For example, the assert module includes functions that write simple unit testing scripts:

#!/usr/bin/env import

import assert@2.1.3

assert 1 = 2
# assertion failed: 1 = 2
Run this code

Here are some useful top-level imports:

See the importpw org on GitHub for the complete listing of repositories.

Community imports

Here are some GitHub repositories that are known to be compatible with import:

(Send a pull request if you would like to have an import listed here)