Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Importmaps #279

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

henrikbjorn
Copy link

Recently the preload option was merged. But it comes with a huge penalty for a mental model. It is required for each dependency to set the preload for entrypoints. Depending on the number of items it can be hard to follow.

Instead I believe this complexity can be solved with allowing multiple importmaps. But by default just work with a single one like today.

This removes the mental headache since a the dependencies in config/importmaps/admin.rb can be seen as a group. Without reading each preload option.

This also allows to silo each importmap and reduce different dependencies to interfere with each other (e.g admin vs application).

If needed multiple importmaps can be defined in the `config/importmaps`
directory.

`bin/importmap` have a new option to work with named importmaps
`bin/importmap -i admin pin "some-dependency"`

The default is still `config/importmap.rb` so no change for exisiting users
that does not need multiple importmaps or complexity.
@henrikbjorn
Copy link
Author

@dhh would you consider this implementation, since it won't change anything regarding the current usage?

@henrikbjorn
Copy link
Author

This could also make 3rd party gems such as ActiveAdmin make it easier to work with their importmaps. As they can create a config/importmaps/active_admin.rb as part of the install and then allow developers to work with it through the CLI bin/importmap -i active_admin pin json_view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant