-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improvement: Update import map to repository module #14845
Conversation
@@ -91,6 +90,7 @@ | |||
@Html.Raw(ImportMapValue("@umbraco-cms/backoffice/property-editor", backofficeAssetsPath + "/packages/core/property-editor/index.js")), | |||
@Html.Raw(ImportMapValue("@umbraco-cms/backoffice/property-action", backofficeAssetsPath + "/packages/core/property-action/index.js")), | |||
@Html.Raw(ImportMapValue("@umbraco-cms/backoffice/culture", backofficeAssetsPath + "/packages/core/culture/index.js")), | |||
@Html.Raw(ImportMapValue("@umbraco-cms/backoffice/repository", backofficeAssetsPath + "/packages/core/repository/index.js")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@madsrasmussen @bergmania I wonder if Umbraco should have a Html extension method to render this - or part of Smidge maybe? And the local ImportMapValue()
can be removed.
While searching around, I found that ServiceStack has StaticImportMap
and ImportMap
:
https://docs.servicestack.net/javascript-add-servicestack-reference#import-maps
https://servicestack.net/posts/javascript
@Html.StaticImportMap(new() {
["vue"] = "/lib/mjs/vue.mjs",
["@servicestack/client"] = "/lib/mjs/servicestack-client.mjs",
["@servicestack/vue"] = "/lib/mjs/servicestack-vue.mjs",
})
@Html.ImportMap(new()
{
["vue"] = ("/lib/mjs/vue.mjs", "/lib/mjs/vue.min.mjs"),
["@servicestack/client"] = ("/lib/mjs/servicestack-client.mjs", "/lib/mjs/servicestack-client.min.mjs"),
["@servicestack/vue"] = ("/lib/mjs/servicestack-vue.mjs", "/lib/mjs/servicestack-vue.min.mjs")
})
It may also benefit developers using ES modules in frontend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really want to make it possible to add a "modules" area to the Umbraco-package.json file. In that case, it is possible for any package to expose modules to the browser and any other package will be able to use that functionality. It could be Umbraco Commerce exposing a repository as part of their package. All the core packages will be able to use the same API - the same possibilities for package developers as the core.
This will also mean that we can remove all these hardcoded entries in the razor files. How we will end up reading the Umbraco-package.json files and rendering in the template we haven't decided yet. I will leave it to the .Net experts how we best get it into the razor template. An HTML extension sounds like a good idea 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bjarnef, good suggestion. Feel free to contribute with such an extension if you wish (in a new PR). I think we can put it somewhere in Umbraco.Web.Common perhaps.
Extra challenge if you are up for it: Considering that you can only have one importmap defined on the page, how would developers extend the map to append their own files?
(As Mads said, we can then use that functionality later on for some automatic parsing of manifest files to lift out global exports)
This PR updates the import map because the module files have been moved in the frontend project.
Merge together with: umbraco/Umbraco.CMS.Backoffice#892