dijs / wiki

Wikipedia Interface for Node.js
MIT License
315 stars 61 forks source link

Error when building wikijs with Vite: Cannot acces stream.Transfrom in client code #175

Open powerslave opened 1 year ago

powerslave commented 1 year ago

I am running into a browser error when trying to execute the basic wikijs sample snippet: The project builds with Vite 3.2.3.

Is there a build option needed for Vite, similar to Usage with Webpacl?

Browser error:

stream-tokenizer.js:5 Uncaught TypeError: Class extends value undefined is not a constructor or null
    at node_modules/hyntax/lib/stream-tokenizer.js (stream-tokenizer.js:5:1)
    at __require (chunk-TWLJ45QX.js?v=8133fa8e:8:50)
    at node_modules/hyntax/index.js (index.js:3:25)
    at __require (chunk-TWLJ45QX.js?v=8133fa8e:8:50)
    at page.js:2:41

There is also a (related?) warning above this error. browser-external:stream:9 Module "stream" has been externalized for browser compatibility. Cannot access "stream.Transform" in client code.

code:

import wiki from "wikijs";

    wiki()
      .page("Batman")
      .then((page) => page.info("alterEgo"))
      .then(console.log); // Bruce Wayne

package.json config

"wikijs": "^6.4.1"
"vite": "^3.2.3"