MihaiValentin / lunr-languages

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

Use lunr.de with requirejs #3

Closed 310K closed 9 years ago

310K commented 10 years ago

Hello, I can't figure out how to use lunr.de with requirejs. I tried :

CASE 1

paths: {
    lunr        : 'path/to/lunr'
    lunrde      : 'path/to/lunr.de' 
},
shim {
    lunr: {
        exports: 'lunr'
    },
    lunrde: {
        deps: ['lunr'],
        exports: 'lunrde'
    }
}

And in another file

define(['app',
        'lunr',
        'lunrde'
],
function(App, lunr, lunrde) {
    var functionName = function() {
        idx = lunr(function() {
            this.use(lunrde);
        });
    }
}

CASE 2

paths: {
    lunr        : 'path/to/lunr'
    'lunr.de'    : 'path/to/lunr.de' 
},
shim {
    lunr: {
        exports: 'lunr'
    },
    'lunr.de': {
        deps: ['lunr'],
    }
}

And in another file

define(['app',
        'lunr',
        'lunrde'
],
function(App, lunr) {
    var functionName = function() {
        idx = lunr(function() {
            this.use(lunr.de);
        });
    }
}

In both cases (and all mixes between them), I'll keep have the exception 'Lunr is not present. Please include / require Lunr before this script.' and another error from lunr because he couldn't find "lunr.de"... It's work with lunr alone !

Do someone know how to include lunr globally with requirejs or how to use lunr.de with require js ? (For brevity here, I don't include lunr.stemmer.support).

MihaiValentin commented 10 years ago

Hi @Michael758,

I've just updated lunr-languages to have AMD/CommonJS support. Check out the demo-browser-require.html demo in the demos folder.

Let me know if it fixed your issue.

310K commented 10 years ago

Hello @MihaiValentin

Thanks a lot, work like a charm ! And thanks for this work !