rfcs/2021-v3-uxp-integration.md
This feature will provide a pattern that we can follow to integrate UXP specific components into the repository and build process. More generally it will describe an approach for providing environment specific overrides for one or more components.
We need to provide React Spectrum compliant components that run on UXP including both plugin environments and Adobe internal projects. When complete a user should be able to import this repository and build applications that run both in modern web browsers and on UXP with the same source code. Some bundling configuration may be required to support bundle-time selection of UXP specific components.
UXP = Unified Extensibility Platform. This platform is used both internally by Adobe and also public plugins for Adobe products including XD.
We will create a new @react-spectrum-uxp organization at npmjs.com in order to provide a namespace for all of our UXP specific react-spectrum modules.
Our UXP implementations will have the same name as the react-spectrum modules they replace but be hosted within our new namespace. For example our implementation of @react-spectrum/button will be at @react-spectrum-uxp/button.
For every @react-spectrum module which needs a modified implementation of one or more components for UXP we will do the following:
packages/@react-spectrum-uxp/[name].packages/@react-spectrum/[name].packages/@react-spectrum/[name].We will create a new package at packages/@adobe/react-spectrum-uxp that has the same API and exports as packages/@adobe/react-spectrum but exports our UXP specific components where needed and simply re-exports any base components that need no changes.
This package will be published on npmjs.com as @adobe/react-spectrum-uxp.
UXP Developers will need a convenient way to author and test UXP components with hot module reloading (HMR). We propose adding a UXP compatible storybook plugin to the repository at packages/@react-spectrum-uxp/storybook.
This new package will:
./stories files for each module.UXP clients will simply modify their existing @adobe/react-spectrum import and change it to @adobe/react-spectrum-uxp. This can also be done with aliasing in most bundlers so that no source code needs to be changed.
We may provide plugins for both parcel and webpack that simplify consumption if needed, but the usage of conditional exports may make this unnecessary.
In order to streamline review process and avoid undue burden on core react-spectrum developers, we propose making UXP team architects code owners over the react-spectrum-uxp folder packages/@react-spectrum-uxp and the mono-package folder ./packages/@adobe/react-spectrum-uxp.
The currently existing PR tests will ensure that uxp specific targets are always built successfully.
No changes within the uxp specific folders should have any effect upon the current browser specific modules.
Backwards incompatible/breaking changes to react-spectrum module API's may cause compile errors in corresponding UXP projects. If this happens then the react-spectrum core developer can fix the type errors and should add a UXP team member such as myself to the review process.
https://github.com/adobe/react-spectrum/compare/main...krisnye:monorepo?expand=1
The presence of new UXP specific modules will increase complexity of the repository and build time. Contributors without a UXP environment won't be able to test any changes that impact UXP.
We will not be changing any public API's or currently existing entry points into packages. No behavior should change for web based consumers. UXP users will need to use a parcel/webpack plugin to bundle the correct new UXP entry points.
Use an external package as the UXP entry point.
Integrate UXP specific components at runtime.
How do we configure Parcel bundling for UXP?
How do we configure Webpack bundling for UXP?
How do we add any tests that require a UXP environment?
Will package.json conditional exports handle importing UXP vs web entry points?
Once code ownership over UXP directories is granted, no further significant help is expected to be needed.