Closed ts-thomas closed 2 years ago
I'm so happy to hear about 0.7.0 (Beta) 🥳 Couldn't resist to try it out instantly.
Sadly I'm unable to import via import Index from "flexsearch/src/index.js"
(as described in https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0.md) with Vue CLI 4.5.12 (Webpack 4.46.0 / Babel 7.13.16). The import seems to work, but there is the following Error at runtime (Chromium 90.0.4430.212):
Uncaught TypeError: Object(...) is not a function
at Module../common/temp/node_modules/.pnpm/github.com+nextapps-de+flexsearch@e391e2bbd67044433e32f991c73b6ba1712283d4/node_modules/flexsearch/src/document.js (document.js:730)
at __webpack_require__ (bootstrap:853)
at fn (bootstrap:150)
at Module../common/temp/node_modules/.pnpm/github.com+nextapps-de+flexsearch@e391e2bbd67044433e32f991c73b6ba1712283d4/node_modules/flexsearch/src/async.js (async.js:1)
at __webpack_require__ (bootstrap:853)
at fn (bootstrap:150)
at Module../common/temp/node_modules/.pnpm/github.com+nextapps-de+flexsearch@e391e2bbd67044433e32f991c73b6ba1712283d4/node_modules/flexsearch/src/index.js (index.js:1)
at __webpack_require__ (bootstrap:853)
at fn (bootstrap:150)
at src/store/search/actions.js (actions.js:1)
But I was able to import Flexsearch globally with import("flexsearch/dist/flexsearch.min.js");
. But then i realized that the "lang" files are not part of 0.7.0/dist and I get the same error as posted above by importing import { encode } from "flexsearch/src/lang/latin/advanced.js";
Maybe it's a Vue CLI thing... I am eagerly awaiting further feedback from other users.
And regarding your questions: I don't need ES5 support. Will provide more feedback if I get 0.7.0 working.
@boardend Thanks for your support. It looks like this line fail:
apply_async
is a function exported from async.js
. Please try the latest commit, probably the issue is gone. But it's really strange that the function will export as an object.
Updating to the latest commit (79fe061) didn't help...
The problem was the import of async.js
which imports back document.js
. So there is a circular dependency, which Webpack 4 seems unable to handle. (Did a test with a new Webpack 5.37.1 project according to the "Getting Started" guide which was working just fine with the latest commit of 0.7.0). Then nailed it down with a new Vue CLI Project with Webpack 4.46.0 (with and without Babel) which caused the same error as I got in my (rather complex) setup).
The PR https://github.com/nextapps-de/flexsearch/pull/218 will resolve this.
Ok I understand. The imports are there because of the type definition. I will provide an replacement for this definition and this problem is fixed then.
I got FlexSearch 0.7.0 working with Webpack 4 with the fix provided above, but then ran into more issues with circular module imports while trying to switch to the WorkerIndex with the Webpack worker-plugin: adapter.js > worker.js > index.js > serialize.js > document.js
(and then back to adapter.js
).
Below you find the output of npx madge --circular src/index.js
:
index.js > cache.js
index.js > lang.js
index.js > serialize.js
index.js > serialize.js > document.js
index.js > lang/latin/default.js
serialize.js > document.js
adapter.js > worker.js > index.js > serialize.js > document.js
I will try to update to Vue CLI v5.0.0-alpha.0 at some point which uses Webpack 5 internally (which wil probably resolve those issues).
But it would still make sense to prevent circular module imports whenever possible. Also I would suggest to avoid logic on the module level (e.g. the apply_async
line from document.js
) and switch to named exports whenever possible.
Let me know if I can help. Otherwise I will do further testing without workers and provide feedback in this issue.
I pushed an update to the branch "0.7.0", this should solve the issue.
Great news ! it's so cool to see this new version. I wanted to test it in my Proof Of Concept app made with Angular. To answer one of your question :
I was wondering if there was a typescript defintion file, and ... yes there is one, so it's great !
Thanks for the works. I will try to test it
The typescript def needs an update for 0.7.0.
e.g. There is no more create
and registerMatcher
in FlexSearch
.
@ts-thomas Were the Typescript definitions removed in v7? After updating to v7, VSCode complains about the type definitions missing.
FlexSearch v0.7.0 (Beta)
Beta is now available. Please test the new version and post back issues and suggestions. The Beta will pushed to the master branch in 2 weeks.
Read the documentation of new features and changes:
https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0.md
Read the documentation of new language encoding features:
https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0-lang.md
Source Code v0.7.0-beta available here:
https://github.com/nextapps-de/flexsearch/tree/0.7.0/src
Some of my questions are: