krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
18.16k stars 767 forks source link

Not working in TypeScript #521

Closed dmurawsky closed 3 years ago

dmurawsky commented 3 years ago

Describe the bug

TypeScript can't import the library

ERROR in ./node_modules/fuse.js/dist/fuse.esm.js
       Module parse failed: Unexpected token (271:2)
       You may need an appropriate loader to handle this file type.
       | 
       | var Config = {
       |   ...BasicOptions,
       |   ...MatchOptions,
       |   ...FuzzyOptions,
        @ ./app/javascript/helpers/on-demand.ts 17:0-27
        @ ./app/javascript/apps/customer/pages/on-demand.tsx
        @ ./app/javascript/apps/customer/index.tsx
        @ ./app/javascript/packs/customer.tsx

Version

6.4.3

Is this a regression?

No

🔬Minimal Reproduction

Import Fuse into a TypeScript app

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

dmurawsky commented 3 years ago

@krisk is this a known issue. I'm a patreon supporter if that helps :)

krisk commented 3 years ago

Hey! Would you have a sample project I can check? Have you tried just doing import Fuse from 'fuse.js'? Could you also share your tsconfig.json? Thanks!

dmurawsky commented 3 years ago

Thanks Krisk, I created a basic TS CRA example and it seems to be working fine. It's failing in a Ruby on Rails project that uses the webpacker ruby gem so that's probably the issue. We're moving this project out of webpacker pretty soon so we're not worried about it.

NorthBei commented 3 years ago

I also encouter this problem like below, after I use CRA build my react rpoject, but I don't use typescript. How could I solve this problem ? Thx.

Describe the bug

./node_modules/fuse.js/dist/fuse.esm.js
Module parse failed: Unexpected token (271:2)
You may need an appropriate loader to handle this file type.
| 
| var Config = {
|   ...BasicOptions,
|   ...MatchOptions,
|   ...FuzzyOptions,

Version 6.4.3