Skip to content
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

jest doesn't find scalars #137

Closed
Manubi opened this issue Aug 30, 2021 · 18 comments
Closed

jest doesn't find scalars #137

Manubi opened this issue Aug 30, 2021 · 18 comments
Assignees
Labels
type/bug Something is not working the way it should

Comments

@Manubi
Copy link

Manubi commented Aug 30, 2021

CleanShot 2021-08-30 at 23 18 20@2x

Hi,

"nexus-prisma": "^0.33.0",
"nexus": "^1.1.0",
"@prisma/client": "^2.30.1"
"prisma": "^2.30.1"

thanks!

@Manubi Manubi added the type/bug Something is not working the way it should label Aug 30, 2021
@jasonkuhrt
Copy link
Member

Is this happening for you outside of Jest too?

@jasonkuhrt jasonkuhrt added the needs/discussion Something needs deciding, new info changes issue scope/spec, unforeseen challenges, etc. label Aug 31, 2021
@Manubi
Copy link
Author

Manubi commented Aug 31, 2021

No, just if I run jest. I know it's not a nexus-prisma bug, but I think the chances of finding a solution are bigger here? :)

@jasonkuhrt
Copy link
Member

Yeah it might be an integration issue that we can better support (Like we did for vercel/ncc) or at least document.

This is weird.

One thing I can say is that we're using the new Node's recent support for package exports field. I think only supported since Node 12.

I wonder if Jest transpilation/pre-processing is somehow failing on this...

Are all your deps up to date?
Node 16 or 14?
Are you using ts-jest?
What does your jest config look like?

If all your deps are not up to date I would start there. And use Node 16 or 14 if 16 not possible for you.

@Manubi
Copy link
Author

Manubi commented Sep 1, 2021

Hey,

deps are all up to date. Also tried the moduleMapper in the jest config without success. Any other ideas?

node: v 16.8.0
"jest": "^27.1.0"
"nexus-prisma": "^0.33.0",
"nexus": "^1.1.0",

jest config in package.json

  "jest": {
    "setupFiles": [
      "dotenv/config"
    ],
    "setupFilesAfterEnv": [
      "./src/test/jest-setup.ts"
    ],
    "transform": {
      "\\.tsx?$": [
        "babel-jest",
        {
          "configFile": "./.babelrc.jest.js"
        }
      ]
    }
  },

@jasonkuhrt
Copy link
Member

Can you share a repo repro?

@Manubi
Copy link
Author

Manubi commented Sep 2, 2021

I would need to make one. Will you look into it if I make one? 😄

@jasonkuhrt
Copy link
Member

@Manubi yep if its not massive 😅

@Manubi
Copy link
Author

Manubi commented Sep 7, 2021

Sorry, didn't have time to make a repo repro.
But, jestjs/jest#9771 looks like Jest has still problems with importing from exports in the package.json. Not sure what a good solution would be.

@sachinraja
Copy link

sachinraja commented Sep 9, 2021

eslint-plugin-import is also erroring import/no-unresolved for nexus-prisma/scalars. I believe it has to do with this change as I only got the error after updating. The import works fine though, the scalars still show up in my schema.

Both jest and eslint-plugin-import support for exports seem to be blocked by browserify/resolve#222. The only solution I see is providing cjs paths (a scalars.js file in the root directory). This is what next.js does (see file tree).

@jasonkuhrt
Copy link
Member

We used to have the old system.

If I bring it back it seems that it will support old systems still transitioning to ESM

@jasonkuhrt
Copy link
Member

I'm convinced to bring back the old system. Will try to push a fix for this soon. If someone wants to go in the git history and pull it back out into a new pr please do

@sachinraja
Copy link

sachinraja commented Sep 9, 2021

Can't we just add a scalars.js that re-exports dist-cjs/entrypoints/scalars.js to the root dir?

