Incompatible with ES6 Modules
See original GitHub issueI’m unable to load Lunr.js in an ES6 module. I know Lunr isn’t packaged up in an ES6 module, but imported scripts will still cause side effects and the window.lunr global can be used within an ES6 module [stack overflow] [codepen example]:
import "https://unpkg.com/lunr/lunr.js"
var documents = [{
"name": "Lunr",
"text": "Like Solr, but much smaller, and not as bright."
}, {
"name": "React",
"text": "A JavaScript library for building user interfaces."
}, {
"name": "Lodash",
"text": "A modern JavaScript utility library delivering modularity, performance & extras."
}]
const lunr = window.lunr
var idx = lunr(function () {
this.ref('name')
this.field('text')
documents.forEach(function (doc) {
this.add(doc)
}, this)
})
console.log(idx.search("bright"))
This results in an error: Uncaught TypeError: Cannot set property 'lunr' of undefined
. on line 3461 root.lunr = factory()
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:16 (3 by maintainers)
Top Results From Across the Web
Grunt and ES6 modules in node - incompatible without ...
So, I'm dabbling a bit with Typescript and Grunt at the moment to see if it's worth it for me. The thing is:...
Read more >Truffle incompatible with ESMs (ES5 / ES6 modules with " ...
is it possible to execute truffle commands inside a folder in "ESM mode", i.e. package.json contains "type": "module", uses import instead of ...
Read more >JavaScript modules via script tag | Can I use... Support ...
Loading JavaScript module scripts (aka ES6 modules) using <script type="module"> Includes support for the nomodule attribute.
Read more >JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax. A background on modules. JavaScript programs started off pretty ......
Read more >16. Modules
ES6 is the first time that JavaScript has built-in modules. ES6 modules are ... The two most important (and unfortunately incompatible) standards are:....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ping @olivernn consider adding contributors to the repo so we don’t have to wait
I just used a temp file, you can see the results here: https://github.com/indo-dev-0/lunr.js