While testing various modules on Bun, I came across a failure with Nunjucks. With a simple inline template and code that runs fine with Nunjucks on Node.js, it fails with the above message.
import nunjucks from 'nunjucks';
let people = ['geddy', 'neil', 'alex'];
const template = nunjucks.compile('Hello {{ username }}');
console.log(template);
console.log(nunjucks.renderString('{{ people | join(", ") }}', { people: people }));
console.log(nunjucks.renderString(`
<ul id="products">
{% for person in people %}
<li>{{ person }}</li>
{% endfor %}
</ul>
`, { people: people }));
Simple. With Node.js, the output is what you'd expect from the templates. It was interesting to look at the compiled template object after having used Nunjucks for a couple years.
$ bun nunjucks.mjs
20 | _inheritsLoose(FileSystemLoader, _Loader);
21 |
22 | function FileSystemLoader(searchPaths, opts) {
23 | var _this;
24 |
25 | _this = _Loader.call(this) || this;
^
TypeError: _Loader.call is not a function. (In '_Loader.call(this)', '_Loader.call' is undefined)
at new FileSystemLoader (/home/david/Projects/akasharender/akashacms-perftest/node_modules/nunjucks/src/node-loaders.js:25:12)
at configure (/home/david/Projects/akasharender/akashacms-perftest/node_modules/nunjucks/index.js:41:21)
at compile (/home/david/Projects/akasharender/akashacms-perftest/node_modules/nunjucks/index.js:82:6)
at /home/david/Projects/akasharender/akashacms-perftest/bench/nunjucks.mjs:5:17
I inserted to console.log statements:
For _Loader this was output: [Function: Loader]
For _Loader.call this was output: undefined -- which agrees with the error message
While testing various modules on Bun, I came across a failure with Nunjucks. With a simple inline template and code that runs fine with Nunjucks on Node.js, it fails with the above message.
Simple. With Node.js, the output is what you'd expect from the templates. It was interesting to look at the compiled template object after having used Nunjucks for a couple years.
I inserted to
console.log
statements:_Loader
this was output:[Function: Loader]
_Loader.call
this was output:undefined
-- which agrees with the error message