Sha256: 7796430c6a502d3969a405d910de004ed31c2ca80548d801eff1826edfdee1a2
Contents?: true
Size: 989 Bytes
Versions: 16
Compression:
Stored size: 989 Bytes
Contents
// FIXME: es-module-shim won't shim the dynamic import without this explicit import import "@hotwired/stimulus" export function registerControllersFrom(under, application) { const paths = Object.keys(parseImportmapJson()) .filter(path => path.match(new RegExp(`^${under}/.*_controller$`))) paths.forEach(path => registerControllerFromPath(path, under, application)) } export function parseImportmapJson() { return JSON.parse(document.querySelector("script[type=importmap]").text).imports } function registerControllerFromPath(path, under, application) { const name = path .replace(new RegExp(`^${under}/`), "") .replace("_controller", "") .replace(/\//g, "--") .replace(/_/g, "-") import(path) .then(module => application.register(name, module.default)) .catch(error => console.error(`Failed to register controller: ${name} (${path})`, error)) } console.warn("stimulus-importmap-autoload.js has been deprecated in favor of stimulus-loading.js")
Version data entries
16 entries across 16 versions & 3 rubygems