smapiot / piral

🚀 Framework for next generation web apps using micro frontends. ⭐️ Star to support our work!
https://piral.io
MIT License
1.68k stars 125 forks source link

Support Configuration of Importmap Behavior in Pilets #625

Closed FlorianRappl closed 1 year ago

FlorianRappl commented 1 year ago

New Feature Proposal

Description

Right now the importmap of a pilet treats non-version specified dependencies as "exact", i.e.,

{
  "imports": {
    "@angular/core": ""
  }
}

will resolve to the currently used version of Angular. As an example, if node_modules/@angular/core/package.json has version 16.0.1 in there this is equivalent to

{
  "imports": {
    "@angular/core@16.0.1": ""
  }
}

However, under some circumstances we might prefer to have a different behavior such as using major-versions only:

{
  "imports": {
    "@angular/core@16.x": ""
  }
}

Background

While the exact behavior is a good default (after all we'll only the version if that's exactly the version you tested with) you might (e.g., for performance reasons) prefer to be a bit less strict - following semver rules.

Rewriting the importmap with explicit versions is a first way out, but suffers from maintainability and verbose. A better alternative is to change the default behavior - e.g., shifting from exact to match-major.

Discussion

Right now the idea is to set this default in the pilet.json via the importmapVersions key. What values should be possible here? all, match-major, any-patch, exact.