This will be called before the store is initialized which will result in collection to be undefined and finally it will fail build process. At least for sanity, add condition to check if collection exist so that it will not end up with follow error:
Cannot destructure property 'collection' of 'store.getCollection(...)' as it is undefined.
For another issues which will be caused by blank array for data, you will need to call this function inside beforeBuild event so that data is available there.
This will be called before the store is initialized which will result in
collection
to beundefined
and finally it will fail build process. At least for sanity, add condition to check if collection exist so that it will not end up with follow error:Cannot destructure property 'collection' of 'store.getCollection(...)' as it is undefined
.For another issues which will be caused by blank array for data, you will need to call this function inside
beforeBuild
event so that data is available there.