-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add extensions to third-party imports without export maps #2
Comments
It seems you need to support both commonjs and esm. I also encountered similar case, my workaround is the modify the source using custom script when running/building for different env... (My case is the server is running in esm, but database migration tool (knex) need to run in commonjs, and they have shared import) |
I just try to import the The error message when running the file:
|
I figured out a way to fix your case. First we import it as below: import * as pkg from '@react-three/drei/core/useContextBridge.js'
const { useContextBridge } = pkg Then we modify the Step 2 is required because the import * as React from 'react'; The package We cannot blindly change all imported third-party packages from commonjs into esm packages because they maybe using If we want to address this problem from In this case, if we cannot fix the problem on
|
This module has solved a lot of my headaches, but there are still some edge cases. To work with ESM, the code
needs to be rewritten to
which this module currently doesn't do. (Note that
@react-three/drei
doesn't use theexports
field.) I don't want to put the.js
in my.ts
source since the CJS version should (probably?) import@react-three/drei/core/useContextBridge.cjs.js
.The text was updated successfully, but these errors were encountered: