Effect CommunityEC
Effect Community3y ago
22 replies
attila

Compilation Errors with effect-http and ESM Project

I have an ESM project and I'm trying to use effect-http as the server but I'm getting the following errors during compilation:
node_modules/effect-http/dist/ServerBuilder-7707ba6d.d.ts:3:85 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./Api.mjs")' call instead.

3 import { Api, Endpoint, EndpointSchemas, ResponseSchemaFull, IgnoredSchemaId } from './Api.mjs';
                                                                                      ~~~~~~~~~~~

node_modules/effect-http/dist/ServerBuilder-7707ba6d.d.ts:4:27 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./Extensions.mjs")' call instead.

4 import { Extension } from './Extensions.mjs';
                            ~~~~~~~~~~~~~~~~~~

node_modules/effect-http/dist/ServerBuilder-7707ba6d.d.ts:5:26 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./ServerError.mjs")' call instead.

5 import { ApiError } from './ServerError.mjs';
                           ~~~~~~~~~~~~~~~~~~~

node_modules/effect-http/dist/ServerBuilder-7707ba6d.d.ts:6:37 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("./internal.mjs")' call instead.

6 import { AnySchema, SchemaTo } from './internal.mjs';


Is something wrong with my setup or is it a problem with effect-http? I tried it with version effect-http@0.23.1 🙏
Was this page helpful?