Skip to content
Closed
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
28 changes: 1 addition & 27 deletions tools/doc/web.doc-kit.config.mjs
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
import { createRequire } from 'node:module';

Check failure on line 1 in tools/doc/web.doc-kit.config.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

'createRequire' is defined but never used
import { totalmem } from 'node:os';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';

const require = createRequire(import.meta.url);

// Gate HTML generation for high-memory machines
//
// TODO(@avivkeller): Lower the amount of memory
// we use.
const hasEnoughMemory = totalmem() > 5 * (1024 ** 3);

// The HTML generator bundles its CSS with Lightning CSS, which ships as a
// native binding that is not available on every platform we build on.
// Probe for it up front and skip HTML generation when it cannot be loaded,
// rather than failing partway through the build.
//
// TODO(@avivkeller): Fall back to WASM on machines
// without native implementations of our dependencies
const canLoadLightningCSS = () => {
try {
require('lightningcss');
return true;
} catch (error) {
console.warn(`Skipping HTML generation: unable to load lightningcss (${error.message.split('\n')[0]})`);
return false;
}
};

const fromRoot = (path) =>
pathToFileURL(join(import.meta.dirname, '..', '..', path)).href;

Expand All @@ -36,7 +10,7 @@

target: [
'legacy-json-all',
hasEnoughMemory && canLoadLightningCSS() && 'section-pages',
'legacy-html-all',
].filter(Boolean),

global: {
Expand Down
Loading