Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exposing configs that are not configurable #682

Merged
merged 17 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions packages/waku/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as dotenv from 'dotenv';
import type { Config } from './config.js';
import { runner } from './lib/hono/runner.js';
import { build } from './lib/builder/build.js';
import { DIST_ENTRIES_JS, DIST_PUBLIC } from './lib/builder/constants.js';

const require = createRequire(new URL('.', import.meta.url));

Expand Down Expand Up @@ -120,19 +121,15 @@ async function runBuild() {
});
}

async function runStart({
distDir = 'dist',
entriesJs = 'entries.js',
publicDir = 'public',
}) {
async function runStart({ distDir = 'dist' }) {
const loadEntries = () =>
import(pathToFileURL(path.resolve(distDir, entriesJs)).toString());
import(pathToFileURL(path.resolve(distDir, DIST_ENTRIES_JS)).toString());
const app = new Hono();
app.use('*', serveStatic({ root: path.join(distDir, publicDir) }));
app.use('*', serveStatic({ root: path.join(distDir, DIST_PUBLIC) }));
app.use('*', runner({ cmd: 'start', loadEntries, env: process.env as any }));
app.notFound((c) => {
// FIXME better implementation using node stream?
const file = path.join(distDir, publicDir, '404.html');
const file = path.join(distDir, DIST_PUBLIC, '404.html');
if (existsSync(file)) {
return c.html(readFileSync(file, 'utf8'), 404);
}
Expand Down
36 changes: 0 additions & 36 deletions packages/waku/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface Config {
basePath?: string;
/**
* The source directory relative to root.
* This will be the actual root in the development mode.
* Defaults to "src".
*/
srcDir?: string;
Expand All @@ -21,35 +20,6 @@ export interface Config {
*/
distDir?: string;
/**
* The public directory relative to distDir.
* It's different from Vite's build.publicDir config.
* Defaults to "public".
*/
publicDir?: string;
/**
* The assets directory relative to distDir and publicDir.
* Defaults to "assets".
*/
assetsDir?: string;
/**
* The SSR directory relative to distDir.
* Defaults to "ssr".
*/
ssrDir?: string;
/**
* The client main file relative to srcDir.
* The extension should be `.js`,
* but resolved with other extensions in the development mode.
* Defaults to "main.js".
*/
mainJs?: string;
/**
* The entries.js file relative to srcDir or distDir.
* The extension should be `.js`,
* but resolved with other extensions in the development mode.
* Defaults to "entries.js".
*/
entriesJs?: string;
/**
* The list of directries to preserve server module structure.
* Relative to srcDir.
Expand All @@ -62,12 +32,6 @@ export interface Config {
* Defaults to "private".
*/
privateDir?: string;
/**
* The serve.js file relative distDir.
* This file is used for deployment.
* Defaults to "serve.js".
*/
serveJs?: string;
/**
* Prefix for HTTP requests to indicate RSC requests.
* Defaults to "RSC".
Expand Down
Loading
Loading