-
Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
This is a follow-up issue from #759 (comment) and may be related to: #757 .
When I include TeX in a notebook and try an :ssr
build with :package :directory
, I get an error that says “document is not defined”. As in issue 757, it doesn’t happen with :package :single-file
or without the ssr option.
clerk-ssr-test % clojure -X:clerk
👷🏼 Clerk is building 1 notebooks…
🧐 Parsing… Done in 18,129ms. ✅
🔬 Analyzing… Done in 34,085ms. ✅
🔨 Building "notebooks/foo.clj"… Done in 21,957ms. ✅
🧱 Server Side Rendering… Execution error (ExceptionInfo) at nextjournal.clerk.builder/ssr! (builder.clj:223).
Clerk ssr! failed
<div class="fixed w-full z-20 top-0 left-0 w-full"></div><div class="flex"><div class="fixed top-2 left-2 md:left-auto md:right-2 z-10"><div class="relative dark-mode-toggle"><button class="text-slate-400 hover:text-slate-600 dark:hover:text-white cursor-pointer"><svg class="w-5 h-5 md:w-4 md:h-4" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="11.9998" cy="11.9998" r="5.75375" fill="currentColor"></circle><g><circle cx="3.08982" cy="6.85502" r="1.71143" transform="rotate(-60 3.08982 6.85502)" fill="currentColor"></circle><circle cx="3.0903" cy="17.1436" r="1.71143" transform="rotate(-120 3.0903 17.1436)" fill="currentColor"></circle><circle cx="12" cy="22.2881" r="1.71143" fill="currentColor"></circle><circle cx="20.9101" cy="17.1436" r="1.71143" transform="rotate(-60 20.9101 17.1436)" fill="currentColor"></circle><circle cx="20.9101" cy="6.8555" r="1.71143" transform="rotate(-120 20.9101 6.8555)" fill="currentColor"></circle><circle cx="12" cy="1.71143" r="1.71143" fill="currentColor"></circle></g></svg></button></div></div><div class="flex-auto w-screen scroll-container"><div class="flex flex-col items-center notebook-viewer flex-auto" style="margin-left:0px"><div class="viewer w-full max-w-prose px-8 not-prose mt-3"><div class="mb-8 text-xs sans-serif text-slate-400"><span>Generated with <a href="https://clerk.vision" class="font-medium border-b border-dotted border-slate-300 hover:text-indigo-500 hover:border-indigo-500 dark:border-slate-500 dark:hover:text-white dark:hover:border-white transition">Clerk</a> from <a class="font-medium border-b border-dotted border-slate-300 hover:text-indigo-500 hover:border-indigo-500 dark:border-slate-500 dark:hover:text-white dark:hover:border-white transition">notebooks/foo.clj</a></span></div></div><div data-block-id="user/anon-expr-5dsiYMRgYd5pbG5TCNNs11twNYBwsy-code" class="viewer code-viewer w-full max-w-wide"><div class="cm-editor"><cm-scroller><div class="cm-content whitespace-pre"><div style="padding:0;line-height:1.6;font-size:15px;font-family:"Fira Mono", monospace" class="cm-line">(<span class="cmt-keyword">ns</span> <span class="cmt-variableName">foo</span></div><div style="padding:0;line-height:1.6;font-size:15px;font-family:"Fira Mono", monospace" class="cm-line"> (<span class="cmt-atom">:require</span> [nextjournal.clerk <span class="cmt-atom">:as</span> clerk]))</div></div></cm-scroller></div></div><div data-block-id="foo/markdown-5dshM3hcEoFK4LJksZVmFuxPfzFoq7" class="viewer markdown-viewer w-full max-w-prose px-8"><h1 id="tex-test">TeX Test</h1><p>inline: <!-- -->Loading...</p><p>function call:</p></div><div data-block-id="foo/anon-expr-5dsJKaV9F7b2js1tEK1BiLiGGozqzo-code" class="viewer code-viewer w-full max-w-wide"><div class="cm-editor"><cm-scroller><div class="cm-content whitespace-pre"><div style="padding:0;line-height:1.6;font-size:15px;font-family:"Fira Mono", monospace" class="cm-line">(<span class="cmt-keyword">clerk/tex</span> <span class="cmt-string">"</span><span class="cmt-string">x^2</span><span class="cmt-string">"</span>)</div></div></cm-scroller></div></div><div class="result-viewer viewer katex-viewer w-full max-w-prose px-8" data-block-id="foo/anon-expr-5dsJKaV9F7b2js1tEK1BiLiGGozqzo-result-1"><div class="relative"><div class="overflow-x-auto">Loading...</div></div></div></div></div></div>
file:///private/var/folders/7n/gm331n5d4sd5c8dh6lbq67w00000gn/T/7c2fb2d5-9283-4c12-a6f2-86c26dbed65d5891955662222770555.mjs:2306
(Db=Db.slice(2));Db=Oa.test(Db)?Db:`${Db}.js`;break a}Db=void 0}return`${bb}${ob}@${Fb}/${Db||"index.js"}`}}function x(bb){function cb(Fb){if(typeof Fb!=="string")return Fb;let Jb=ob.get(Fb);Jb||ob.set(Fb,Jb=new Promise((fc,Rb)=>{const J=document.createElement("script");J.onload=()=>{try{fc(V.pop()(sb(Fb)))}catch(F){Rb(new Aa("invalid module"))}J.remove()};J.onerror=()=>{Rb(new Aa("unable to load module"));J.remove()};J.async=!0;J.src=Fb;window.define=X;document.head.appendChild(J)}));return Jb}function sb(Fb){return Jb=>
^
ReferenceError: document is not defined
at file:///private/var/folders/7n/gm331n5d4sd5c8dh6lbq67w00000gn/T/7c2fb2d5-9283-4c12-a6f2-86c26dbed65d5891955662222770555.mjs:2306:239
at new Promise (<anonymous>)
at cb (file:///private/var/folders/7n/gm331n5d4sd5c8dh6lbq67w00000gn/T/7c2fb2d5-9283-4c12-a6f2-86c26dbed65d5891955662222770555.mjs:2306:209)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Node.js v22.17.1
----- Native stack trace -----
1: 0x104631008 node::errors::TriggerUncaughtException(v8::FunctionCallbackInfo<v8::Value> const&) (.cold.1) [/usr/local/bin/node]
2: 0x10286786c node::errors::Initialize(v8::Local<v8::Object>, v8::Local<v8::Value>, v8::Local<v8::Context>, void*) [/usr/local/bin/node]
3: 0x10346af98 Builtins_CallApiCallbackGeneric [/usr/local/bin/node]
4: 0x103468ef0 Builtins_InterpreterEntryTrampoline [/usr/local/bin/node]
5: 0x1097539b0
6: 0x1096f99ec
7: 0x103466c0c Builtins_JSEntryTrampoline [/usr/local/bin/node]
8: 0x1034668f4 Builtins_JSEntry [/usr/local/bin/node]
9: 0x102ba2fbc v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/usr/local/bin/node]
10: 0x102ba2918 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*) [/usr/local/bin/node]
11: 0x102a51f04 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [/usr/local/bin/node]
12: 0x102765a80 node::InternalCallbackScope::Close() [/usr/local/bin/node]
13: 0x102765cc4 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context, v8::Local<v8::Value>) [/usr/local/bin/node]
14: 0x10277ba7c node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/usr/local/bin/node]
15: 0x10296d5f0 node::(anonymous namespace)::CompressionStream<node::(anonymous namespace)::BrotliDecoderContext>::AfterThreadPoolWork(int) [/usr/local/bin/node]
16: 0x102827e68 node::ThreadPoolWork::ScheduleWork()::'lambda'(uv_work_s*, int)::operator()(uv_work_s*, int) const [/usr/local/bin/node]
17: 0x102827d1c node::ThreadPoolWork::ScheduleWork()::'lambda'(uv_work_s*, int)::__invoke(uv_work_s*, int) [/usr/local/bin/node]
18: 0x103442c44 uv__work_done [/usr/local/bin/node]
19: 0x103446974 uv__async_io [/usr/local/bin/node]
20: 0x10345ad0c uv__io_poll [/usr/local/bin/node]
21: 0x103446edc uv_run [/usr/local/bin/node]
22: 0x1027664f4 node::SpinEventLoopInternal(node::Environment*) [/usr/local/bin/node]
23: 0x1028b0e74 node::NodeMainInstance::Run() [/usr/local/bin/node]
24: 0x102821008 node::Start(int, char**) [/usr/local/bin/node]
25: 0x19ba9eb4c start [/usr/lib/dyld]
----- JavaScript stack trace -----
1: throwUnhandledRejectionsMode (node:internal/process/promises:394:5)
2: processPromiseRejections (node:internal/process/promises:475:17)
3: processTicksAndRejections (node:internal/process/task_queues:106:32)
Full report at:
/var/folders/7n/gm331n5d4sd5c8dh6lbq67w00000gn/T/clojure-15209822692431655876.edn
Test deps setup:
{:paths ["notebooks"]
:deps {org.clojure/clojure {:mvn/version "1.12.1"} ; same with 1.11.1
;; SHA of latest commit
io.github.nextjournal/clerk {:git/sha "b3cb7915d9a31f65087fb06fbf7e9cfc92cc4905"}}
:aliases
{:clerk
{:exec-fn nextjournal.clerk/build!
:exec-args {:paths ["notebooks/foo.clj"]
:ssr true
:package :directory
:out-path "./out"}}}}
Test namespace:
(ns foo
(:require [nextjournal.clerk :as clerk]))
;; # TeX Test
;; inline: $x^2$
;; function call:
(clerk/tex "x^2")
Metadata
Metadata
Assignees
Labels
No labels