kit icon indicating copy to clipboard operation
kit copied to clipboard

feat: enable extending user tsconfig

Open robBowes opened this issue 2 years ago • 4 comments

Closes https://github.com/sveltejs/kit/issues/6868 by allowing the user to specify a root tsconfig to extend. This is useful for monorepos where the is a base tsconfig file at the root that needs to be extended.

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. All changesets should be patch until SvelteKit 1.0

robBowes avatar Dec 20 '22 17:12 robBowes

🦋 Changeset detected

Latest commit: d8b6e16e9faa3fb7f679253330e5ccc352c063ad

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Dec 20 '22 17:12 changeset-bot[bot]

@robBowes is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Dec 20 '22 17:12 vercel[bot]

Thank you. extends probably isn't the right name — it should be something tsconfig-specific.

I wonder if a more future-proof approach might be to allow the generated config to be augmented in arbitrary ways? Something like this:

// svelte.config.js
import path from 'path';

export const config = {
  kit: {
    tsconfig: (tsconfig) => {
      tsconfig.extends = path.resolve('../tsconfig.json');
    }
  }
};

Or this:

// svelte.config.js
import path from 'path';

export const config = {
  kit: {
    tsconfig: (tsconfig) => {
      return {
        ...tsconfig,
        extends: path.resolve('../tsconfig.json')
      };
    }
  }
};

I don't know if tsconfig is the best name for the option.

Rich-Harris avatar Jan 05 '23 15:01 Rich-Harris

I like the second version of Rich's proposal. I think tsconfig is the right name.

dummdidumm avatar Jan 09 '23 09:01 dummdidumm

going to close this in favour of #8606 which implements the idea above — thanks!

Rich-Harris avatar Jan 19 '23 16:01 Rich-Harris