Description
The PolymerJS as a library along with satellites like Vaadin Elements is used in portal environments and meant to be reused across multiple apps. Unfortunately modern ES6 imports (ESM) build could not use libs from library root on server or from CDN.
Proposing to add support of CDN distribution of polymer-cli built modules.
One of possible ways: polymer.json
configuration parameter cdnRootUrl mapping for modules to URLs.
{ "builds": [
{
"name": "esm-unbundled",
"basePath": "https://myOrgCDN.io/my-component/esm-unbundled",
"cdnRootUrl":{
"@my-org/my-component":"https://myOrgCDN.io/my-component/esm-unbundled",
"@polymer":"https://somePolymerCDN.io/polymer-3/esm-unbundled",
"@vaadin":"https://someVaadinCDN.io/vaadin-14/esm-unbundled"
}
}
Which during the build would substitute references to modules from relative to build root path
import "../../node_modules/@polymer/iron-ajax/iron-ajax.js";
to CDN URL
import "https://somePolymerCDN.io/@polymer/iron-ajax@3.0.0/iron-ajax.js";
The build/esm-unbundled/node_modules/*
content would be changed to fit into CDN naming convention:
- module folder suffixed with module revision
- internal imports changed to match
cdnRootUrl
mapping
The project binaries would be copied to node_modules
with current module revision so they would be deploy-able to and consumed from CDN.
Related issues:
- Change url when doing build to point to cdn Change url when doing build to point to cdn #818
- Work with refereces to external url's (like CDN) Work with refereces to external url's (like CDN) #898