Skip to content

Conversation

@paperclover
Copy link
Contributor

@paperclover paperclover commented May 16, 2022

This PR implements config.kit.alias, as the proposed solution in #4734 describes.

Example usage:

const config = {
  kit: {
    alias: {
      $utils: 'src/utils'
    }
  }
};

Notes:

  • I would like some pointers/assistance with adding the new config property, I may have messed something up.
  • New tests need to be written and some existing ones need to be modified. Before I go on with writing tests, I'd like feedback to the code itself.
  • We should consider deprecating/removing config.kit.files.lib and having it be config.kit.alias.$lib, but $lib is special for packaging and other situations.

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

@changeset-bot
Copy link

changeset-bot bot commented May 16, 2022

🦋 Changeset detected

Latest commit: ab2b77a

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 Patch

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

@paperclover paperclover changed the title implement basic alias config (closes #4734) implement config.kit.alias May 16, 2022
Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

looks pretty good to me. main things I see are the failing tests and need to update the documentation

@paperclover
Copy link
Contributor Author

looks pretty good to me. main things I see are the failing tests and need to update the documentation

i just merged in your change requests, and i'll get to tests and docs today.

@benmccann benmccann added the feature / enhancement New feature or request label May 17, 2022
@paperclover
Copy link
Contributor Author

paperclover commented May 17, 2022

some notes/questions

  1. is this doc page alright? link
  2. should there be any extra validation on alias key and value? i havent tested much malformed input on them (such as an absolute path).
  3. do we need more tests besides fixing the broken ones? im not 100% familiar with the codebase so if you want tests for making sure aliases do their job, id need some pointers.
  4. should the $lib alias be moved into this new config? i feel like it should but i also don't want to break anything, or put too much in one commit.

@Rich-Harris
Copy link
Member

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature / enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants