imp
v0.1.1

imp-ui - Imports

Everything imp gives you arrives through a bare specifier that imp resolves for you. In development it uses the import map imp start injects. In production it uses the bundle imp build produces. There is nothing to install and nothing to configure.

The library is split by subject, so an import line shows which part of imp a file uses:

SpecifierWhat it holdsPage
impcomponent, mount, init, env, flag, appMap, interval, delayComponents
imp/htmlel, html, and one factory per HTML tag (div, span, button, ...)Rendering
imp/stateinitState, useState, computedState
imp/routerrouter, area, redirect, wait, navigate, safeNext, beforeLeave, useRoute, url, screenRegionRouting
imp/themetheme, appliedTheme, applyTheme, colorSchemeOfTheming
imp/i18nt, lang, dir, missingMessages, defaultMessagesTranslations
imp/loglogger, createLogger, setLogLevel, logLevelLogging
imp/httpinitHttpClient, useHttpClient, createHttpClient, HttpErrorHTTP
imp/iconsluHouse, luUser, luStar, ... from the Lucide icon setStandard components
imp/service-workerstartDevMode, precacheBuild, for a service worker of your ownCLI
imp/analyticsonAnalytics, batch, zone, trackAnalytics
imp/analytics/alyalySink, a sink that sends the records to your imp-aly serversAnalytics
imp/stdThe standard component library, split by groupStandard components
imp/testtest, expect, spy, mockModule, and the hooksTesting
imp/previewmockModule, for a *.preview.js fileCLI
imp/fakefake, generated data for a mock file, a test or a previewCLI

A typical screen imports from the two or three specifiers it uses:

import { component } from 'imp'
import { button, div, h1 } from 'imp/html'
import { initState } from 'imp/state'

Why the library is split

  • The tag factories are most of the surface. One factory per HTML tag is nearly eighty names. They stay behind imp/html, so the framework itself stays small enough to remember.

  • A name can mean two things at two levels. button is a plain <button> from imp/html, and it is also the styled component from imp/std. The two never collide, because they arrive through different specifiers, and the import line shows which one a file uses. When a file wants both, give one an alias:

    import { button } from 'imp/html'
    import { button as styledButton } from 'imp/std'
  • The imports document a file. When you see imp/router and imp/state at the top of a module, you know what the module does before you read a single line.

When you get an import wrong

imp lint catches a name from the wrong specifier, and names the correct one:

error[imp/import-source]: 'div' is not exported by 'imp' - it comes from 'imp/html': import { div } from 'imp/html'

imp lint --fix moves the name to the correct import for you. An imp/... specifier outside the library fails, and the error lists the real specifiers. A spelling mistake never turns into a missing module you cannot explain.

Namespace imports

You can also import every subpath as a whole. This reads well for the tag factories, in a file that uses many of them:

import * as h from 'imp/html'

export const card = (title) => h.article(h.h2(title), h.p('...'))