Skip to content

CDN support as build target #3486

Open
Open
@sashafirsov

Description

@sashafirsov

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions