orama
orama copied to clipboard
Browser build doesn't export methods
Describe the bug The current version of Lyra, ran in a browser doesn't work.
Uncaught SyntaxError: The requested module './src/lyra.js' does not provide an export named 'create' (at index.html:5:16)
I got the same error with search
and insert
methods.
To Reproduce Steps to reproduce the behavior:
- Create a new index file importing a browser release: https://unpkg.com/@lyrasearch/[email protected]/dist/browser/src/lyra.js
- Paste the following code:
<!DOCTYPE html>
<html>
<body>
<script type="module">
import { create, search, insert } from "https://unpkg.com/@lyrasearch/[email protected]/dist/browser/src/lyra.js";
const db = create({
schema: {
author: "string",
quote: "string",
},
});
insert(db, {
quote: "It is during our darkest moments that we must focus to see the light.",
author: "Aristotle",
});
const searchResult = search(db, {
term: "if",
properties: "*",
});
console.log(searchResult)
</script>
</body>
</html>
- Open the file
Expected behavior Lyra should be used in any runtime
Desktop (please complete the following information):
- Lyra: v0.2.4
Additional context
EDITED: A good tsc
alternative to building the browser release is to use esbuild
(used by Lyra a few versions ago), I've created a branch with a working browser release.