smapiot / piral

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

Share dependencies defined as npm aliases #593

Closed MSSPL-KamalenduGarai closed 1 year ago

MSSPL-KamalenduGarai commented 1 year ago

Prerequisites

Node - 16.13.1, npm - 8.3.0 piral - 0.15.8

Description

Hi, I am trying to load multiple react js version 18 and 17 into the app cell so that I can share react@17 to the two of my pilets. You can check the screen shot of appCell package.json where you will find "react17": "npm:react@^17.0.2" which depicts how I have installed the dependency and have put "react17":"." as imports in import map section. Now, when I am creating a new pilet its showing me the error "Installing dependencies ...npm ERR! Cannot convert undefined or null to object". If I remove react17 from import map then its building fine. Will you please shed some light to it.

Expected behavior

It should get compiled without generating any error.

FlorianRappl commented 1 year ago

A fix for this is out in the preview version.

In general though, you should not really share such different versions via the shell, but rather as distributed dependencies from the pilets. Pilets are capable of using any kind of version - and also sharing this version. You should make use of this, as it will take off the version-management responsibility from the shell.

General rule of thumb: Only share from the shell what is already used by the shell or definitely used by some pilet that will always get loaded.

MSSPL-KamalenduGarai commented 1 year ago

That is a nice explanation. Thank you.