phiresky / sql.js-httpvfs

Hosting read-only SQLite databases on static file hosters like Github Pages
Apache License 2.0
3.47k stars 105 forks source link

New NPM release and/or build instructions? #39

Closed jordemort closed 2 years ago

jordemort commented 2 years ago

I was trying to use the cache busting added in https://github.com/phiresky/sql.js-httpvfs/pull/21 and discovered that it isn't in the version of the module released on NPM.

I tried installing the module from the git repository instead, but because package.json lacks a prepare script, it doesn't run the build process and installs an empty package.

I tried adding a prepare script, so that I could install the module from the repo, but failed at it: https://github.com/phiresky/sql.js-httpvfs/compare/master...jordemort:npm-prepare?expand=1

I don't really need to build the module myself, and would be perfectly content to consume an updated version from NPM, but failing that, I would appreciate some help in figuring out how to build it.

All three attempts ended in errors similar to:

npm ERR! ERROR in ./src/index.ts
npm ERR! Module build failed (from ./node_modules/ts-loader/index.js):
npm ERR! Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
npm ERR!     at Object.resolveTypeReferenceDirective (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/typescript/lib/typescript.js:43192:18)
npm ERR!     at /Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/ts-loader/dist/servicesHost.js:679:18
npm ERR!     at /Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/ts-loader/dist/servicesHost.js:118:141
npm ERR!     at Array.map (<anonymous>)
npm ERR!     at Object.resolveTypeReferenceDirectives (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/ts-loader/dist/servicesHost.js:118:124)
npm ERR!     at actualResolveTypeReferenceDirectiveNamesWorker (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/typescript/lib/typescript.js:118249:163)
npm ERR!     at resolveTypeReferenceDirectiveNamesWorker (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/typescript/lib/typescript.js:118549:26)
npm ERR!     at processTypeReferenceDirectives (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/typescript/lib/typescript.js:120046:31)
npm ERR!     at findSourceFileWorker (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/typescript/lib/typescript.js:119931:21)
npm ERR!     at findSourceFile (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/typescript/lib/typescript.js:119783:26)
npm ERR! 
npm ERR! ERROR in ./src/sqlite.worker.ts
npm ERR! Module build failed (from ./node_modules/ts-loader/index.js):
npm ERR! TypeError: Cannot read properties of undefined (reading 'getSourceFile')
npm ERR!     at Object.getEmitOutput (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/ts-loader/dist/instances.js:514:53)
npm ERR!     at getEmit (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/ts-loader/dist/index.js:261:37)
npm ERR!     at successLoader (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/ts-loader/dist/index.js:39:11)
npm ERR!     at Object.loader (/Users/jordan/.npm/_cacache/tmp/git-clone32cgcP/node_modules/ts-loader/dist/index.js:23:5)
phiresky commented 2 years ago

The following steps to build the package work for me:

git clone https://github.com/phiresky/sql.js-httpvfs
cd sql.js-httpvfs
yarn install
cd sql.js
yarn install
yarn rebuild
cd ..
yarn build

Maybe the issue is that you didn't run npm install in the sql.js directory? Alternatively, the issue might be that you used npm to install the dependencies and got versions that aren't compatible with each other (since npm ignores the yarn lock file). The dependencies (including sql.js) should be updated to the newest versions, but I'm not actively working on this project anymore.

In any case, I've released version 0.8.12 that should include the latest changes.

jordemort commented 2 years ago

Alternatively, the issue might be that you used npm to install the dependencies and got versions that aren't compatible with each other (since npm ignores the yarn lock file).

I'll give it a shot; it's definitely most likely that I did something wrong. I am mostly a C programmer and when it comes to JS stuff I am usually just blindly throwing stuff at the wall.

I'm not actively working on this project anymore.

It's an extremely cool project; I picked it because all the pre-made "static site search" things I found seemed to need to download the entire index to work.

I think I was able to pull of a nasty little hack to avoid the problem of having to pull the whole index to sort by rank; instead of using fts5 and it's built-in ranking function, I use fts4 with no ranking function, and then wrap that up as a CTE and compute a rank after the data has been retrieved. My bogus "ranking function" seems to do a surprisingly good job: https://github.com/jordemort/jordemort.github.io/blob/main/src/search/client.ts

In any case, I've released version 0.8.12 that should include the latest changes.

Thank you!