kit icon indicating copy to clipboard operation
kit copied to clipboard

fix: service worker base path in dev mode

Open TorstenDittmann opened this issue 1 year ago • 6 comments

Using a service worker in dev mode was not respecting the configured base path and it was missing from the filesystem import.

This PR prepends the base path before the filesystem import.

In a case with the basepath of /console, http://localhost:3000/console/service-worker.js will resolve now to:

- import '/@fs/Users/torstendittmann/Documents/GitHub/appwrite/console/src/service-worker.ts';
+ import '/console/@fs/Users/torstendittmann/Documents/GitHub/appwrite/console/src/service-worker.ts';

I didn't find a good place to add a test though. I could add another packages/kit/test/apps/dev-only test suite with a base path, but I'd rather wait on some feedback if this is the right choice 👍🏻

Created a PoC of what the tests could look like => https://github.com/TorstenDittmann/kit/compare/fix-service-worker-base-path...fix-service-worker-base-path-tests

More context to this issue can be found here => https://github.com/sveltejs/kit/issues/12039


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

  • [x] 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
  • [x] This message body should clearly illustrate what problems it solves.
  • [ ] Ideally, include a test that fails without this PR but passes with it.

Tests

  • [x] Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • [x] 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:.

Edits

  • [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

TorstenDittmann avatar Aug 14 '24 16:08 TorstenDittmann

🦋 Changeset detected

Latest commit: 28294e3dc43e0a7fcf7bfdddc931eecf408f5604

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

changeset-bot[bot] avatar Aug 14 '24 16:08 changeset-bot[bot]

Thanks for the PR! Is this test suite a good fit for your test? https://github.com/sveltejs/kit/blob/13fb7f51a1eefd473f56cf4073ed5a48140a996b/packages/kit/test/apps/options-2/test/test.js#L58 I noticed it also has a test with a base path and a service worker.

teemingc avatar Oct 09 '24 09:10 teemingc

Thanks for the PR! Is this test suite a good fit for your test?

https://github.com/sveltejs/kit/blob/13fb7f51a1eefd473f56cf4073ed5a48140a996b/packages/kit/test/apps/options-2/test/test.js#L58 I noticed it also has a test with a base path and a service worker.

Hey, thank you for the review. Saw it a bit late :-) will go through it 👍🏻

TorstenDittmann avatar Oct 16 '24 13:10 TorstenDittmann

Thanks for the PR! Is this test suite a good fit for your test?

https://github.com/sveltejs/kit/blob/13fb7f51a1eefd473f56cf4073ed5a48140a996b/packages/kit/test/apps/options-2/test/test.js#L58 I noticed it also has a test with a base path and a service worker.

The tests are skipped in dev mode 👍🏻 let me just add relevant test cases there 💪🏻

TorstenDittmann avatar Oct 16 '24 13:10 TorstenDittmann

@eltigerchino added the tests and your comment 👍🏻

TorstenDittmann avatar Oct 16 '24 14:10 TorstenDittmann

Thank you! I'll wait for another review before merging just to sanity check this.

teemingc avatar Oct 17 '24 01:10 teemingc