Updates
This commit is contained in:
@@ -153,7 +153,7 @@ bun run dev
|
|||||||
| Command | Description |
|
| Command | Description |
|
||||||
| -------------- | ------------------------------------------------------------------------------ |
|
| -------------- | ------------------------------------------------------------------------------ |
|
||||||
| `bunext dev` | Start the development server with HMR and file watching. |
|
| `bunext dev` | Start the development server with HMR and file watching. |
|
||||||
| `bunext build` | Bundle all pages for production. Outputs artifacts to `.bunext/public/pages/`. |
|
| `bunext build` | Bundle all pages for production. Outputs artifacts to `.bunext/public/pages/`. Resolves absolute paths in the artifact maps at the configured build root — see [BUNEXT_BUILD_ROOT_DIR](#environment-variables). |
|
||||||
| `bunext start` | Start the production server using pre-built artifacts. |
|
| `bunext start` | Start the production server using pre-built artifacts. |
|
||||||
|
|
||||||
### Running the CLI
|
### Running the CLI
|
||||||
@@ -913,10 +913,21 @@ bun run server.ts
|
|||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
| Variable | Description |
|
| Variable | Description |
|
||||||
| ------------------ | ------------------------------------------------------------------------------------------------ |
|
| ---------------------- | ------------------------------------------------------------------------------------------------ |
|
||||||
| `PORT` | Override the server port (takes precedence over config) |
|
| `PORT` | Override the server port (takes precedence over config) |
|
||||||
| `BUNEXT_PUBLIC_*` | Any env var prefixed with `BUNEXT_PUBLIC_` is exposed to the client via `window.process.env` |
|
| `BUNEXT_PUBLIC_*` | Any env var prefixed with `BUNEXT_PUBLIC_` is exposed to the client via `window.process.env` |
|
||||||
|
| `BUNEXT_BUILD_ROOT_DIR` | Read by `bunext build` only. When set, the project root's absolute path is replaced with this value inside the artifact maps (`map.json` and `ssr-bundler-ctx-map.json`) before they are written. Use it when the project will be served from a different path than the one it was built at (e.g. building in CI at `/build/app` and running in a container mounted at `/app`). |
|
||||||
|
|
||||||
|
### Build Root Directory
|
||||||
|
|
||||||
|
Artifact maps store absolute filesystem paths. By default, `bunext build` records the build machine's current working directory as the root. If the project will be deployed or served from a different location, point the maps at the runtime root instead:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
BUNEXT_BUILD_ROOT_DIR=/app bun run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Run `bunext start` from the directory matching `BUNEXT_BUILD_ROOT_DIR` so all recorded artifact paths resolve at request time. If unset, the path is left as-is and the runtime working directory must match the build directory.
|
||||||
|
|
||||||
### Public Environment Variables
|
### Public Environment Variables
|
||||||
|
|
||||||
@@ -965,8 +976,9 @@ Running `bunext build`:
|
|||||||
|
|
||||||
1. Sets `NODE_ENV=production`.
|
1. Sets `NODE_ENV=production`.
|
||||||
2. Runs ESBuild once with minification enabled.
|
2. Runs ESBuild once with minification enabled.
|
||||||
3. Writes all bundled artifacts to `.bunext/public/pages/` and the artifact map to `.bunext/public/pages/map.json`.
|
3. Writes all bundled artifacts to `.bunext/public/pages/` plus the artifact maps `.bunext/public/pages/map.json` and `.bunext/public/pages/ssr-bundler-ctx-map.json`.
|
||||||
4. Exits.
|
4. Artifact maps store absolute paths anchored at the project root. If `BUNEXT_BUILD_ROOT_DIR` is set, every occurrence of the build directory is replaced with that value so the maps point at the deploy-time location (see [Build Root Directory](#build-root-directory)).
|
||||||
|
5. Exits.
|
||||||
|
|
||||||
### Production Server
|
### Production Server
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ export default async function grabPageComponent(params) {
|
|||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
let bundledMap = global.BUNEXT_BUNDLER_CTX_MAP[file_path];
|
let bundledMap = global.BUNEXT_BUNDLER_CTX_MAP[file_path];
|
||||||
console.log("bundledMap", bundledMap);
|
|
||||||
console.log("file_path", file_path);
|
|
||||||
if (!bundledMap?.path) {
|
if (!bundledMap?.path) {
|
||||||
if (does_error_file_exist) {
|
if (does_error_file_exist) {
|
||||||
throw new Error(`Application Error. Please Check your components. ${match?.filePath} likely exists but has no exported module.`);
|
throw new Error(`Application Error. Please Check your components. ${match?.filePath} likely exists but has no exported module.`);
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@moduletrace/bunext",
|
"name": "@moduletrace/bunext",
|
||||||
"version": "1.1.10",
|
"version": "1.1.11",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -92,9 +92,6 @@ export default async function grabPageComponent(
|
|||||||
|
|
||||||
let bundledMap = global.BUNEXT_BUNDLER_CTX_MAP[file_path];
|
let bundledMap = global.BUNEXT_BUNDLER_CTX_MAP[file_path];
|
||||||
|
|
||||||
console.log("bundledMap", bundledMap);
|
|
||||||
console.log("file_path", file_path);
|
|
||||||
|
|
||||||
if (!bundledMap?.path) {
|
if (!bundledMap?.path) {
|
||||||
if (does_error_file_exist) {
|
if (does_error_file_exist) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user