-
Notifications
You must be signed in to change notification settings - Fork 175
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
Dynamic import syntax highlighter from source to save on bundle size #874
Conversation
size-limit report 📦
|
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
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.
I need to keep reference to this PR so I will remember why we have this exclude
clauses and where we need to modify them in the future
0b51ea5
to
aaa7f8a
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
aaa7f8a
to
9a6f635
Compare
9a6f635
to
b25d769
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
b25d769
to
eb8dcec
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
eb8dcec
to
865b35e
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
865b35e
to
ee35089
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
0886334
to
a2ee828
Compare
a2ee828
to
fe9fe14
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
export default class Highlighter extends React.Component<Props> { | ||
render() { | ||
const { children: source } = this.props; | ||
|
||
return <SyntaxHighlighter className="source-modal__source" language="json" style={githubGist}> | ||
{source} | ||
</SyntaxHighlighter>; | ||
} | ||
} |
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.
export default class Highlighter extends React.Component<Props> { | |
render() { | |
const { children: source } = this.props; | |
return <SyntaxHighlighter className="source-modal__source" language="json" style={githubGist}> | |
{source} | |
</SyntaxHighlighter>; | |
} | |
} | |
export const Highlighter: SFC = ({ children: source }) => | |
<SyntaxHighlighter className="source-modal__source" language="json" style={githubGist}> | |
{source} | |
</SyntaxHighlighter>; |
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.
Of course, need to import SFC from React.
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.
TS told me SFC
is deprecated and I should use FunctionComponent
.
Also it has to export default to work as lazy component.
<SyntaxHighlighter className="source-modal__source" language="json" style={githubGist}> | ||
{source} | ||
</SyntaxHighlighter> | ||
<React.Suspense fallback={Loader}> |
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.
Perfect case for lazy component!
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.
Yeah, it is! Wonder if SourceModal
wouldn't be a better candidate though.
3fabd8b
to
651431c
Compare
651431c
to
5cc85d4
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
1 similar comment
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
5cc85d4
to
03fc616
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
03fc616
to
70695c1
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
70695c1
to
aa12c0a
Compare
✅ Deployed successfully to: https://turnilo-syntax-highlighter-src-gmbbyye42a-ew.a.run.app |
#845