PF3 Card use break with webpack tree shaking on when using embedded sub-components
See original GitHub issueUsing the following style, the Card
component breaks with webpack tree shaking (i.e. production mode) turned on:
import React from 'react'
import PropTypes from 'prop-types'
import Format from 'intl-messageformat'
import { Card, Icon } from 'patternfly-react'
const UpgradeReview = ({
hostCount,
hostLabel = '{count,number} {count, plural, one {Host} other {Hosts}}',
hostsDescription = 'Will be upgraded one at a time during Cluster upgrade'
}) => {
const hostLabelFormat = new Format(hostsLabel)
return (
<div className='clusterUpgradeWizard-UpgradeReview'>
<Card>
<Card.Title>
<Icon type='pf' name='container-node' className='circle-icon' />
<div className='info-label'>
{ hostLabelFormat.format({ count: hostCount }) }
</div>
</Card.Title>
<Card.Body>
{ hostsDescription }
</Card.Body>
</Card>
</div>
)
}
UpgradeReview.propTypes = {
hostCount: PropTypes.number.isRequired,
hostLabel: PropTypes.string,
hostsDescription: PropTypes.string
}
export default UpgradeReview
The reason it breaks due to a change in #2190 that moved the sub components from Card.js
to the peer index.js
. It is the only component that looks like this.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
Read more >Tree shaking and code splitting in webpack - LogRocket Blog
Here, we'll explain tree shaking and code splitting in webpack and discuss how to combine them for the most optimal bundle possible.
Read more >Tree-Shaking Basics for React Applications - Telerik
Tree -shaking is an important way to reduce the size of your bundle and improve performance. See how you can do it in...
Read more >Webpack 3, Babel and Tree shaking not working
Webpack's built-in tree shaking works on ES6 module syntax only. If you're using Babel's defaults settings, Babel will compile ES6 modules ...
Read more >Tree-Shaking Problems with Component Libraries - Medium
Whether you like it or not, Webpack is endemic to modern front end applications. It's an incredible tool, building on the legacy of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have a work around – import and use
CardTitle
andCardBody
directly. Looks like an easy fix, I may submit a PR for that if I have a few extra cycles this week.Hi @sjd78 yes, we can close this issue