Skip to content

Commit 43e3816

Browse files
committed
fix stats and dev bug
1 parent c8cd6ef commit 43e3816

File tree

8 files changed

+2697
-17
lines changed

8 files changed

+2697
-17
lines changed

packages/mws/src/services/setupDevServer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync, rm, rmSync, writeFileSync } from "fs";
22
// import { buildOptions } from "./context";
33
import { request } from "http";
4-
import { readFile } from "fs/promises";
4+
import { readFile, writeFile } from "fs/promises";
55
import { basename, join, relative, resolve } from "path";
66
import { checkPath, dist_resolve, SendError, SendErrorReasonData, ServerRequest, ServerRoute } from "@tiddlywiki/server";
77
import { createHash } from "crypto";
@@ -63,7 +63,7 @@ function parseMetafileEntryPoints({ entryPoints, result, publicdir }: {
6363
relative(publicdir, e[1].cssBundle!)
6464
);
6565

66-
writeFileSync(publicdir + ".json", JSON.stringify(result.metafile));
66+
6767

6868
const maxwidth = outputs.reduce((a, [b]) => Math.max(a, b.length), 0);
6969

@@ -162,9 +162,9 @@ export async function runBuildOnce({ rootdir, publicdir }: { rootdir: string; pu
162162
// errors cause this to reject
163163
const result = await esbuild.build(options);
164164
console.timeEnd(timeTag);
165-
166165
const { js, css } = parseMetafileEntryPoints({ entryPoints, result, publicdir });
167166

167+
await writeFile(publicdir + ".json", JSON.stringify(result.metafile));
168168
await generateHtml({ js, css, rootdir, publicdir });
169169

170170
return result;
@@ -196,6 +196,7 @@ async function startDevServer({ rootdir, publicdir }: { rootdir: string; publicd
196196
// errors cause this to reject
197197
const result = await ctx.rebuild();
198198
const { css, js } = parseMetafileEntryPoints({ entryPoints, result, publicdir });
199+
await writeFile(publicdir + ".json", JSON.stringify(result.metafile));
199200
await generateHtml({ js, css, rootdir, publicdir });
200201
}
201202

@@ -204,8 +205,8 @@ async function startDevServer({ rootdir, publicdir }: { rootdir: string; publicd
204205
return async function sendDevServer(state: ServerRequest, indexOptions?: { status: number, serverResponse: ServerToReactAdmin }): Promise<typeof STREAM_ENDED> {
205206
// this will rebuild the html on page load
206207
// if the build fails, esbuild will serve the error so we just ignore it
207-
208-
if (state.headers["sec-fetch-dest"] === "document") await rebuild().catch(() => { });
208+
if (state.headers["sec-fetch-dest"] === "document")
209+
await rebuild().catch((e) => { if (!(e.errors && e.warnings)) throw e; });
209210

210211
if (indexOptions) return await serveIndex({ state, publicdir, status: indexOptions.status, serverResponse: indexOptions.serverResponse });
211212

packages/react-admin/esbuild.options.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
1+
//@ts-check
22
import { basename, join, resolve } from 'node:path';
33
import { copy } from 'esbuild-plugin-copy';
44
import { existsSync } from 'node:fs';
55

66
/**
77
* @template {import('esbuild').BuildOptions} T
8-
* @param {Promise<import('esbuild').SameShape<import('esbuild').BuildContext, T>>} options
8+
* @param {import('esbuild').SameShape<import('esbuild').BuildOptions, T>} options
99
* @returns
1010
*/
1111
function optionsTyped(options) {
1212
return options;
1313
}
1414

15-
16-
export default async function({rootdir, publicdir}) {
15+
/**
16+
*
17+
* @param {{rootdir: string, publicdir: string}} param0
18+
*/
19+
export default async function({ rootdir, publicdir }) {
1720

1821
/** @type {{in: string; out: string;}[]} */
1922
const entryPoints = [
@@ -27,7 +30,7 @@ export default async function({rootdir, publicdir}) {
2730
});
2831

2932
const options = optionsTyped({
30-
entryPoints: [resolve(rootdir, 'src/main.tsx')],
33+
entryPoints,
3134
bundle: true,
3235
target: 'es2020',
3336
platform: 'browser',
@@ -43,9 +46,6 @@ export default async function({rootdir, publicdir}) {
4346
assets: [{
4447
from: [join(rootdir, "public", "**/*")],
4548
to: ['.'],
46-
}, {
47-
from: [join(rootdir, "index.html")],
48-
to: ['../' + basename(publicdir) + ".html"]
4949
}],
5050
}),
5151
]

packages/react-admin/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare global {
1313
const BUILD_VERSION: string;
1414
}
1515

16-
const theme = createTheme({
16+
const theme = creat eTheme({
1717
palette: {
1818
background: {
1919
default: "#f0f0f0",

public/.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# This is where the client build output goes.
2-
*
3-
!.gitignore
4-
!.default.html
2+
/**/
3+
/*
4+
!/.gitignore
5+
!/.default.html
6+
!/stats

0 commit comments

Comments
 (0)