-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Directory import is not supported resolving ES modules #1910
Comments
Quick update: importing from lib seems to resolve the issue, but if I'm honest I don't understand why 😄
I'll leave the ticket here in case someone else runs into the same problem |
Same happened on my local machine, directly using fp-ts. Used npm version is "Fix" from @thobson comment appears to work |
For anyone wondering, the fp-ts ecosystem of libraries don't currently support ESM, instead only ES6 and CJS. When you explicitly import from |
I recently hit this issue and I think I might have a fix. Please hold... |
Ok, in order to fix this issue the In the package.json the existing fields for main, module, and typings, would need to be removed and replaced with the exports field for each module, like this: "exports": {
"./Option": {
"import": "./es6/Option.js",
"require": "./lib/Option.js",
"types": "./lib/Option.d.ts"
}
}, And files inside the import { getApplicativeMonoid } from './Applicative.js';
import { apFirst as apFirst_, apS as apS_, apSecond as apSecond_, getApplySemigroup as getApplySemigroup_ } from './Apply.js';
import * as chainable from './Chain.js'; |
Since this is just using // this
import { foo } from './lib' // Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './lib.js'?
// would have to become this
import { add } from './lib.js' |
🐛 Bug report
Firstly, apologies but I'm not sure if this is an fp-ts issue or a vite/webpack/sveltekit issue but I'd be grateful for any pointers ...
Current Behavior
I'm importing using this syntax:
import { pipe } from "fp-ts/function";
When running
vite dev
everything works fine, however after building and running the svelte kit app I get this error:Additional context
I can work around the issue by importing like this:
import { pipe } from "fp-ts/es6/function";
However this then raises an error during
vite dev
Your environment
The text was updated successfully, but these errors were encountered: