-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Essentials: Prebundle addons and minimize need for react
/react-dom
as peerDependency
#23486
Essentials: Prebundle addons and minimize need for react
/react-dom
as peerDependency
#23486
Conversation
…into norbert/no-docs-no-react-peers
…into norbert/no-docs-no-react-peers
…into norbert/no-docs-no-react-peers
No top level dependency changes detected. Learn more about Socket for GitHub ↗︎ |
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
…into norbert/no-docs-no-react-peers
…bert/no-docs-no-react-peers
…into norbert/no-docs-no-react-peers # Conflicts: # code/addons/a11y/package.json # code/addons/actions/package.json # code/addons/backgrounds/package.json # code/addons/controls/package.json # code/addons/essentials/package.json # code/addons/gfm/package.json # code/addons/highlight/package.json # code/addons/interactions/package.json # code/addons/jest/package.json # code/addons/links/package.json # code/addons/measure/package.json # code/addons/outline/package.json # code/addons/storysource/package.json # code/addons/toolbars/package.json # code/addons/viewport/package.json
…into norbert/no-docs-no-react-peers
…een manager & preview
Notes on how to globalize
If we solve the above, I can make a version of In addition I could adjust the addon-bundler to also globalize |
react
/react-dom
as peerDependency
…into norbert/no-docs-no-react-peers
…js/storybook into norbert/no-docs-no-react-peers
What I did
preview.ts
andmanager.ts
entrypoints never need to have types generated for them, not generating them saves install-size and compile/publish-timemanager.ts
file should be prebundled. References to manager-related storybook packages andreact
will be globalized/externalized by the builder-manager.. So why not do this before publishing.preview.ts
file should be prebundled. References to preview-related storybook packages will be globalized by the builder.. So why not do this before publishing?preset.ts
should be compiled for node16 only, and does not need types generated.react
&react-dom
peerDependencies as much as possible.react
because ofmanager.ts
injecting custom Panels and such do not need the dependency anymore, this is solved via the new bundle script for addons!react
for decorators will need a peerDependency onreact
. This makes the addon react specific, though a notable exception here is addon-links. It has a react dep for theLinkTo
component, that is it's own export... I've made this have an optional peerDependency onreact
for now. Such addons ARE NOT ALLOWED IN ESSENTIALS!builder-webpack5
needsreact
because it added aliases for some manager-packages. I removed this here: WebpackBuilder: Remove need forreact
as peerDependency #23496To be determined
react in the preview
preview.ts
file might have a dependency toreact
, I could possibly prebundle this as well, and maybe globalized/externalized react for the preview?react
, and possibly be able to prebundle most if not all of addon-docs? I could make a prebundled version of react and inject it into the preview, so the global variable is available. If the user isn't using react themselves, I could use the version storybook shipped with, if the user does use react themselves, I'd quickly prebundle their version of react, and inject that...react in manager deps
manager-api
needsreact
because it exposes components and hooks. This package ends up being embedded intomanager
package, in whichreact
is prebundled. I've spiked moving the code intomanager
: Refactor: Move code oflib/manager-api
intoui/manager
#23389. That PR doesn't actually change the fact the package is depending onreact
. Users of this package (addon-authors) will want to get proper types, which includereact
-types! Embedding those in might actually be the correct move, because that would ensure users will be told if they tried to do things our version of react embedded into the manager can't do...router
needsreact
because it's embeddingreact-router
. This package is only used in the manager, so whatever I end up doing tomanager-api
I'll likely do here as well. I'm not sure this packages has any real-world use anymore TBH, could be merged intomanager-api
?theming
needsreact
because it's embeddingemotion-react
. This package is used in the manager, but has seen other uses as well. globalizingreact
in it'sdist
seems not possible to me because of it.TBD: How to cope with
manager-api
,router
andtheming
packages depending on react.browser
extra export. I'm not sure what the point of that would truly be.manager-api
's and orrouter
's implementations into themanager
package.TBD: How to cope with
blocks
andcomponents
packages depending on react.react
components
also has a dependency onreact-dom
.TBD: Do we want to remove addon-docs from
sb init
?TBD: Do I remove the addon-links
LinkTo
component? ? move it somewhere else to make addon-links not depend onreact
anymore? Do I externalizereact
in the preview?TBD: the package
types
needsreact
, mostly for manager-api stuff. It's externalized it seems right now, without any dependency defined.. this is possibly problematic, but considering it's just types, and the recommendation isskipLibCheck
this might be ok??manager-api
?How to test
TBD