esbuild_deno_loader
esbuild_deno_loader copied to clipboard
Could not resolve react in "@react-three/drei" using deno-loader
Description
I encountered an error while using the deno-loader plugin in my Deno project. The error message indicates that it could not resolve the "react" module only when using @react-three/drei. It's doing fine with @react-three/fiber.
Error Message
✘ [ERROR] Could not resolve "react" [plugin deno-loader]
../../../Library/Caches/deno/deno_esbuild/[email protected][email protected]/node_modules/tunnel-rat/dist/index.js:1:18:
1 │ import React from 'react';
╵ ~~~~~~~
...
error: Uncaught (in promise) Error: Build failed with 3 errors:
../../../Library/Caches/deno/deno_esbuild/@react-three/[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@react-three/drei/web/Html.js:3:26: ERROR: [plugin: deno-loader] Could not resolve "react-dom/client"
../../../Library/Caches/deno/deno_esbuild/@react-three/[email protected]_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@react-three/drei/web/ScrollControls.js:3:26: ERROR: [plugin: deno-loader] Could not resolve "react-dom/client"
../../../Library/Caches/deno/deno_esbuild/[email protected][email protected]/node_modules/tunnel-rat/dist/index.js:1:18: ERROR: [plugin: deno-loader]
Steps to Reproduce
- Install the deno-loader plugin in a Deno project.
- Attempt to import the "@react-three/drei" module using esbuild and the deno-loader in a JavaScript or TypeScript file.
- Run the Deno script.
Expected Behavior
The deno-loader plugin should be able to resolve the "react" module and allow its usage in the Deno project.
Actual Behavior
The deno-loader plugin fails to resolve the "react" module, resulting in the aforementioned error.
Environment
- Deno version: 1.42
- deno-loader version: 0.10
- Operating System: macos
- deno.json imports:
{
...
"imports": {
"@react-three/fiber": "npm:@react-three/[email protected]",
"@react-three/drei": "npm:@react-three/[email protected]",
"react": "npm:react@^18.2.0",
"react/": "npm:/react@^18.2.0/",
"react-dom": "npm:react-dom@^18.2.0",
"react-dom/": "npm:/react-dom@^18.2.0/"
}
}
Additional Information
- The error occurs when importing the "react" module from the "tunnel-rat" package.
- The file path in the error message suggests that the "react" module is being imported from a cached location.
Possible Cause
It seems that the deno-loader plugin is unable to resolve the "react" module correctly, possibly due to a configuration issue or a compatibility problem between the plugin and the "react" module.
I would appreciate any assistance or guidance in resolving this issue. Please let me know if you need any further information or clarification.
Thank you for your attention to this matter.
Hey! Try give a look at my comment on a similar issue: https://github.com/lucacasonato/esbuild_deno_loader/issues/127#issuecomment-2211477464