marten_importmap
Version, currently 0.1.23 versions
- 0.1.2latestMar 26, 2026
- 0.1.1not indexedMay 21, 2026
- 0.1.0not indexedMay 21, 2026
github.com/treagod/marten-importmap
No description declared in shard.yml.
Installation
# Add this to your shard.yml
dependencies:
marten_importmap:
github: treagod/marten-importmap
version: ~> 0.1.2Then run:
shards installshard.yml
- Crystal
>= 1.13.0- License
- MIT
- Author
- Marvin Ahlgrimm
Dependencies
Runtime Dependencies
Development Dependencies
README
MartenImportmap
Integration between Marten and the ImportMap shard.
Installation
Add the shard to your shard.yml:
dependencies:
marten_importmap:
github: treagod/marten-importmap
Run shards install, then add the two requires to your project:
# src/project.cr
require "marten"
require "marten_importmap"
# src/cli.cr (needed before running `marten importmap init`)
require "marten/cli"
require "marten_importmap/cli"
Then initialize the project:
marten importmap init
marten importmap init will:
- add
require "marten_importmap"tosrc/project.crif not present - add
require "marten_importmap/cli"tosrc/cli.crif the file exists and the require is missing - add
MartenImportmap::Apptoconfig.installed_apps - create
config/initializers/importmap.crfor user-managed importmap entries - create
config/initializers/importmap_pins.crfor CLI-managed pins - create
src/assets/application.jsif it does not exist
Template tag
Add {% importmap %} inside the <head> of your base template. It renders the <script type="importmap"> block and a <script type="module"> tag for the entrypoint:
<head>
<link rel="stylesheet" href="{% asset 'css/app.css' %}" />
{% importmap %}
</head>
Optional arguments:
{% importmap %} {# default namespace, entrypoint "application" #}
{% importmap "admin" %} {# custom namespace #}
{% importmap "admin" entrypoint="admin/app" %} {# custom namespace and entrypoint #}
Configuration
Marten.configure do |config|
# Default: false (download resolved modules into vendor_scripts_dir)
config.importmap.keep_cdn_urls = false
# Default: "src/assets/vendor/"
config.importmap.vendor_scripts_dir = "src/assets/vendor/"
config.importmap.draw do
pin "application", "application.js"
end
end
Use config/initializers/importmap.cr for manual pins, namespaces, and pin_all_from directives.
CLI
After initialization, pin a library using JSPM:
marten importmap pin react
marten importmap pin react --from jsdelivr
Supported providers: jspm.io (default), jsdelivr, unpkg, skypack, esm.sh.
The command downloads the resolved module to src/assets/vendor/ and updates config/initializers/importmap_pins.cr:
# AUTO-GENERATED by `marten importmap pin ...`
# DO NOT EDIT.
Marten.configure do |config|
config.importmap.draw do
pin "react", "vendor/react.js"
end
end
config/initializers/importmap_pins.cr is CLI-managed. config/initializers/importmap.cr remains user-managed.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.2- Tagged
- Mar 26, 2026
- Commit
c6c6cde8ab18- Crystal
>= 1.13.0- Indexed
- yes
Dependents
Repository
github.com/treagod/marten-importmap
Metadata
- Created
- Aug 18, 2026
- Updated
- Sep 26, 2026
- Synced
- Sep 26, 2026
- Versions
- 3