Skip to content

Commit

Permalink
fix: dev server node streaming apis (QwikDev#2547)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Jan 3, 2023
1 parent c0ff2fb commit 473a7ac
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/qwik-city/buildtime/vite/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ import {
STATIC_PATHS_ID,
} from '../../adaptors/shared/vite';
import { postBuild } from '../../adaptors/shared/vite/post-build';
import {
TextEncoderStream,
TextDecoderStream,
WritableStream,
ReadableStream,
} from 'node:stream/web';

/**
* @alpha
Expand All @@ -45,6 +51,16 @@ export function qwikCity(userOpts?: QwikCityVitePluginOptions): any {
let ssrFormat = 'esm';
let outDir: string | null = null;

// Patch Stream APIs
if (typeof globalThis.TextEncoderStream === 'undefined') {
globalThis.TextEncoderStream = TextEncoderStream;
globalThis.TextDecoderStream = TextDecoderStream;
}
if (typeof globalThis.WritableStream === 'undefined') {
globalThis.WritableStream = WritableStream as any;
globalThis.ReadableStream = ReadableStream as any;
}

const api: QwikCityPluginApi = {
getBasePathname: () => ctx?.opts.basePathname ?? '/',
getRoutes: () => {
Expand Down

0 comments on commit 473a7ac

Please sign in to comment.