-
Notifications
You must be signed in to change notification settings - Fork 19
Description
The problem
Webpack 5 module federation dependency sharing works best with imports from a package's root entry file. Currently to share Pharos, folks would need to list the individual components they'd like to share as their imports go deep into the package:
import '@ithaka/pharos/lib/components/modal/pharos-modal';
The solution
Address #3 and then add an exports field to the package.json to define the main entry point and encapsulate the package to prevent other entry points.
"exports": {
".": "./lib/index.js",
"./lib": "./lib/index.js",
"./lib/index": "./lib/index.js",
"./lib/index.js": "./lib/index.js",
"./package.json": "./package.json",
"./custom-elements.json": "./custom-elements.json"
}
The first entry would allow consumers to import component definitions in this way:
import { PharosButton } from '@ithaka/pharos';
Thus they would only need to add @ithaka/pharos
as a shared dependency in their MFE configuration.
Alternatives considered
N/A.
Additional information
This will likely be a breaking change as only the entry points defined in the field would be allowed.