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

nextjs-app compilation error and warning #2969

Closed
jtlapp opened this issue Nov 29, 2022 · 2 comments
Closed

nextjs-app compilation error and warning #2969

jtlapp opened this issue Nov 29, 2022 · 2 comments

Comments

@jtlapp
Copy link

jtlapp commented Nov 29, 2022

I got this error and warning from the nextjs-app v3.58.0 build:

➤ YN0000: [nextjs-app]: info  - Loaded env from /Users/joe/repos/nounzoo/apps/nextjs-app/.env
➤ YN0000: [nextjs-app]: notice- Will transpile [ky]
➤ YN0000: [nextjs-app]: info  - Linting and checking validity of types...
➤ YN0000: [nextjs-app]: warn  - You have enabled experimental features (outputFileTracingRoot, externalDir) in next.config.mjs.
➤ YN0000: [nextjs-app]: warn  - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
➤ YN0000: [nextjs-app]: 
➤ YN0000: [nextjs-app]: 
➤ YN0000: [nextjs-app]: Failed to compile.
➤ YN0000: [nextjs-app]: 
➤ YN0000: [nextjs-app]: ./src/backend/graphql/graphqlSchema.ts
➤ YN0000: [nextjs-app]: 4:1  Error: `@nounzoo/db-main-prisma` import should occur before import of `@pothos/core`  import/order
➤ YN0000: [nextjs-app]: 
➤ YN0000: [nextjs-app]: ./src/features/home/blocks/hero/HeroBlock.tsx
➤ YN0000: [nextjs-app]: 10:11  Warning: 't' is assigned a value but never used.  @typescript-eslint/no-unused-vars
➤ YN0000: [nextjs-app]: 
➤ YN0000: [nextjs-app]: info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
➤ YN0000: [nextjs-app]: Process exited (exit code 1), completed in 8s 902ms

I was able to eliminate the error by moving the following line to the top of the file graphqlSchema.ts:

import type { DbMainPrismaTypes } from '@nounzoo/db-main-prisma';

And by removing the following two lines from HeroBlock.tsx:

import { useTranslation } from 'next-i18next';

const { t } = useTranslation(['home', 'common']);

Would you like a pull request?

@belgattitude
Copy link
Owner

Thanks, actually it's not a bug. By changing @your-org/db-main-prisma into @nounzoo/db-main-prisma, the enforced order change.

It's enforced in the import/order, see

Of course it's an example, up to you to decide if you want to have this rule.

Otherwise good tips:

  • Command line: yarn lint --fix / or globally yarn g:lint --fix
  • Note that this is done automatically for you when you commit (lint-staged/husky)

And of course you can setup your ide (vscode/webstorm...) to automatically run the linter on save. If you use the example config, it should be done for you:

"source.fixAll.eslint": true

@jtlapp
Copy link
Author

jtlapp commented Dec 2, 2022

Okay, thank you. FYI, I've decided to use your monorepo example and another as references for creating my own, as there's more complexity than I'd like at the start of a project. I'd like to extend the solution as I feel the need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants