react@17 & webpack/babel という古い環境で react-virtuoso という仮想化ライブラリを使おうとして以下のエラーに遭遇しました。
Module not found: Error: Can't resolve 'react/jsx-runtime' in '/node_modules/react-virtuoso/dist'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 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.
webpack.config.js
にエイリアスを追加することで無事動くようになりました。
const config: webpack.Configuration = { resolve: { alias: { 'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js', 'react/jsx-runtime': 'react/jsx-runtime.js', }, },
};export default config;