Comments (4)
I think this will probably be the direction we go in. As a start, I've opened #19, which just exports (by default) Worker and createApp.
from cloudflare-worker-local.
If you want to use chokidar, the new pseudocode would look something like this
const {createApp} = require("cloudflare-worker-local")
const app = createApp(fs.readFileSync("/path/to/worker.js"), {})
app.listen(3000);
chokidhar.watch("/path/to/worker.js")
.on('change', () => fs.readFile('/path/to/worker.js', buffer => app.updateWorker(bufferToString(buffer))))
from cloudflare-worker-local.
Hmmm, Lots of food for thought. I think we should be exporting the following things:
- startServer(pathToWorker, {port}) (this automatically will updating the worker on SIGHUP)
- Worker
- startTestServer(workerContents, upstreamBehavior)
I've updated the readme, turns out watching and listening for SIGHUP is actually much easier than I thought.
from cloudflare-worker-local.
In my experience so far using cloudflare-worker-local with packagers like parcel and rollup, nodemon hasn't worked well. It leads to complex npm scripts to ensure the packager has built the worker script prior to starting cloudflare-worker-local. Similar to remy/nodemon#1297 and remy/nodemon#797.
The sighup approach seems to be ok for scenarios where the worker source code is a single javascript file.
For increased flexibility I think it would be great if the CLI related logic (process.argv
, SIGHUP
and fs.readFile(pathToWorker)
) was decoupled from the core logic (start server / update worker).
from cloudflare-worker-local.
Related Issues (20)
- Script called two times HOT 1
- Example worker modifies a Response object HOT 2
- It seems setTimeout is not working HOT 2
- request entity too large error HOT 3
- 1.9.1 release HOT 2
- Set cf config values in request headers
- Support FetchEvent.passThroughOnException() HOT 1
- Response.redirect is not a function HOT 2
- Move all program arguments into worker.toml config file HOT 9
- Refactor request handling
- Google drive index script is not working HOT 4
- npm install -g cloudflare-worker-local error HOT 3
- MINIO_PORT env var doesn't work HOT 3
- ReferenceError: process is not defined HOT 2
- Need support for byob in getReader() HOT 1
- Binary site assets not transferring correctly HOT 1
- does not support ES module worker HOT 1
- Not possible to set cf-ipcountry header, it is always DEV HOT 2
- Getting error while running google index script HOT 2
- Response body can be falsy, test throws error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloudflare-worker-local.