#1910·fp-ts

Directory import is not supported resolving ES modules

Author: thobsonCreated Oct 20, 2023Updated May 20, 2025

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:

Directory import 'node_modules/fp-ts/function' is not supported resolving ES modules imported from .svelte-kit/output/server/entries/pages/_page.svelte.js

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

bash
.pnpm/[email protected]/node_modules/fp-ts/es6/function.js:17
export var getBooleanAlgebra = function (B) {
^^^^^^

SyntaxError: Unexpected token 'export'

Your environment

Software Version(s)
fp-ts 2.16.1
TypeScript 5.2.2
vite 4.5.0