Open LumaKernel opened 8 months ago
Is there any update on this issue? I am experiencing it with v2.9.2
.
@remix-run/dev: 2.9.2
@remix-run/node: 2.9.2
@remix-run/react: 2.9.2
@remix-run/serve: 2.9.2
I am also experiencing the same issue
I've been running into the same issue with several packages such as react-content-loader
and the workaround mentioned above seems to work for my case too.
I encountered the same issue when using chartjs-react.
Following the suggestions from the original poster and this comment, I tried the following two solutions, both of which resolved the issue:
{ "type": "module" }
to lib's package.json
file.client.tsx
file
Reproduction
Quick: Go to https://stackblitz.com/edit/remix-run-remix-cqepq2?file=app%2Froutes%2F_index.tsx Or see https://github.com/remix-run/remix/pull/9071
'use-immer'
The package which causes this problem has these conditions:
type: module
in package.jsonexports: { ".": { import: "something" }}
in package.jsonThe package.json in use-immer@0.9.0, you can see like this:
And we can confirm this satisfies the condition. Actually, if I add "type=module" to this, and restart remix run, it succeeds to import.
Extra contexts
related:
This could be the bug of vite. I can create issue instead on vite, but I'm not sure for now. The most important part of this issue is I got small reproduction for these issues (currently discussions).
~I'm also making PR for Option 1 after submitting this issue.~ Done.
By the way, you may think, such packages should have
type: module
in their package.json. Actually, import from these packages from esm does not work, and multi-support is actually not possible by native level. Even if type=module is added, now, it cannot be require-able. Sadly, this is complicated situation. Node.js, TypeScript and Webpack treats exports as their own way. Webpack says as https://webpack.js.org/guides/package-exports/#support .Thanks.
System Info
Used Package Manager
npm
Expected Behavior
Not get error and just can import it as ESM module as usual.
Actual Behavior
Got an error:
We have the workaround for this, just with importing by relative path: