MihaiValentin / lunr-languages

A collection of languages stemmers and stopwords for Lunr Javascript library
Other
431 stars 163 forks source link

Activate plugin in Reactjs #28

Open jaynakus opened 7 years ago

jaynakus commented 7 years ago

How can I add this support in Reactjs where ES2015 and ES2016 are used. Where modules are not required but imported.

tried these but didn't work

import lunr from 'lunr';
require('../node_modules/lung-languages/lunr.stemmer.support.js')(lunr)
import lunr from 'lunr';
import {} from 'lunr-languages';
var idx = lunr(function(){
   this.use(require('../node_modules/lung-languages/lunr.stemmer.support.js'))
});
Narretz commented 6 years ago

This syntax would technically work (maybe you need to specify the full path)

  import elasticlunr from 'elasticlunr';
  import stemmerSupport from 'lunr-languages/lunr.stemmer.support.js';
  import de from 'lunr-languages/lunr.de.js';

  stemmerSupport(elasticlunr);
  de(elasticlunr);

elasticlunr(function () {
  this.use(elasticlunr.de);
});

However, you cannot use npm install lunr-languages because the package on npm only works with lunr. You need to include the files from the fork https://github.com/weixsong/lunr-languages