Skip to content

Commit cc82a8c

Browse files
Copilotbookernath
andcommitted
Replace Cloudflare direct integration with listhen
Co-authored-by: bookernath <8922457+bookernath@users.noreply.github.com>
1 parent ad9d6a9 commit cc82a8c

File tree

5 files changed

+179
-256
lines changed

5 files changed

+179
-256
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"nx:prerelease-build": "nx run core:prerelease-build",
1414
"nx:dev": "nx run core:dev",
1515
"preinstall": "npx check-node-version --package",
16-
"postinstall": "node scripts/install-cloudflared.js || echo '⚠️ Cloudflared installation failed - tunnel features will be unavailable'",
1716
"prebuild": "rm -rf dist && rm -rf packages/test-framework/report",
1817
"build": "npm-run-all nx:build",
1918
"build:server": "http-server dist",
@@ -160,6 +159,7 @@
160159
"jest": "29.7.0",
161160
"jest-environment-jsdom": "29.7.0",
162161
"jest-junit": "^15.0.0",
162+
"listhen": "^1.9.0",
163163
"mini-css-extract-plugin": "^2.6.0",
164164
"msw": "^1.3.2",
165165
"npm-run-all": "^4.1.5",

scripts/README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
11
# Development Server Enhancement
22

3-
This directory contains enhanced development server scripts that improve the BigCommerce Checkout JS development workflow.
3+
This directory contains enhanced development server scripts that improve the BigCommerce Checkout JS development workflow using [listhen](https://github.com/unjs/listhen).
44

55
## Scripts
66

77
### dev-server.js
8-
Main development server script that combines webpack development build with HTTP server and optional Cloudflare Tunnels integration.
8+
Main development server script that combines webpack development build with HTTP server and optional tunneling via listhen.
99

1010
**Features:**
1111
- Unified command to start both webpack dev build and HTTP server
12-
- Optional HTTPS tunneling via Cloudflare Tunnels
13-
- Automatic process management and cleanup
12+
- Optional HTTPS tunneling via listhen (powered by untun)
13+
- Automatic port selection and process management
1414
- Configurable via CLI arguments or environment variables
1515
- Verbose logging mode for debugging
16-
17-
### install-cloudflared.js
18-
Automatically downloads and installs the cloudflared binary required for tunnel functionality.
19-
20-
**Features:**
21-
- Automatic download from GitHub releases
22-
- Cross-platform support (currently Linux)
23-
- Proper executable permissions setup
24-
- Graceful failure handling
16+
- Built-in static file serving with CORS support
2517

2618
### test-dev-server.js
2719
Test script to verify the development server functionality.
@@ -51,16 +43,26 @@ node scripts/dev-server.js --port 9000 --tunnel --verbose
5143
## Environment Variables
5244

5345
- `DEV_SERVER_TUNNEL`: Enable tunnel mode ('true'/'false')
54-
- `DEV_SERVER_PORT`: HTTP server port (default: 8080)
46+
- `DEV_SERVER_PORT`: HTTP server port (default: 8080, auto-selected with listhen)
5547
- `DEV_SERVER_VERBOSE`: Enable verbose logging ('true'/'false')
56-
- `CLOUDFLARED_PATH`: Custom path to cloudflared binary
48+
- `DEV_SERVER_BUILD_DIR`: Build directory to serve (default: build)
5749

5850
## Architecture
5951

60-
The dev-server.js script manages multiple processes:
52+
The dev-server.js script manages:
6153

6254
1. **Webpack Process**: Runs `npm run dev` for watch mode compilation
63-
2. **HTTP Server Process**: Runs `http-server` on the build directory
64-
3. **Cloudflared Process** (optional): Creates HTTPS tunnel
55+
2. **Listhen Server**: Elegant HTTP server with optional tunneling capabilities
56+
- Static file serving for the build directory
57+
- Automatic CORS headers
58+
- SPA routing support (fallback to index.html)
59+
- Optional HTTPS tunnel via untun/cloudflared
60+
61+
All processes are managed with proper signal handling and cleanup on exit.
62+
63+
## Benefits of Listhen Integration
6564

66-
All processes are managed with proper signal handling and cleanup on exit.
65+
- **Automatic port selection**: No more port conflicts during development
66+
- **Built-in tunneling**: Simplified tunnel setup without manual cloudflared installation
67+
- **Better error handling**: Graceful fallbacks when tunneling is unavailable
68+
- **Modern architecture**: Based on unjs ecosystem with h3 and nitro foundation

0 commit comments

Comments
 (0)