From c7e9ca93a0a0c3873ce4d26e4b8c8268c9fc7cc0 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Thu, 6 Jun 2024 21:32:15 -0700 Subject: [PATCH] chore: update README --- README.md | 11 +++++++++++ exe-src/start.ts | 48 ++++++++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 64a1914..0f43334 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,14 @@ which could serve interestingly. ![](./assets/explainer.png) > This isn't a great visual explainer. I wrote it quickly [while live on Twitch](https://twitch.tv/crutchcorn). + +## Unfinished Warning + +This project is _mostly_ finished but is not tested, as we are blocked by this issue: + +https://github.com/nodejs/single-executable/issues/100 + +### Will it work? + +I'm not sure, because our `fs` patch supposedly can read from `Buffer`s like `sea.getAsset` returns, however this **really heavily** expects +Next.js to not introspect the `dir` path as if it were a string in any way outside of using the `fs` APIs. I'm doubtful this is the case, but I could be wrong. diff --git a/exe-src/start.ts b/exe-src/start.ts index 9cb80df..e0c2787 100644 --- a/exe-src/start.ts +++ b/exe-src/start.ts @@ -1,27 +1,23 @@ -// import 'next/dist/server/lib/cpu-profile' -// import {startServer} from 'next/dist/server/lib/start-server' -// import {printAndExit} from 'next/dist/server/lib/utils' -// import {getProjectDir} from 'next/dist/lib/get-project-dir' -// import {getReservedPortExplanation, isPortIsReserved,} from 'next/dist/lib/helpers/get-reserved-port' -// -// const dir = getProjectDir(directory) -// const host = "locahost" -// const port = 3000 -// let keepAliveTimeout = true -// -// if (isPortIsReserved(port)) { -// printAndExit(getReservedPortExplanation(port), 1) -// } -// -// await startServer({ -// dir, -// isDev: false, -// hostname: host, -// port, -// keepAliveTimeout, -// }) -// +import 'next/dist/server/lib/cpu-profile' +import {startServer} from 'next/dist/server/lib/start-server' +import {printAndExit} from 'next/dist/server/lib/utils' +import {getReservedPortExplanation, isPortIsReserved,} from 'next/dist/lib/helpers/get-reserved-port' -// TODO: Pass this to the Next server above and start server with patched `fs` module -// import { getAsset } from 'node:sea'; -// const blob = getAsset('bundle.asar'); +const host = "locahost" +const port = 3000 +let keepAliveTimeout = 300 + +if (isPortIsReserved(port)) { + printAndExit(getReservedPortExplanation(port), 1) +} + +import { getAsset } from 'node:sea'; +const dir = getAsset('bundle.asar') as never; + +await startServer({ + dir, + isDev: false, + hostname: host, + port, + keepAliveTimeout, +}) -- 2.51.2