question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PF3 Card use break with webpack tree shaking on when using embedded sub-components

See original GitHub issue

Using 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sjd78commented, Sep 16, 2019

Hi @sjd78 do you have a work around for this or is this a blocker for you at this time?

I have a work around – import and use CardTitle and CardBody directly. Looks like an easy fix, I may submit a PR for that if I have a few extra cycles this week.

0reactions
rachael-phillipscommented, Dec 2, 2019

Hi @sjd78 yes, we can close this issue

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found