sanity-io / sanity-algolia

Utilities for indexing Sanity documents in Algolia
MIT License
67 stars 16 forks source link

How do I transform your code for require- rather than import-based functions? #9

Closed kkgthb closed 3 years ago

kkgthb commented 3 years ago

I'm trying to use Netlify with your example function instead of Vercel. I'm getting errors about @import and saw a tip to switch to require imports instead.

However, I keep getting failures like TypeError: sanityAlgolia.webhookSync is not a function or TypeError: indexer is not a function.

Any tips?

runeb commented 3 years ago

Hello @kkgthb . If you are using require you might need to get the default export. A better way is to use babel or some other bundler/transpiler when you deploy javascript code.

Try

const sanityAlgolia = require("sanity-algolia").default';