Skip to content

Commit 55e1a7d

Browse files
committed
Unconditional watches + require() fallback
1 parent 22d9c23 commit 55e1a7d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/lib/output/plugins/AssetsPlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export class AssetsPlugin extends RendererComponent {
5151
}
5252

5353
if (this.customCss) {
54+
this.application.watchFile(this.customCss);
5455
if (existsSync(this.customCss)) {
55-
this.application.watchFile(this.customCss);
5656
copySync(this.customCss, join(dest, "custom.css"));
5757
} else {
5858
this.application.logger.error(
@@ -64,8 +64,8 @@ export class AssetsPlugin extends RendererComponent {
6464
}
6565

6666
if (this.customJs) {
67+
this.application.watchFile(this.customJs);
6768
if (existsSync(this.customJs)) {
68-
this.application.watchFile(this.customJs);
6969
copySync(this.customJs, join(dest, "custom.js"));
7070
} else {
7171
this.application.logger.error(

src/lib/utils/options/readers/typedoc.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ export class TypeDocReader implements OptionsReader {
9292
try {
9393
if (process.platform === "win32") {
9494
// Node on Windows doesn't support the `?` trick for
95-
// cache-busting, so we need to use require()
95+
// cache-busting, so try using require()
9696
delete require.cache[require.resolve(file)];
97-
const mod = require(file);
98-
fileContent = mod.default ?? mod;
99-
} else {
97+
try {
98+
const mod = require(file);
99+
fileContent = mod.default ?? mod;
100+
} catch (error: any) {
101+
// Only recent node can require an ESM
102+
if (error?.code !== "ERR_REQUIRE_ESM") throw error;
103+
}
104+
}
105+
if (!fileContent) {
100106
const esmPath = pathToFileURL(file).toString();
101107
// Cache-bust for reload on watch
102108
fileContent = await (

0 commit comments

Comments
 (0)