js-kyle / connect-assets

A Rails-style asset pipeline for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error using js or jsInline helper

dev-bjoern opened this issue · comments

I am getting following error using the js or jsInline helper in my template, but only with NODE_ENV=production:

string must be a string, Buffer, or ArrayBuffer

The css or cssInline helpers work without problem...

My configuration:

app.use(assets({
servePath: '/static',
helperContext: hbs.handlebars.helpers,
fingerprinting: true,
build: false,
bundle: false,
paths: [
'dist/static'
]
}))

And in handlebars template simply:

{{{js 'app.js'}}}

Error stack:

"stack":"TypeError: string must be a string, Buffer, or ArrayBuffer\n
at Function.byteLength (buffer.js:481:11)\n
at new BundledAsset (/MYAP/node_modules/mincer/lib/mincer/assets/bundled.js:123:24)\n
at Index.Base.buildAsset (/MYAP/node_modules/mincer/lib/mincer/base.js:535:12)\n
at /MYAP/node_modules/mincer/lib/mincer/index.js:141:26\n
at Index.module.exports.cacheAsset (/MYAP/node_modules/mincer/lib/mincer/helpers/caching.js:52:12)\n
at Index.buildAsset (/MYAP/node_modules/mincer/lib/mincer/index.js:140:33)\n
at Index.Base.findAsset (/MYAP/node_modules/mincer/lib/mincer/base.js:348:15)\n
at Index.findAsset (/MYAP/node_modules/mincer/lib/mincer/index.js:114:22)\n
at Environment.findAsset (/MYAP/node_modules/mincer/lib/mincer/environment.js:137:21)\n
at module.exports.Assets.getAssetByPath (/MYAP/node_modules/connect-assets/lib/assets.js:230:29)\n
at Object. (/MYAP/node_modules/connect-assets/lib/assets.js:180:22)\n
at eval (eval at createFunctionContext (/MYAP/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:257:23), :6:93)\n
at Object.prog [as fn] (/MYAP/node_modules/handlebars/dist/cjs/handlebars/runtime.js:221:12)\n
at Object. (/MYAP/node_modules/handlebars/dist/cjs/handlebars/helpers/if.js:19:22)\n
at Object.eval [as main] (eval at createFunctionContext (/MYAP/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:257:23), :6:32)\n
at main (/MYAP/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)\n
at ret (/MYAP/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12)\n
at ret (/MYAP/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:526:21)\n
at Object.invokePartial (/MYAP/node_modules/handlebars/dist/cjs/handlebars/runtime.js:283:12)\n
at Object.invokePartialWrapper [as invokePartial] (/MYAP/node_modules/handlebars/dist/cjs/handlebars/runtime.js:68:39)\n
at Object.eval [as main] (eval at createFunctionContext (/MYAP/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:257:23), :16:28)\n
at main (/MYAP/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32)

Any help is appreciated.

Hi @chickenwing did you work this one out? Otherwise, I can try to have a look in the near future. Cheers

If this issue is only happening in production, can you try setting compress to false or ensuring that you are including uglify-js? https://github.com/js-kyle/connect-assets#options

Setting compress to false did fix the issue, thank you!