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

fix: Make tsconfig.json path depend on cwd #7798

Closed
wants to merge 1 commit into from
Closed

fix: Make tsconfig.json path depend on cwd #7798

wants to merge 1 commit into from

Conversation

nataliemarleny
Copy link
Contributor

@nataliemarleny nataliemarleny commented Jul 8, 2019

This PR has been created to support nested directory hierarchy, where there are multiple parent directories containing the pages directory.

This is so that tsconfig.json auto-generates in the project root - TypeScript documentation.

Reference: process.cwd()

fixes: #7782

- This is to support nested directory hierarchy - where there are multiple
  parent directories containing the pages directory.
@nataliemarleny nataliemarleny changed the title Fix: Make tsconfig.json path depend on cwd fix: Make tsconfig.json path depend on cwd Jul 8, 2019
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2019

Stats from current PR

Click to expand stats
zeit/next.js canary nataliemarleny/next.js fix-7782-tsconfig-path Change
Build Duration 14.7s 14.6s -116ms
node_modules Size 45.4 MB 45.4 MB ⚠️ +80 B
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 68.8 kB 68.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB -1 B
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 222 B 224 B ⚠️ +2 B
Client pages/link Size 4.76 kB 4.76 kB
Client pages/link gzip Size 2.03 kB 2.03 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 301 B 300 B -1 B
Client main Size 24.3 kB 24.3 kB
Client main gzip Size 7.97 kB 7.97 kB -1 B
Client commons Size 183 kB 183 kB
Client commons gzip Size 59.5 kB 59.5 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Base Rendered Size 1.36 kB 1.36 kB
Build Dir Size 785 kB 785 kB
Click to expand serverless stats
zeit/next.js canary nataliemarleny/next.js fix-7782-tsconfig-path Change
Build Duration 16.2s 15.4s -730ms
node_modules Size 45.4 MB 45.4 MB ⚠️ +80 B
Total Bundle (main, webpack, commons) Size 210 kB 210 kB
Total Bundle (main, webpack, commons) gzip Size 68.8 kB 68.8 kB
Client _app Size 2.39 kB 2.39 kB
Client _app gzip Size 1.08 kB 1.08 kB
Client _error Size 8.45 kB 8.45 kB
Client _error gzip Size 3.24 kB 3.24 kB
Client pages/index Size 296 B 296 B
Client pages/index gzip Size 224 B 224 B
Client pages/link Size 4.76 kB 4.76 kB
Client pages/link gzip Size 2.03 kB 2.03 kB
Client pages/routerDirect Size 423 B 423 B
Client pages/routerDirect gzip Size 306 B 306 B
Client pages/withRouter Size 435 B 435 B
Client pages/withRouter gzip Size 300 B 300 B
Client main Size 24.3 kB 24.3 kB
Client main gzip Size 7.97 kB 7.97 kB
Client commons Size 183 kB 183 kB
Client commons gzip Size 59.5 kB 59.5 kB
Client webpack Size 1.49 kB 1.49 kB
Client webpack gzip Size 770 B 770 B
Serverless pages/link Size 338 kB 338 kB
Serverless pages/link gzip Size 86.7 kB 86.7 kB
Serverless pages/index Size Error getting size Error getting size
Serverless pages/index gzip Size Error getting size Error getting size
Serverless pages/_error Size 328 kB 328 kB
Serverless pages/_error gzip Size 84 kB 84 kB
Serverless pages/routerDirect Size 329 kB 329 kB
Serverless pages/routerDirect gzip Size 84.3 kB 84.3 kB ⚠️ +2 B
Serverless pages/withRouter Size 329 kB 329 kB
Serverless pages/withRouter gzip Size 84.2 kB 84.2 kB
Build Dir Size 2.04 MB 2.04 MB

@timneutkens
Copy link
Member

timneutkens commented Jul 8, 2019

Hey as explained here: #7782 (comment) the behavior was actually correct. @Timer mistook the reproduction steps as the reverse of what was being displayed, but the current behavior in stable is correct as there might be settings that collide for example in a monorepo environment. Hence why the file is being placed where it is.

Thank you very much for your contribution 🙏

@timneutkens timneutkens closed this Jul 8, 2019
@nataliemarleny
Copy link
Contributor Author

Until Next.js time then... 🥁🥁🥁

@nataliemarleny nataliemarleny deleted the fix-7782-tsconfig-path branch July 8, 2019 21:52
@wouterds
Copy link

wouterds commented Jul 9, 2019

I've been using TypeScript with Next.js since V8 (with a custom ./src folder) and that has been working great so far. Trying to upgrade now to Next.js V9 now but it doesn't detect my tsconfig and always generates a new file in ./src.

Any solution / workaround to this problem @timneutkens?

Screenshot-2019-07-09-at-16 26 50

@timneutkens
Copy link
Member

@wouterds the workaround is mentioned here: #7782 (comment)

@kachkaev
Copy link
Contributor

kachkaev commented Jul 9, 2019

I also have a few projects where all the source files are in src. Because Next.js pages dir cannot be customised (#4315), app's root directory has to be src too (otherwise, I can't put pages into src/pages).

As a result, configuring next() in src/server.ts becomes tricky:

const app = next({
  dir: __dirname,
  conf:
    env.NODE_ENV === "production"
      ? { distDir: "../.next", poweredByHeader: false }
      : undefined,
  dev: env.NODE_ENV !== "production",
});

After upgrading to Next 9 there some extra mess related to src/tsconfig.json and src/next-env.d.ts, which ideally belong to the repo's root.

If only we could configure pagesDir, all these problems would be gone. Next's root dir would match the repo's root dir, but the file structure could remain clean (src/(components|hooks|pages|etc.)).

Having all source in src makes search and replace much easier. I don't have to exclude .next, build and other auxiliary folders, just tell VSCode use project/src as search scope.

@wouterds
Copy link

wouterds commented Jul 9, 2019

@timneutkens Damn that's an ugly workaround. Seems a bit out of scope to this issue but I agree with @kachkaev, I'd like to have all my application code in ./src and nothing else.

@kachkaev kachkaev mentioned this pull request Jul 17, 2019
1 task
@vercel vercel locked as resolved and limited conversation to collaborators Feb 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TSConfig auto-generated generated in the wrong location
4 participants