Gabriel Prates 8 Months Ago Hey Dave, really nice stuff! jsImportMapsEntry is, without a doubt, my favorite Client Extension at all! 😄 I just want to add one thing: you mentioned workspace in a Liferay perspective and, in fact, the Liferay Workspace will enable `@liferay/vacation-shared-code` as a dependency of your `customElement` (as a installed package) because of the way Node.js will resolve modules in a NPM/Yarn Workspace . So, I imagine your Liferay's root `package.json` looks like this: { "private": true, "workspaces": { "packages": [ "client-extensions/vacation-shared-code-js-import-map-entry", "client-extensions/vacation-test" ] } } Based on this configuration (Liferay Workspace also defining a NPM/Yarn Workspace), Node.js will be able to resolve the package name (`@liferay/vacation-shared-code`), as you said, because it was told to it where else it should look for packages. We can even create a NPM/Yarn Workspace outside a Liferay Workspace, and still make the modules/packages shareble among each other, but it is really nice to see how Liferay team cares about the ecosystem and we can use it built in! 👏 A few extra resources to go deeper: - https://yarnpkg.com/features/workspaces - https://docs.npmjs.com/cli/v7/using-npm/workspaces Please sign in to reply. Reply as... Cancel David H Nebinger Gabriel Prates 8 Months Ago - Edited Absolutely right Gabriel! The Liferay Workspace is not required to build this kind of JS Import Map support. I tend to recommend it though because the Liferay Workspace does know how to bundle up the various Client Extensions into the deployable zip artifacts in an easy and convenient way. And in this case, it also allows the custom element to use and reference the vacation-shared-code as a dependency without having to create or maintain the root package.json needed for the NPM/Yarn workspace. So while the Liferay Workspace isn't the only way to create and manage these guys, I do feel it makes it easier in some respects. Please sign in to reply. Reply as... Cancel
David H Nebinger Gabriel Prates 8 Months Ago - Edited Absolutely right Gabriel! The Liferay Workspace is not required to build this kind of JS Import Map support. I tend to recommend it though because the Liferay Workspace does know how to bundle up the various Client Extensions into the deployable zip artifacts in an easy and convenient way. And in this case, it also allows the custom element to use and reference the vacation-shared-code as a dependency without having to create or maintain the root package.json needed for the NPM/Yarn workspace. So while the Liferay Workspace isn't the only way to create and manage these guys, I do feel it makes it easier in some respects. Please sign in to reply. Reply as... Cancel
Eric D 4 Months Ago - Edited Hi Dave, We are using 5 angular 17 Custom Element for one of my client. It works great but I try to share angular/core like you have done for React. It seems not so easy, do you know if someone have done that ? Please sign in to reply. Reply as... Cancel David H Nebinger Eric D 4 Months Ago - Edited So the JS import maps and import handling is all stuff done in the browser, there's nothing Liferay- or CX-specific that is really involved in it. Angular already supplies the ES modules so you're basically ready to roll. The CX for the Import Map would just need to define the imports and the paths to the local ES modules. You can get details for this from ChatGPT (or your preferred AI) using a prompt like “How can I share Angular 17 core via an import map using ES modules from the fesm folder?” It will give you the non-Liferay aspects of what you'll need to do. The only Liferay aspects to worry about is how then to package into a CX... If you have trouble with it, post to the Liferay Community Slack (maybe in #portal-frontend) and I or someone else can help get you over the line... Please sign in to reply. Reply as... Cancel
David H Nebinger Eric D 4 Months Ago - Edited So the JS import maps and import handling is all stuff done in the browser, there's nothing Liferay- or CX-specific that is really involved in it. Angular already supplies the ES modules so you're basically ready to roll. The CX for the Import Map would just need to define the imports and the paths to the local ES modules. You can get details for this from ChatGPT (or your preferred AI) using a prompt like “How can I share Angular 17 core via an import map using ES modules from the fesm folder?” It will give you the non-Liferay aspects of what you'll need to do. The only Liferay aspects to worry about is how then to package into a CX... If you have trouble with it, post to the Liferay Community Slack (maybe in #portal-frontend) and I or someone else can help get you over the line... Please sign in to reply. Reply as... Cancel