Open antiantivirus opened 2 years ago
My solution was adding .default
.
const indexer = require('sanity-algolia').default
Might be related / fixed by this: https://github.com/sveltejs/kit/issues/6694
https://publint.dev/sanity-algolia@1.1.0 states: pkg.module is used to output ESM, but pkg.exports is not defined. As NodeJS doesn't read pkg.module, the ESM output may be skipped. Consider adding pkg.exports to export the ESM output. pkg.module can usually be removed alongside too. (This will be a breaking change)
HAS_MODULE_BUT_NO_EXPORTS: If the package has a module field, but has no exports field, suggest to use exports instead. This is because Node.js doesn't recognize the module field, so instead using exports would increase compatibility with it.
If the package isn't meant for Node.js usage, it is safe to ignore this suggestion, but it is still recommended to use exports whenever possible.
As suggested from https://publint.dev/sanity-algolia@1.1.0
I modified my local node_modules\sanity-algolia\package.json
to the following, and that made it work for me.
{
"version": "1.1.0",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
"dist",
"src"
],
"engines": {
"node": ">=10"
},
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint src test",
"prepare": "tsdx build"
},
"husky": {
"hooks": {
"pre-commit": "tsdx lint src test"
}
},
"name": "sanity-algolia",
"author": "Rune Botten",
+ "type": "module",
"module": "dist/sanity-algolia.esm.js",
+ "exports": {
+ "import": "./dist/sanity-algolia.esm.js",
+ "require": "./dist/sanity-algolia.cjs.js"
+ },
"devDependencies": {
"@types/jest": "^26.0.14",
"@types/stopword": "^0.3.0",
"husky": "^4.3.0",
"prettier": "^2.1.2",
"tsdx": "^0.14.0",
"tslib": "^2.0.2",
"typescript": "^4.0.3"
},
"dependencies": {
"algoliasearch": "^4.5.1",
"stopword": "^1.0.3"
}
}
I don't know if this would break something else, but could you take a look at maybe implementing this @runeb? :)
Any updates on this?
getting the error "indexer is not a function" with the following code. Written in javascript and deployed on netlify serverless function