Skip to content

JavaScript

The modules every site’s import map already carries, what a site’s own file may be called and which two names load on their own, and the keys of the site’s import map. Served over MCP as vizitka://docs/javascript, and by describe_vocabulary with topic=javascript.

What every customer’s site gets, and the whole of what a site’s import map starts from: Turbo, Stimulus, and the controllers a template can ask for.

site, @hotwired/turbo-rails, @hotwired/stimulus, @hotwired/stimulus-loading, vizitka/live, shared/application, shared/disclosure_controller, shared/disk_image_controller.

Lowercase segments of letters, digits and underscores, up to four, the shape controllers/gallery_controller and lib/money already have. No dot, no hyphen and no leading slash, so a name is never a URL and never a file extension, and stimulus-loading’s controllers/<name>_controller (hyphens become underscores) is always a name a file can have.

The pattern is \A[a-z0-9_]+(?:/[a-z0-9_]+){0,3}\z.

Refused as a first segment: vizitka, shared, site. First segments that are the platform’s: vizitka is reserved everywhere a site names something, and shared and site are modules every site’s map already carries (config/importmap/site.rb).

Taken: controllers/disclosure_controller, controllers/disk_image_controller. The controller names site.js registers for every site, which a site’s own file may not take: disclosure would be controllers/disclosure_controller.

The file imported on every page, when a site has published one.

Where a controller of the site’s own lives, the directory stimulus-loading reads. stimulus-loading’s own arithmetic: image-gallery is controllers/image_gallery_controller, admin--menu is controllers/admin/menu_controller.

Keys: imports, integrity. The two keys a document may have. scopes is the standard’s third, and it is refused: a scope remaps a name for one directory of modules, and a site has no directory of its own that a scope could mean. A document needs imports, an object from a name to an https:// address.