krisk / Fuse

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

IE11 broken build #491

Closed mariorodriguespt closed 3 years ago

mariorodriguespt commented 3 years ago

Describe the bug

I'm using core-js and webpack for development and production. On IE11 my app doesn't run, after commenting the import of my components that use fuse.js, it works flawlessly.

Version

6.4.1

Is this a regression?

I found old closed tickets with a similar issue: https://github.com/krisk/Fuse/issues?q=is%3Aissue+is%3Aclosed+ie11

🔬Minimal Reproduction

  1. Create a regular webpack build with core-js
  2. Use fuse.js
  3. Open your app in IE11
  4. Watch it burn
mariorodriguespt commented 3 years ago

Found a temporary fix in previous tickets for those in urgent need: change your import to import Fuse from 'fuse.js/dist/fuse.min.js'

maerzhase commented 3 years ago

Having the exact same problem.

import Fuse from 'fuse.js/dist/fuse.min.js'

works for me aswell!

mliq commented 3 years ago

Great but how to make this work in TypeScript?

import Fuse from 'fuse.js/dist/fuse.min.js' gives me:

Could not find a declaration file for module 'fuse.js/dist/fuse.min.js'. '/Users/mliquori/prequal-web/node_modules/fuse.js/dist/fuse.min.js' implicitly has an 'any' type.
  Try `npm install @types/fuse.js` if it exists or add a new declaration (.d.ts) file containing `declare module 'fuse.js/dist/fuse.min.js';`ts(7016)
wsakaria-mdsol commented 3 years ago

Use tslint ignore next line @mliq

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

mariorodriguespt commented 3 years ago

Commenting to avoid closing without a fix.

ekosz commented 3 years ago

Looks like this is due to the the spread operator being including in the module builds. AFAIK, module should be reserved for ES5 syntax + import/export.

danielbeardsley commented 3 years ago

We're running into this as well. I don't think this should be closed.

vesse commented 3 years ago

@mliq I copy-pasted the original fuse.d.ts to my sources (src/fuse.js__dist__fuse.min.js.d.ts) and wrapped it in declare module 'fuse.js/dist/fuse.min.js', and replaces the declares from there with exports, ie. like

declare module 'fuse.js/dist/fuse.min.js' {
  export default Fuse;

  export class Fuse<T> {
  ...
}

Now builds when used import Fuse from 'fuse.js/dist/fuse.min.js'; and types work and works also on IE11 which was the actual, rather sad requirement.

daphnesmit commented 2 years ago

Even easier then copy pasting:

declare module 'fuse.js/dist/fuse.min.js' {
  import Fuse from 'fuse.js';
  export default Fuse;
}