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: tsconfig includes being a level higher than they should be #8880

Merged
merged 6 commits into from
Feb 7, 2023

Conversation

gtm-nayan
Copy link
Contributor

@gtm-nayan gtm-nayan commented Feb 4, 2023

closes #8872
closes #8898

  • removed project_relative cause the paths are already resolved to be absolute when the config is processed
  • also fixes the other problem mentioned in tsconfig contains duplicate include entries #8872 (comment), which was caused by project_relative returning an empty string for any folder directly inside the project directory, so config_relative was pointing to /**/*.js
  • had to add a special case for src because otherwise it'd be a breaking change

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! I adjusted the v2 comment because frankly I don't think we can remove that logic for v2, and deduplicated paths some more

.changeset/happy-boats-shave.md Outdated Show resolved Hide resolved
packages/kit/src/core/sync/write_tsconfig.js Outdated Show resolved Hide resolved
packages/kit/src/core/sync/write_tsconfig.spec.js Outdated Show resolved Hide resolved
@wvhulle
Copy link

wvhulle commented Feb 6, 2023

For me it seems like there are multiple extra levels, not just one. Is this also solved with this pull request?

@gtm-nayan
Copy link
Contributor Author

Yep, see second bullet from the PR description.

@wvhulle
Copy link

wvhulle commented Feb 7, 2023

It is not solved yet on master branch. Do you want to see a reproduction?

@wvhulle
Copy link

wvhulle commented Feb 7, 2023

[path.resolve('src')].filter((dir) => {
    const relative = path.relative(path.resolve('src'), dir);
    return !relative || relative.startsWith('..');
});

always returns src even though it doesn't exist. Is this intended?

@wvhulle
Copy link

wvhulle commented Feb 7, 2023

const config = {
		preprocess: vitePreprocess(),

		kit: {
			env: { dir: "../" },
			alias: {
				$lib: "../lib"
			},
			files: {
				assets: "../static",
				hooks:  { client: './hooks.client', server: './hooks.server' },
				lib: "../lib",
				params: "../lib/params",
				routes: './routes',
				appTemplate: `../static/app.html`
			},
			outDir: `/home/[omitted]/cache/dev/main/kit`,
			adapter: adapter({ out: "build" })
		}
	};

generates

   "include": [
   	"ambient.d.ts",
   	"./types/**/$types.d.ts",
   	"../../../../main/vite.config.ts",
   	"../../../../../../../../../**/*.js",
   	"../../../../../../../../../**/*.ts",
   	"../../../../../../../../../**/*.svelte",
   	"../../../../**/*.js",
   	"../../../../**/*.ts",
   	"../../../../**/*.svelte",
   	"../../../../main/tests/**/*.js",
   	"../../../../main/tests/**/*.ts",
   	"../../../../main/tests/**/*.svelte"
   ],

@wvhulle
Copy link

wvhulle commented Feb 7, 2023

After going through your code it seems like the problem is not in the code adding the includes but in the parsing of the config.

A reproduction is in https://github.com/wvhulle/sveltekit-bug-write-tsconfig.json

@wvhulle
Copy link

wvhulle commented Feb 7, 2023

Sorry, I didn't properly update to the latest commit. I now see it works. Reverting to version 1.5.0 brings back the problem. My only remark is that the src is included even though. How do I make sure the kit version i reference is the one from github? I used pnpm add -D github:sveltejs/kit but then I had to manually find the path of the function sveltekit in node_modules.

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