nexus-prisma icon indicating copy to clipboard operation
nexus-prisma copied to clipboard

ESM not compatible?

Open yovanoc opened this issue 2 years ago • 5 comments

Screenshot

image

Description

I build my ts files with esbuild src/**/*.ts --platform=node --minify --target=esnext --format=esm --outdir=dist

and here's my yarn test command: cross-env NODE_ENV=${NODE_ENV:-development} DOTENV_FLOW_PATH=../.. node -r dotenv-flow/config ./dist/index.js

yovanoc avatar Apr 02 '22 11:04 yovanoc

We should aim to add official ESM support upon the release of TypeScript 4.7.

Some work has been done to provide incremental ESM support using libraries like typescript-esm but there have been test regressions as a result. Once official ESM support lands in TypeScript we'll look to implement a solution accordingly.

andrewicarlson avatar Apr 28 '22 16:04 andrewicarlson

Ok, you will aim to be ready for the release (24 may) or begin to dev from the that date?

yovanoc avatar Apr 29 '22 15:04 yovanoc

@yovanoc I believe we should add the official ESM support after it's released in TypeScript but can't provide a date by which it'll be merged. If you'd like to take a stab at implementing it based on the beta I think it'd spark great discussion!

andrewicarlson avatar May 04 '22 15:05 andrewicarlson

Its now released (https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/)

I can't do this in the next weeks so if someone want to tackle this

yovanoc avatar May 25 '22 08:05 yovanoc

Any news on this? just came back this week ^^

yovanoc avatar Aug 25 '22 08:08 yovanoc

I'm sad the commit has been reverted, it's annoying as it prevents to use vitest for example which is ESM-first.

Would be very appreciated that nexus-prisma supports ESM properly as the whole ecosystem is now moving to it 🙏

NTag avatar Nov 30 '22 10:11 NTag

I'm stuck too, can we have update on it please ? :| @jasonkuhrt ? Thanks.

fryck avatar Dec 08 '22 09:12 fryck

The transpiled esm files have .js extensions instead of .mjs. This breaks builds because .js is process as CJS while .mjs is processed as ESM. The output files should name them with the .mjs suffix.

Screen Shot 2023-05-11 at 12 22 04 AM

peace-duro avatar May 11 '23 05:05 peace-duro

@peace-duro there was an attempt here https://github.com/graphql-nexus/nexus-prisma/pull/192/files but then it was reverted to support other prisma versions, but it was time where we were supporting 3.x.x. Currently we are already on 4.x.x.

Do you want to try to reintroduce given PR to see what happens to tests.

rostislav-simonik avatar May 24 '23 05:05 rostislav-simonik

I did some investigation and summarised it in https://github.com/graphql-nexus/nexus-prisma/discussions/693. Currently, I'll be better to remove esm build, because it's not completed. I'll prepare a fix for that.

rostislav-simonik avatar Jul 31 '23 16:07 rostislav-simonik