API #6
chrisdmacrae
started this conversation in
Ideas
API
#6
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The problem
Importmaps make the API gross, unfortunately.
We need to resolve controllers from a folder inside
app/components
, such asapp/components/hot_components
OR manually resolve each component controller in an importmap manifest js file.With jsbundling this is not an issue because we generate a manifest file that does relative imports.
This is because importmaps do conventional magic with the Rails asset pipeline to resolve a custom module identifier to a compiled asset, and the conventional magic is based on conventional magic of the Rails asset pipeline.
E.g, given the following Rails app structure:
config/importmap.rb
This means that given a root folder in
app
, likeapp/components
you can only have root JS assets inpublic/assets
. Such asapp/components/example_controller.js
resolving to/public/assets/example_controller.js
.There is no way to configure this differently.
Given an asset in the root of
public/assets
, it cannot be namespaces inimportmap
. Animportmap
namespace must be equivalent to the folder for no fucking reason other than bad API design.E.g.,
The following does not work:
Because
app/components
does not output topublic/assets/components
.The Scope
Decide what the API should be to resolve the problem above.
Some options:
components/hot_components
namespaceAnd
app/javascripts/controllers/components.js
:Beta Was this translation helpful? Give feedback.
All reactions