This thread is just for documentation if anyone else have a hardtime to solve following problem:
ERROR in ./node_modules/react-dnd/dist/esm/core/DndProvider.mjs 28:0-51
Module not found: Error: Package path ./jsx-runtime.js is not exported from package /home/local/MGM/tfreygang/epsap/main3/webapp/node_modules/react (see exports field in /home/local/MGM/tfreygang/epsap/main3/webapp/node_modules/react/package.json)
@ ./node_modules/react-dnd/dist/esm/core/index.mjs
@ ./node_modules/react-dnd/dist/esm/index.mjs 2:0-33 2:0-33
@ ./src/index.tsx 1:82-117 1:2175-2186
webpack 5.93.0 compiled with 1 error in 27663 ms
Solution:
You need to add mjs files to extensions and add an alias, also your loader for javascript/Typescript need to handle .mjs files as well.
before:
extensions: [".ts", ".tsx", ".js", ".json", ".css"],
module: {
rules: [
{
oneOf: [
{
test: /\.(js|tsx?)$/,
use: ["thread-loader", {
loader: "swc-loader",
after:
extensions: [".ts", ".tsx", ".js", ".mjs", ".json", ".css"],
alias: {
"react/jsx-runtime.js": "react/jsx-runtime",
"react/jsx-dev-runtime.js": "react/jsx-dev-runtime"
},
module: {
rules: [
{
oneOf: [
{
test: /\.(js|mjs|tsx?)$/,
use: ["thread-loader", {
loader: "swc-loader",