Essentials: Prebundle addons and minimize need for react/react-dom as peerDependency#23486
Closed
ndelangen wants to merge 31 commits into
Closed
Conversation
…into norbert/no-docs-no-react-peers
…into norbert/no-docs-no-react-peers
…into norbert/no-docs-no-react-peers
|
👍 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
Member
Author
|
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
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What I did
preview.tsandmanager.tsentrypoints never need to have types generated for them, not generating them saves install-size and compile/publish-timemanager.tsfile should be prebundled. References to manager-related storybook packages andreactwill be globalized/externalized by the builder-manager.. So why not do this before publishing.preview.tsfile should be prebundled. References to preview-related storybook packages will be globalized by the builder.. So why not do this before publishing?preset.tsshould be compiled for node16 only, and does not need types generated.react&react-dompeerDependencies as much as possible.reactbecause ofmanager.tsinjecting custom Panels and such do not need the dependency anymore, this is solved via the new bundle script for addons!reactfor 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 theLinkTocomponent, that is it's own export... I've made this have an optional peerDependency onreactfor now. Such addons ARE NOT ALLOWED IN ESSENTIALS!builder-webpack5needsreactbecause it added aliases for some manager-packages. I removed this here: WebpackBuilder: Remove need forreactas peerDependency #23496To be determined
react in the preview
preview.tsfile 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-apineedsreactbecause it exposes components and hooks. This package ends up being embedded intomanagerpackage, in whichreactis prebundled. I've spiked moving the code intomanager: Refactor: Move code oflib/manager-apiintoui/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...routerneedsreactbecause it's embeddingreact-router. This package is only used in the manager, so whatever I end up doing tomanager-apiI'll likely do here as well. I'm not sure this packages has any real-world use anymore TBH, could be merged intomanager-api?themingneedsreactbecause it's embeddingemotion-react. This package is used in the manager, but has seen other uses as well. globalizingreactin it'sdistseems not possible to me because of it.TBD: How to cope with
manager-api,routerandthemingpackages depending on react.browserextra export. I'm not sure what the point of that would truly be.manager-api's and orrouter's implementations into themanagerpackage.TBD: How to cope with
blocksandcomponentspackages depending on react.reactcomponentsalso has a dependency onreact-dom.TBD: Do we want to remove addon-docs from
sb init?TBD: Do I remove the addon-links
LinkTocomponent? ? move it somewhere else to make addon-links not depend onreactanymore? Do I externalizereactin the preview?TBD: the package
typesneedsreact, 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 isskipLibCheckthis might be ok??manager-api?How to test
TBD