Also I believe the esm files should have the file extension .mjs as this package is not marked as "type": "module" (I think this is the cause of #142). I don't think the typescript compiler has the ability to do this, but babel certainly can if you are willing to add it (I can also attempt a PR). If not, we could just have a script that renames the dist-esm files to have the .mjs extension.

@jasonkuhrt
Copy link
Member

Yes this is what we used to do. Again just look in the git history. We had a script that built the facade files before publishing. We did not commit them to the repo.

@jasonkuhrt
Copy link
Member

About .mjs I am waiting for TS to do this, it should land later this year.

@sachinraja
Copy link

Yes this is what we used to do. Again just look in the git history. We had a script that built the facade files before publishing.

Oh sorry, I should have looked first.

About .mjs I am waiting for TS to do this, it should land later this year.

Correct me if I'm wrong, but I don't think the TS team has plans for that looking at microsoft/TypeScript#18442. The ESM files cannot be imported otherwise and dist-esm is useless. Also a simple rename wouldn't be too difficult renamer -regex --find '\.js^' --replace '.mjs' './dist-esm/**/*.js'.

I understand if you don't want to do this though, just suggesting in case you do still want to have cjs and esm builds.

@jasonkuhrt
Copy link
Member

Correct me if I'm wrong, but I don't thin

I haven't followed that issue too closely, my plan was to wait for it to be closed and see what the outcome was.

@jasonkuhrt jasonkuhrt removed the needs/discussion Something needs deciding, new info changes issue scope/spec, unforeseen challenges, etc. label Sep 10, 2021
@jasonkuhrt jasonkuhrt pinned this issue Sep 10, 2021
@Manubi
Copy link
Author

Manubi commented Sep 16, 2021

Hey,
jest added a resolver field in the latest version v27.0.2 . Does anyone know how that setup should look like in order to work with nexus-prisma? 😶‍🌫️ Because I think it should fix this problem. Correct? 😄

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Sep 16, 2021

Hm! If someone figures this out and wants to send docs to NP that would be great.

@jasonkuhrt jasonkuhrt self-assigned this Sep 18, 2021
@jasonkuhrt jasonkuhrt unpinned this issue Sep 18, 2021
github-actions bot pushed a commit that referenced this issue Jan 7, 2023
## 1.0.0 (2023-01-07)

### ⚠ BREAKING CHANGES

* **deps:** update dependency graphql to v16

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Rostislav Simonik <rostislav.simonik@technologystudio.sk>
* scalars module only exports named exports (#187)
* support latest Prisma (#164)
* no types namespace (#130)
* remove support for prisma 2.17
* support prisma 2.30 (#114)
* Prisma Int @id maps to GraphQL Int  (#23)
* better names, auto-import friendly, jsdoc (#12)
* validate that peer dep requirements are met
* **deps:** nexua and @prisma/client are peer dependencies
* hello world

### Features

* add bytes scalar support ([#75](#75)) ([88fd092](88fd092))
* add default resolver for relation fields ([#25](#25)) ([4f5cd70](4f5cd70))
* add nexus_prisma bin for =<2.17 prisma users ([469c9e9](469c9e9))
* add nexusPrisma default and named export ([704f07c](704f07c))
* add peer dep support for prisma 2.18.x ([2e898ab](2e898ab))
* add support for BigInt scalar ([#56](#56)) ([67ce824](67ce824))
* add support for Decimal scalar ([#96](#96)) ([74da7c2](74da7c2))
* add support for reading configuration at generation time ([#27](#27)) ([275e03f](275e03f))
* control rejectOnNotFound client setting ([#135](#135)) ([01daf38](01daf38))
* **deps:** nexua and @prisma/client are peer dependencies ([b28217b](b28217b))
* emit model scalar fields ([#5](#5)) ([3a0a75a](3a0a75a))
* esm support ([#127](#127)) ([eec4932](eec4932))
* gentime setting for output directory ([#166](#166)) ([83889bf](83889bf))
* hello world ([9667cd0](9667cd0))
* Json & DateTime custom scalar support ([#9](#9)) ([df51143](df51143)), closes [#8](#8)
* Prisma Int [@id](https://github.com/id) maps to GraphQL Int  ([#23](#23)) ([624c745](624c745))
* settings system for runtime & gentime ([#42](#42)) ([ef76e45](ef76e45))
* **settings:** allow customization of prisma client import ([#49](#49)) ([c8b5f6c](c8b5f6c))
* **settings:** allow disable jsdoc guide ([#136](#136)) ([9418649](9418649))
* support latest Prisma ([#164](#164)) ([594699d](594699d))
* support prisma 2.30 ([#114](#114)) ([b7c7927](b7c7927))
* support prisma up to 2.24 ([#70](#70)) ([2704ff2](2704ff2))
* support prisma up to 3 ([#147](#147)) ([0020742](0020742))
* support projecting enums ([#18](#18)) ([1c1cd13](1c1cd13))
* turn prisma client on graphql context validation into a formal check ([#180](#180)) ([72817f1](72817f1))
* Update official Prisma support up to 2.27 ([#100](#100)) ([db1010d](db1010d))
* Use JSONResolver for Json scalar ([#231](#231)) ([e4143ac](e4143ac))
* validate that peer dep requirements are met ([7976bf5](7976bf5))

### improve

* better names, auto-import friendly, jsdoc ([#12](#12)) ([6e395b9](6e395b9))
* no types namespace ([#130](#130)) ([cbe3df8](cbe3df8))
* remove support for prisma 2.17 ([e007721](e007721))

### Refactoring

* peer dep failure state labels ([03d3c64](03d3c64))
* resolver "constraints" ([#165](#165)) ([3c9991b](3c9991b))
* **tests:** use kont for tests ([#149](#149)) ([1218c7e](1218c7e))

### Documentation

* "which should I use" guide ([599b76d](599b76d))
* add jsdoc for $settings ([#90](#90)) ([98a2267](98a2267))
* add missing issue reference ([eefa884](eefa884))
* architecture diagram ([5f4970f](5f4970f)), closes [#7](#7)
* cover projecting 1-to-1 relations ([#32](#32)) ([bb70ea4](bb70ea4))
* **jsdoc:** docPropagation docs ([#55](#55)) ([5b4e5e6](5b4e5e6))
* list enum members in jsdoc ([#92](#92)) ([d806d56](d806d56))
* mention patch ver support policy ([8e61651](8e61651))
* peer deps validation ([4992741](4992741)), closes [#2](#2)
* **readme:** adjust readiness disclaimer ([0e94cea](0e94cea))
* **readme:** remove now-resolved limitation caveat ([b5fed98](b5fed98))
* setup hello world nextra site ([784705c](784705c))
* update to nextra 2.0.0 ([#232](#232)) ([fccffd5](fccffd5))
* update to nexus@^1.1 api ([#95](#95)) ([1d31a76](1d31a76))
* **website:** fix links in docs ([#144](#144)) ([abd56f2](abd56f2))

### Testing

* **e2e:** adjust kitchen-sink snapshot ([#234](#234)) ([f831369](f831369))
* **e2e:** adjust ts-node-import-error snapshot ([#230](#230)) ([e464f2f](e464f2f))
* extract hardcoded package.json declarations to fixtures ([#309](#309)) ([8cebf8a](8cebf8a))

### chore

* **deps:** update dependency graphql to v16 ([#256](#256)) ([b6678a4](b6678a4))

### Bug fixes

* add lodash as production dep ([627aa54](627aa54)), closes [#107](#107)
* bring back support for jest ([1705a54](1705a54)), closes [#137](#137)
* **deps:** update dependency @reach/skip-nav to v0.18.0 ([#300](#300)) ([1ece744](1ece744))
* **deps:** update dependency @types/node to v18.11.17 ([#324](#324)) ([86a6c4d](86a6c4d))
* **deps:** update dependency debug to ^4.3.4 ([#289](#289)) ([53a5b47](53a5b47))
* **deps:** update dependency decimal.js to ^10.4.2 ([#301](#301)) ([38d02f6](38d02f6))
* **deps:** update dependency decimal.js to ^10.4.3 ([#325](#325)) ([21cea98](21cea98))
* **deps:** update dependency dotenv to ^9.0.2 ([#326](#326)) ([fca26b0](fca26b0))
* **deps:** update dependency fs-jetpack to v5 ([#255](#255)) ([7fdb71c](7fdb71c))
* **deps:** update dependency graphql-scalars to ^1.20.1 ([#302](#302)) ([38d47d6](38d47d6))
* **deps:** update dependency kleur to ^4.1.5 ([#290](#290)) ([3c2310f](3c2310f))
* **deps:** update dependency nextra to v2.0.0-beta.41 ([#273](#273)) ([a523891](a523891))
* **deps:** update dependency nextra-theme-docs to v2.0.0-beta.41 ([#274](#274)) ([73f99bf](73f99bf))
* **deps:** update dependency semver to ^7.3.8 ([#291](#291)) ([1cbfb25](1cbfb25))
* **deps:** update dependency tslib to ^2.4.1 ([#303](#303)) ([ec603b0](ec603b0))
* **deps:** update dependency typescript to v4.9.4 ([#251](#251)) ([bb3d9d7](bb3d9d7))
* **deps:** update nextra packages to v2.0.1 ([#316](#316)) ([f3923e2](f3923e2))
* **deps:** update nextra packages to v2.0.2 ([#346](#346)) ([ee97081](ee97081))
* **deps:** update nextra packages to v2.0.3 ([#349](#349)) ([84170d1](84170d1))
* description type should not be null ([#24](#24)) ([cffc94d](cffc94d))
* **docs:** update custom settings example ([#215](#215)) ([8b56ec9](8b56ec9))
* endent via dedent introduces unexpected newlines on Windows ([#51](#51)) ([2447f56](2447f56))
* graphql peerDependency ([#233](#233)) ([0086763](0086763))
* grpahql and floggy dependencies ([#188](#188)) ([774624f](774624f))
* handle multiline prisma docs ([#134](#134)) ([f9e2f2e](f9e2f2e))
* import path on windows ([#145](#145)) ([4699b90](4699b90))
* import prisma client for instanceof check using configured path ([#62](#62)) ([b796689](b796689))
* list def typing ([#77](#77)) ([72cc944](72cc944))
* module `fs-jetpack` not found ([#11](#11)) ([4f83b26](4f83b26))
* ncc support ([#113](#113)) ([9c7e552](9c7e552))
* output mjs files for ES modules support ([#192](#192)) ([cf59aae](cf59aae))
* remove bad prisma client on ctx check & export $settings ([#60](#60)) ([60a77cd](60a77cd))
* remove colors from the the result to fix the local test ([#225](#225)) ([684fa20](684fa20))
* remove lingering console.log ([d16f763](d16f763))
* resolve path ~ when checking if can import at @prisma/client ([#104](#104)) ([8eee072](8eee072))
* scalars module only exports named exports ([#187](#187)) ([5223f9e](5223f9e))
* setup nodejs 14 for publishing job on ci ([4cbb0de](4cbb0de))
* typegen guards for undefined relations ([#126](#126)) ([a27fc1a](a27fc1a))
* update prisma client dep to 3 ([#148](#148)) ([fa58349](fa58349))
* use import id @prisma/client by default when possible ([#88](#88)) ([5599a65](5599a65))

### CI

* add pull request workflow documentation build commit status check ([#314](#314)) ([4522e1d](4522e1d))
* configure renovate config to update only the lock file for prisma packages ([#344](#344)) ([3560a41](3560a41))
* configure renovate to automerge minor and patch chore(deps) ([#284](#284)) ([2022809](2022809))
* extract tests into reusable workflow and refactor releases ([#345](#345)) ([27e99a8](27e99a8))
* fix package version ([#317](#317)) ([4e02312](4e02312))
* group nextra packages for renovate upgrades ([#315](#315)) ([21471e8](21471e8))
* ignore execa from renovate updates due exclusive esm support ([#337](#337)) ([99110c8](99110c8))
* refactor tests to use local database ([#311](#311)) ([7559995](7559995))
* reflect local database for tests in trunk github actions workflow ([#312](#312)) ([8bfd561](8bfd561))
* switch dependencies into dev dependencies in tests ([#319](#319)) ([11ee750](11ee750))
* unify trunk and pull request github actions workflow ([#313](#313)) ([6a73b25](6a73b25))
* update renovate config to use version range to ignore packages migrated to pure esm ([#343](#343)) ([23ed616](23ed616))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something is not working the way it should
Projects
None yet
Development

No branches or pull requests

3 participants