Closed dtothefp closed 8 years ago
@dtothefp Thanks for the issue! If you're reporting a bug, please be sure to include:
assemble
you are using.fn.call is not a function
That's telling me you're not passing an actual function to the .use
method.
@doowb thanks, babel was doing a weird caching thing that made my export an object. I cleared the babel cache rm ~/.babel.json
and that worked but now I have a new error
TypeError: Cannot set property offset of [object Object] which has only a getter
at Buffer.copy (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/mixin-deep/index.js:30:15)
at forIn (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/for-in/index.js:12:12)
at mixinDeep (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/mixin-deep/index.js:11:7)
at File.copy (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/mixin-deep/index.js:28:5)
at forIn (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/for-in/index.js:12:12)
at mixinDeep (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/mixin-deep/index.js:11:7)
at Object.copy (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/mixin-deep/index.js:28:5)
at forIn (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/for-in/index.js:12:12)
at Function.mixinDeep (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/mixin-deep/index.js:11:7)
at View.context (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/vinyl-view/index.js:263:22)
at View.context (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/vinyl-view/index.js:133:23)
at cacheContext (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/templates/lib/plugins/render.js:341:17)
at /Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/templates/lib/plugins/render.js:302:23
at /Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/base-routes/index.js:168:9
at /Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/base-routes/index.js:168:9
at /Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/en-route/lib/index.js:576:15
at next (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/en-route/lib/index.js:161:14)
at Function.proto.handle (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/en-route/lib/index.js:140:3)
at Views.<anonymous> (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/base-routes/index.js:82:21)
at /Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/base-routes/index.js:91:20
at /Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/en-route/lib/index.js:576:15
at next (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/en-route/lib/index.js:161:14)
_handled: true,
source: 'at Buffer.copy (/Users/davidfox-powell/dev/build-boiler/packages/boiler-config-assemble/node_modules/mixin-deep/index.js:30:15)',
reason: 'assemble#handle("preCompile"): /Users/davidfox-powell/dev/build-boiler/src/templates/pages/index.html
Not sure if it's related to how @jonschlinkert recommended I appended the view
to the file
export default (file, next) => {
const view = file.clone();
view.data = cloneDeep(view.data);
file.data.view = view;
next(null, file);
};
but I can catch the error in the render cycle just after piping to renderFile
app.src(newSrc)
.pipe(gulpIf(mergeFluxData, fluxPlugin))
.pipe(app.renderFile())
.on('error', (err) => {
//error is here
})
try just shallow cloning view.data
, like I did in my example:
export default (file, next) => {
var view = file.clone();
view.data = Object.assign({}, view.data);
file.data.view = view;
next();
};
hmm, but view
is already exposed on helper context. So in helpers you can do this.view
to get the view. It might be better to use a helper for what you're doing so you don't need to clone views like that. It's probably slow
sounds like this original issue was resolved, per the op. I'm going to go ahead and close, but you can reopen if I'm mistaken, or feel free to create another issue for the file cloning stuff
@jonschlinkert I was only attaching the view
to the file
object because of the previous issue last time I upgraded assemble-core
https://github.com/jonschlinkert/templates/issues/17
Not sure why the view
has disappeared again from the file
context but my Nunjucks tags (essentially helpers Nunjucks style) rely on some context from view
such as key
and path
.
With your suggestion above for cloning the view I still ended up with the error stack I listed above. Since I only need these two keys I did
/**
* Add the `view` to `file.data
* https://github.com/jonschlinkert/templates/issues/17
*/
export default (file, next) => {
const fallback = {
key: file.key,
path: file.path
};
file.data.view = file.data.view || fallback;
next();
};
I don't know how to access this.view
in helper context as you suggested above because I'm using Nunjucks.
I still ended up with the error stack
that's not surprising, it's inception. but it sounds like you got it worked out then?
Not sure why the view has disappeared again from the file context
view
is on the helper context, so inside a helper it would be on this.view
, but view
is actually a built in helper name as well. So it would be a function if you tried to just use it as a variable.
@dtothefp if you're experiencing a bug or a regression that should be fixed, let's get another issue created so @doowb and I can work on resolving it
Our build is pretty complex so it's hard to pinpoint issues upon upgrading to
0.25.0
but we are getting this erroroccurring at this line of code https://github.com/dtothefp/build-boiler/blob/master/packages/boiler-task-assemble/src/index.js#L71