Skip to content

Commit

Permalink
fix: CF pages polyfill also when shimmed (QwikDev#5512)
Browse files Browse the repository at this point in the history
* fix: polyfill also when shimmed

* chore: add comment to explain polyfill

* chore: Giorgio's feedback
  • Loading branch information
mpeg committed Dec 1, 2023
1 parent 9784ec1 commit 5e0249a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/qwik-city/middleware/cloudflare-pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import { setServerPlatform } from '@builder.io/qwik/server';

/** @public */
export function createQwikCity(opts: QwikCityCloudflarePagesOptions) {
if (typeof globalThis.TextEncoderStream === 'undefined') {
try {
// https://developers.cloudflare.com/workers/configuration/compatibility-dates/#streams-constructors
// this will throw if CF compatibility_date < 2022-11-30
new globalThis.TextEncoderStream();
} catch (e) {
(globalThis as any).TextEncoderStream = TextEncoderStream;
}
const qwikSerializer = {
Expand Down

0 comments on commit 5e0249a

Please sign in to comment.