-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: dev/preview platform emulation #11730
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
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 |
antony
left a comment
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
emulatefunction that returns a set of functions for influencing the dev and preview servers. Right now, there's only aplatformfunction, which populatesevent.platform. This is useful for providing access to e.g. KV namespaces in development.TODO:
feat: implementadapter-cloudflare-workersshould also populateplatform.contextandplatform.caches, I think?adapter.emulate#11732do we need a cleanup mechanism? (e.g.not immediately necessarybindingshas adisposemethod that is never called; we just kill the process. maybe that's fine?) if so what would it look like?Future:
emulateandplatformshould be mandatory for adapters that populateplatformin 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 (/_vercelfor image optimisation), etcwrangler.toml)ValidatedKitConfig = RecursiveRequired<KitConfig>, TypeScript thinksadapter.emulateis 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 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