#134 - Async loading of minisearch cache
Using a custom build of minisearch
This commit is contained in:
@@ -57,6 +57,14 @@ build({
|
|||||||
to: ['./'],
|
to: ['./'],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
{
|
||||||
|
name: 'resolve-minisearch',
|
||||||
|
setup(build) {
|
||||||
|
build.onResolve({ filter: /^minisearch$/ }, () => {
|
||||||
|
return { path: path.resolve('node_modules/minisearch/src/MiniSearch.ts') };
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
format: 'cjs',
|
format: 'cjs',
|
||||||
watch: !prod,
|
watch: !prod,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
"dexie": "^3.2.7",
|
"dexie": "^3.2.7",
|
||||||
"lodash-es": "4.17.21",
|
"lodash-es": "4.17.21",
|
||||||
"markdown-link-extractor": "^4.0.2",
|
"markdown-link-extractor": "^4.0.2",
|
||||||
"minisearch": "^6.3.0",
|
"minisearch": "github:scambier/minisearch#async-load-json",
|
||||||
"pure-md5": "^0.1.14",
|
"pure-md5": "^0.1.14",
|
||||||
"search-query-parser": "^1.6.0"
|
"search-query-parser": "^1.6.0"
|
||||||
},
|
},
|
||||||
|
|||||||
5647
pnpm-lock.yaml
generated
5647
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -59,6 +59,7 @@ export class Omnisearch {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
private minisearch: MiniSearch
|
private minisearch: MiniSearch
|
||||||
/** Map<path, mtime> */
|
/** Map<path, mtime> */
|
||||||
private indexedDocuments: Map<string, number> = new Map()
|
private indexedDocuments: Map<string, number> = new Map()
|
||||||
@@ -75,8 +76,7 @@ export class Omnisearch {
|
|||||||
async loadCache(): Promise<boolean> {
|
async loadCache(): Promise<boolean> {
|
||||||
const cache = await cacheManager.getMinisearchCache()
|
const cache = await cacheManager.getMinisearchCache()
|
||||||
if (cache) {
|
if (cache) {
|
||||||
// console.log('Omnisearch - Cache', cache)
|
this.minisearch = await MiniSearch.loadJSAsync(cache.data, Omnisearch.options)
|
||||||
this.minisearch = MiniSearch.loadJS(cache.data, Omnisearch.options)
|
|
||||||
this.indexedDocuments = new Map(cache.paths.map(o => [o.path, o.mtime]))
|
this.indexedDocuments = new Map(cache.paths.map(o => [o.path, o.mtime]))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,10 @@
|
|||||||
"lib": [
|
"lib": [
|
||||||
"DOM",
|
"DOM",
|
||||||
"ES2021"
|
"ES2021"
|
||||||
]
|
],
|
||||||
|
"paths": {
|
||||||
|
"minisearch": ["node_modules/minisearch/src/MiniSearch.ts"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user