patternfly / patternfly/patternfly-react

Bug - react-icons 6.6.1- invalid ESM module

Open
#12,657 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
862
Forks
392
Avg merge
4d 8h
Merged PRs (30d)
9

Description

Describe the problem
Webpack build fails with error:

ERROR in ./node_modules/@patternfly/react-icons/dist/esm/createIcon.js 2:0-63
Module not found: Error: Can't resolve 'react/jsx-runtime' in '/home/xxx/repos/pf_modules/node_modules/@patternfly/react-icons/dist/esm'
Did you mean 'jsx-runtime.js'?
BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.

How do you reproduce the problem?
minimal code to recreate the issue: https://github.com/rszwajko/pf-icons-esm-bug
Initially encountered while updating libraries on older branches of https://github.com/openshift/networking-console-plugin

Expected behavior
Webpack build should work without relaxing import rules.

Is this issue blocking you?
No. Workaround exists i.e. as used here https://github.com/openshift/networking-console-plugin/commit/e4ed48dabced60f949d4af09559996b131c93fba

      {
        test: /\.m?js/,
        include: /node_modules\/@patternfly\/.*/,
        resolve: {
          fullySpecified: false,
        },
      },

What is your environment?
React 17
react-icons 6.6.1

What is your product and what release date are you targeting?
https://github.com/openshift/networking-console-plugin


Jira Issue: PF-4648

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction at https://github.com/rszwajko/pf-icons-esm-bug and inspect the generated @patternfly/react-icons/dist/esm/createIcon.js import of react/jsx-runtime under Webpack. Reproduce the failure with React 17 and react-icons 6.6.1; done means the Webpack build works without relaxing import rules.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript, webpack
Domain
build-system, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.