You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an weird issue. When including a library (I was using math.js), pug.render would fail on the first attempt and succeed on all the latter attempts (within single execution). Here's my test code:
PS C:\mypath> node test.js
one
TypeError: C:\mypath\jslibraries\mathjs.pug:6
Cannot read properties of undefined (reading 'sqrt')
at eval (eval at wrap (C:\mypath\node_modules\pug-runtime\wrap.js:6:10), <anonymous>:22:62)
at template (eval at wrap (C:\mypath\node_modules\pug-runtime\wrap.js:6:10), <anonymous>:23:7)
at Object.exports.render (C:\mypath\node_modules\pug\lib\index.js:423:43)
at Object.<anonymous> (C:\mypath\test.js:20:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
two
<html><body><h1>Test Template</h1><p>math.sqrt(4) = 2</p></body></html>
/jslibraries/mathjs.pug contains minified math.js with a dash, newline and 4 spaces in front of it. Start of the file looks like this, to give you a better idea:
I have also tried prepending contents of /jslibraries/mathjs.pug to the beginning of the template, results are identical.
The only possible explanation I can see is that due to math.js being a fairly large script there is some async issue, which allowes the template to continue rendering before the included script is evaluated. I haven't had a chance to investigate further myself unfortunately.
The text was updated successfully, but these errors were encountered:
Pug Version: 3.0.2
Node Version: 16.13.0
I encountered an weird issue. When including a library (I was using
math.js
),pug.render
would fail on the first attempt and succeed on all the latter attempts (within single execution). Here's my test code:What I get as a result is:
/jslibraries/mathjs.pug
contains minifiedmath.js
with a dash, newline and 4 spaces in front of it. Start of the file looks like this, to give you a better idea:I have also tried prepending contents of
/jslibraries/mathjs.pug
to the beginning of the template, results are identical.The only possible explanation I can see is that due to
math.js
being a fairly large script there is some async issue, which allowes the template to continue rendering before the included script is evaluated. I haven't had a chance to investigate further myself unfortunately.The text was updated successfully, but these errors were encountered: