-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Feat: Do not put component into global namespace #1116
Conversation
BREAKING CHANGE: Style guide componets are no longer accessible on window. Only current component is accessible in the example context (not on window). You need to explicitly import any other component.
@@ -44,6 +44,22 @@ Fenced blocks with other languages are rendered as highlighted code: | |||
<h1>Hello world</h1> | |||
``` | |||
|
|||
Current component (like `Button` in this example) is always accessible by its name in the example code. If you want to use other component, you need to explicitly import them: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar, either:
If you want to use another component, you need to explicitly import it
or
If you want to use other components, you need to explicitly import them
I really like this change! Will help a lot with large styleguides. 👍 |
This change is bittersweet to me, I understand the reasoning but it does take away some convenience, especially when experimenting with examples in the code editor. To be honest it's making me reconsider using markdown at all - normal .js files obviously have tooling advantages. Would you accept a PR which:
I've got a project with 283 markdown files here and not enjoying the prospect of converting them by hand! |
Keep in mind that the current component is still available, and in my experience it's the majority of the use cases. You can use context option to list components you want to access in your examples — that should be more reliable than autoloading everything on Styleguidist side, which will have similar issues with duplicated component names, that we have now. |
BREAKING CHANGE:
Style guide componets are no longer accessible on window. Only current component is accessible in the example context (not on window). You need to explicitly import any other component.