unic / estatico

[DEPRECATED] Estático – Static site generator for frontend unicorns
Other
121 stars 18 forks source link

Moving boilerplate code from *.data.js to helpers/data.js #47

Closed marbor3 closed 2 years ago

marbor3 commented 7 years ago

I was hoping for performance optimisation but there was no change ... Anyway - I kinda like it anyway so I'll post it as a suggestion.

What do you think?

swey commented 7 years ago

In our setup we have several default data files (e.g. page.data.js which is the base for pages). Also we had some cases where we based our data on mock data (technically we merged the default data, some mock data and some other object).

Of course it still would be possible to use the old variant of the data files in those cases, but they would be less consistent.

orioltf commented 7 years ago

Same here: striping from every module the option to choose which data file(s) to extend from reduces a lot the power from the modularisation that we have in Estatico, except when going back to the current solution for modules needing so, of course. Yet then the expectation for entry level users would be different, and the demo modules wouldn't be showcasing it. I'd therefor prefer staying in the current solution. What do you think @marbor3 ?

marbor3 commented 7 years ago

Hmm,

I don't want to get rid of .data.js files per module, it's just that on larger project - this data has a tendency to grow really fast. Build performance is hurt a lot when we have multiple requires in .data.js files.

So what I wanted to achieve here:

I think you still could be using module .data.js files the way you are now - just I would try to move logic outside of them and keep there just the data.

And about many defaultData files or mock data - this could be just another helper in helpers.data.js or it could stay in modules .data.js.

Or this doesn't make much sense? :)

orioltf commented 7 years ago

Do you think you could expand 'getExtendedData' to accept n arguments? like that we could be doing something lie follows in any page:

var dataHelper = require('../../../../helpers/data.js'),
    pagesData = require('../../../data/pages.data.js');

module.exports = dataHelper.getExtendedData(pagesData, {
    ... MODULE DATA...
});

What do you think?

marbor3 commented 2 years ago

I will close it as not longer active