Skip to content

Commit

Permalink
Fix CLI development server
Browse files Browse the repository at this point in the history
  • Loading branch information
lemonmade committed Dec 8, 2023
1 parent cf52a94 commit 110fe32
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-zebras-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@watching/cli': patch
---

Fix development server
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"devDependencies": {
"@lemon/css": "workspace:*",
"@lemon/zest": "workspace:*",
"@lemonmade/graphql-live": "^0.4.1",
"@lemonmade/graphql-live": "^0.4.2",
"@lemonmade/remote-ui": "^0.3.3",
"@lemonmade/remote-ui-preact": "^0.4.1",
"@lemonmade/remote-ui-react": "^0.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"build": "rollup --config configuration/rollup.config.js"
},
"dependencies": {
"@lemonmade/graphql-live": "^0.4.1",
"@lemonmade/graphql-live": "^0.4.2",
"@quilted/cli-kit": "^0.1.12",
"@quilted/graphql": "^3.0.1",
"@quilted/graphql-tools": "^0.2.0",
Expand Down
9 changes: 8 additions & 1 deletion packages/cli/source/commands/develop/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import * as path from 'path';
import type {Server} from 'http';
import {emitKeypressEvents} from 'readline';
import {stat, readFile} from 'fs/promises';
import {setMaxListeners} from 'events';

import {
on,
EventEmitter,
Expand Down Expand Up @@ -75,6 +77,10 @@ export async function develop({ui, proxy}: {ui: Ui; proxy?: string}) {

await ensureRootOutputDirectory(app);
const devServer = await createDevServer(app, {ui});

// The development server adds lots of event listeners to abort controllers,
// which causes unnecessary warnings in Node.
setMaxListeners(Number.POSITIVE_INFINITY);
const result = await devServer.listen();

const localUrl = new URL(proxy ?? `http://localhost:${result.port}`);
Expand Down Expand Up @@ -313,8 +319,9 @@ async function createDevServer(app: LocalApp, {ui}: {ui: Ui}) {
return new Response(await readFile(assetPath, {encoding: 'utf8'}), {
headers: {
'Cache-Control': 'no-store',
'Timing-Allow-Origin': '*',
'Content-Type': mime.getType(assetPath)!,
'Timing-Allow-Origin': '*',
'Access-Control-Allow-Origin': '*',
},
});
} else {
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 110fe32

Please sign in to comment.