diff --git a/examples/preact/component/script.mts b/examples/preact/component/script.mts index 024c5c61..deaf61a4 100644 --- a/examples/preact/component/script.mts +++ b/examples/preact/component/script.mts @@ -1 +1,3 @@ -document.getElementById('replace')!.textContent = 'Hello from JavaScript!'; +const replace = document.getElementById('replace'); +if (!replace) throw new Error('No `#replace` element.'); +replace.textContent = 'Hello from JavaScript!'; diff --git a/packages/rules_prerender/scripts.mts b/packages/rules_prerender/scripts.mts index a6d282ae..f54d6d72 100644 --- a/packages/rules_prerender/scripts.mts +++ b/packages/rules_prerender/scripts.mts @@ -18,8 +18,8 @@ export function includeScript(filePath: string, meta: ImportMeta): string { * wrapping. This is useful for templating engines which don't have easy "parse * HTML into safe type" utilities. */ -export function includeScriptAnnotation( - filePath: string, meta: ImportMeta): string { +export function includeScriptAnnotation(filePath: string, meta: ImportMeta): + string { if (!filePath.startsWith('.')) { throw new Error(`Only relative imports are supported and must start with \`./\` or \`../\`: "${filePath}".`); }