-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
import locale in SvelteKit/NodeJS #2964
Comments
seems i got it to work with: |
I have the same problem. I'll give it a try |
@faulander @garytube What |
TLDR, this is because Node.js doesn't allow a package to provide both CommonJS and ESM build under the same extension ( I created a PR to fix this issue: #3099 |
due to lack of esm support from date-fns it's now completely unusable with dynamic locale imports |
@ZerdoX-x for me it works:
|
esm problem
|
Works fine without TS complaining: |
In my environment (run directly on Node v18 after tsc), I had to make a declare module 'date-fns/locale/index.js' {
import { ja } from 'date-fns/locale';
export { ja }
} Then, refer it when importing: /// <reference types="path/to/date-fns-workaround.d.ts" />
import { ja } from 'date-fns/locale/index.js'; Make sure to add the directory |
For this to properly be fixed you probably need to add "exports" in this package's package.json
https://nodejs.org/api/packages.html#packages_exports otherwise you need
|
@kossnocorp now that ESM support has been merged into (it was marked as one of the issues that #3099 was going to close) |
package.json example.tsx
|
i tried the following combinations:
all of them bring this or a similar error:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '.../node_modules/date-fns/locale/de' is not supported resolving ES modules imported from .../.svelte-kit/output/server/entries/pages/moral.svelte.js
How can i get this to work please?
The text was updated successfully, but these errors were encountered: