You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently need to import modules from JS snippets. This requires currently knowledge of the "final" (hash-appended) URL of the module. A similar problem occurs when using JS web workers, since those are loaded dynamically and not via a script-tag.
This is basically an addition to the current ongoing debate about having a "manifest" of all the files produced from trunk. I would like to propose a new feature that complements this.
Proposal
JS module importmaps allow you to assign almost arbitrary identifiers as aliases for modules, such that you can use these instead of full URLs. The idea would be to add a data-trunk attribute to these and let trunk replace the mapped URLs with the actual hashed output files. Taking the example from the MDN article, we would have something like
I personally haven't work with importmaps so far. But it sounds like a reasonable improvement and it looks like you gave some though to it. I am working towards a 0.19.x release, so now would be the right time. I would welcome a PR on this.
I currently need to import modules from JS snippets. This requires currently knowledge of the "final" (hash-appended) URL of the module. A similar problem occurs when using JS web workers, since those are loaded dynamically and not via a
script
-tag.This is basically an addition to the current ongoing debate about having a "manifest" of all the files produced from trunk. I would like to propose a new feature that complements this.
Proposal
JS module importmaps allow you to assign almost arbitrary identifiers as aliases for modules, such that you can use these instead of full URLs. The idea would be to add a
data-trunk
attribute to these and let trunk replace the mapped URLs with the actual hashed output files. Taking the example from the MDN article, we would have something likeThis would be processed by trunk to something like
Then, in both JS modules and JS snippets (which are modules as well), you can use the "well-known" module aliases to import:
Pros of this approach:
Cons / alternatives:
Is this generally something that the maintainers consider useful / desirable? I wouldn't mind working on a PR if yes.
The text was updated successfully, but these errors were encountered: