-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: dev/preview platform emulation #11730
Conversation
This reverts commit 4a847e4.
🦋 Changeset detectedLatest commit: 8e94317 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 |
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.
I'm sad that it's not shimulate but I'm happy for it.
This picks up @dario-piotrowicz' work in #11323 and adds the things discussed in #11323 (comment).
It allows an adapter to provide an
emulate
function that returns a set of functions for influencing the dev and preview servers. Right now, there's only aplatform
function, which populatesevent.platform
. This is useful for providing access to e.g. KV namespaces in development.TODO:
feat: implementadapter-cloudflare-workers
should also populateplatform.context
andplatform.caches
, I think?adapter.emulate
#11732do we need a cleanup mechanism? (e.g.not immediately necessarybindings
has adispose
method that is never called; we just kill the process. maybe that's fine?) if so what would it look like?Future:
emulate
andplatform
should be mandatory for adapters that populateplatform
in production? Though it wouldn't allow us to remove the?
inplatform?: App.Platform
, since it's still not populated during prerendering (unless we decide otherwise?)platform
, for e.g. adding platform-specific globals/modules, banning certain imports, special platform-specific routes (/_vercel
for image optimisation), etcwrangler.toml
)ValidatedKitConfig = RecursiveRequired<KitConfig>
, TypeScript thinksadapter.emulate
is always present. Not sure how to correct thatPlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits