Open thinkverse opened 1 year ago
Open to contributions 🙏
Open to contributions 🙏
Uno-reverse huh? 👀 Guess I'm tinkering with this then, feel free to assign me. 👍
Adding my 2 cents, the micro-dev
-package might be redundant with the built-in live reload feature w/ Node 18.
Specifically, you can use the --watch
-flag to get an automated code reload on file changes.
Therefore, the following setup might be sufficient by leveraging the serve
-function from the lib. Ofc this only works when you opt-out of the micro
-command.
18.12.1
package.json
{
"scripts": {
"dev": "node --watch index.js",
"start": "node index.js",
}
}
index.js
import 'dotenv/config';
import http from 'node:http';
import { send, serve } from 'micro';
const handler = async (req,res) => {
// ...
};
const server = new http.Server(serve(handler));
server.listen(Number(process.env.PORT) || 8080);
I'm using such a setup in production for a small endpoint to generate OG-images at runtime: https://github.com/flaming-codes/crane-app/tree/main/services/og-img-gen
Currently
micro-dev
isn't compatible withmicro
v10.x, trying to usemicro-dev
with v10.x causes aMODULE_NOT_FOUND
error. Seemsmicro
v10.x dropped thelib
directory used in previous versions, somicro-dev
is requiringmicro/lib
andmicro/lib/handler
, which as of v10.x doesn't exist.https://github.com/vercel/micro-dev/blob/718e5911bb2a1396740eb46fbe2796c22e57bdc7/lib/serve.js#L6-L7
Any chance
micro-dev
will get a v4 that supportsmicro
v10.x?