kit
kit copied to clipboard
fix: service worker base path in dev mode
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 testand lint the project withpnpm lintandpnpm 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 changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.
Edits
- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
🦋 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
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.
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 👍🏻
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 💪🏻
@eltigerchino added the tests and your comment 👍🏻
Thank you! I'll wait for another review before merging just to sanity check this.