-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: don't bundle @sveltejs/kit
#13971
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
Conversation
🦋 Changeset detectedLatest commit: fbf7871 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
| import { Readable } from 'node:stream'; | ||
| import * as set_cookie_parser from 'set-cookie-parser'; | ||
| import { SvelteKitError } from '../../runtime/control.js'; | ||
| import { SvelteKitError } from '../internal/index.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be the package import rather than relative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really matter as long as you don't use relative imports between bundled and unbundled modules
| @@ -1,4 +1,4 @@ | |||
| import { HttpError, Redirect, ActionFailure } from '../runtime/control.js'; | |||
| import { HttpError, Redirect, ActionFailure } from './internal/index.js'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
|
There's a type checking issue in the Kit package. Since we import from the Kit package namespace, we're also importing the generated types. This causes the EDIT: actually there's probably another reason since we've already been importing from the Kit package namespace before this without issues EDIT 2: ok it seems the issue only happens if we import from the Kit package namespace in a unit test file. |
|
I think you can also fix it (and I think that's preferable) to add a path alias for that namespace import (we already have one for the root for the same reason) |
Oh nice. I didn't know you could override packages like that. I've changed it to use the path alias now. |
likely broken by sveltejs/kit#13971
likely broken by sveltejs/kit#13971
This was an accidental removal in #13971, we still need it: Without this SvelteKit will be prebundled on the client, which means we end up with two versions of Redirect etc. Also see #5952 (comment) No test because it's only testeable when SvelteKit is resolved as a npm package, Vite seems to do resolving slightly different within a monorepo
This was an accidental removal in #13971, we still need it: Without this SvelteKit will be prebundled on the client, which means we end up with two versions of Redirect etc. Also see #5952 (comment) No test because it's only testeable when SvelteKit is resolved as a npm package, Vite seems to do resolving slightly different within a monorepo
closes #13894
We've had a long-running battle with
instanceofchecks inside the codebase: when you callerror(...)orredirect(...)in your code, SvelteKit needs to check that the thrown object is an instance ofHttpErrororRedirect.Recently we tried #13843, which attempts to ensure that any of your dependencies that depend on
@sveltejs/kitare bundled, since@sveltejs/kitis also bundled, and that means that your app will only have a single copy of SvelteKit (and classes likeHttpError) in memory. But that has problems of its own.This PR goes in the opposite direction, by making it possible to not bundle
@sveltejs/kitin the first place. Aside from being a lot simpler, this feels more correct. The one compromise is that we need to expose a@sveltejs/kit/internalpackage so that classes can be shared between code in@sveltejs/kitand code in$app/...(which is bundled, necessarily, as it relies on virtual modules etc). But because we're controlling howtypes/index.d.tsis generated, this module is invisible to TypeScript (and therefore won't show up in import autocomplete suggestions etc).Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
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