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

Improvement: Update import map to repository module #14845

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

madsrasmussen
Copy link
Contributor

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

@@ -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")),
Copy link
Contributor

@bjarnef bjarnef Sep 25, 2023

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")
})

https://github.com/ServiceStack/ServiceStack/blob/3ca6daf7a2dd882437cd5cd863f22a0522eab8ec/ServiceStack/src/ServiceStack.Mvc/RazorPage.cs#L387-L408

It may also benefit developers using ES modules in frontend.

Copy link
Contributor Author

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 👍

Copy link
Contributor

@iOvergaard iOvergaard Sep 29, 2023

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)

@iOvergaard iOvergaard merged commit ded1cbb into v14/dev Oct 6, 2023
7 of 9 checks passed
@iOvergaard iOvergaard deleted the improvement/remap-repository-module branch October 6, 2023 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants