Skip to content
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

Bug - [react-icons] - babel transformation error from PF provided snippet #9377

Closed
christianvogt opened this issue Jul 18, 2023 · 1 comment · Fixed by #9759
Closed

Bug - [react-icons] - babel transformation error from PF provided snippet #9377

christianvogt opened this issue Jul 18, 2023 · 1 comment · Fixed by #9759
Assignees
Milestone

Comments

@christianvogt
Copy link
Contributor

Describe the problem
Patternfly react-icons README provides the following code snippet to aid with tree shaking:

module.exports = {
  presets: ["@babel/preset-env", "@babel/preset-react"],
  plugins: [
    [
      "transform-imports",
      {
        "@patternfly/react-icons": {
          transform: (importName, matches) => `@patternfly/react-icons/dist/js/icons/${importName.split(/(?=[A-Z])/).join('-').toLowerCase()}`,
          preventFullImport: true
        }
      }
    ]
  ]
}

This snippet however doesn't work with all icons as some of the icons contain upper case characters in the name. The failing icons are coming from customIcons.js. For example pathMissing icon.

image

How do you reproduce the problem?

  • Create a new patternfly based react project.
  • Create a source file with the following import: import { PathMissingIcon } from '@patternfly/react-icons';
  • Add the suggested plugin snippet to your babel.config.js
  • Build your project.

Error:
ModuleNotFoundError: Module not found: Error: Can't resolve '@patternfly/react-icons/dist/js/icons/path-missing-icon' in ...

Expected behavior
Update code snippet with exceptions or generate icons with consistent case.

Is this issue blocking you?
No

What is your environment?

  • @patternfly/react-icons: 4.93.6

What is your product and what release date are you targeting?
Open Data Hub

Any other information?

@stale
Copy link

stale bot commented Oct 1, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants