Skip to content

Conversation

@selaux
Copy link

@selaux selaux commented Nov 14, 2025

Reasons for making this change

With "type": "module" in package.json most bundlers (e.g. webpack 5 and vite) expect an extension for referencing files directly inside node_modules. I guess the safest way is to just import them directly from the package.

For us e.g. Webpack 5 fails with:

BREAKING CHANGE: The request '@ant-design/icons/PlusCircleOutlined' 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.
Add the extension to the request.

And vite fails with:

Error: Cannot find module '/home/stefan/workspace/stracciatella-toolset/node_modules/@ant-design/icons/ExclamationCircleOutlined' imported from /home/stefan/workspace/stracciatella-toolset/node_modules/@rjsf/antd/lib/templates/ErrorList/index.js
Did you mean to import "@ant-design/icons/ExclamationCircleOutlined.js"?

Checklist

  • I'm updating documentation
  • I'm adding or updating code
    • I've added and/or updated tests. I've run npx nx run-many --target=build --exclude=@rjsf/docs && npm run test:update to update snapshots, if needed.
    • I've updated docs if needed
    • I've updated the changelog with a description of the PR
  • I'm adding a new feature
    • I've updated the playground with an example use of the feature

With `"type": "module"` in package.json most bundlers (e.g. webpack 5
and vite) expect an extension for referencing files directly inside
`node_modules`. I guess the safest way is to just import them directly
from the package.
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this pull request Nov 14, 2025
Made build-time fix for the issue attempting to be fixed by rjsf-team#4871
- Added new `antdIconsReplacer.ts` to fix up `@antd/icons` to add `.js` onto them
- Updated `@rjsf/antd` to add `antdIconsReplacer.ts` to the `compileReplacers` script, `tsconfig.build.json` and `tsconfig.replacer.json`
- Updated `CHANGELOG.md` accordingly
@heath-freenome
Copy link
Member

@selaux Thanks for trying to fix this on your own. While your fix actually solves the problem, it pulls in ALL of the icons into the system, which you probably didn't need. Instead I have pushed up a build-time fix (#4872) to add the .js suffixes into the generated distribution. That should fix it without any code changes.

@selaux
Copy link
Author

selaux commented Nov 15, 2025

Works for me as well, thanks 🙂

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants