Closed KararTY closed 3 years ago
The module needs cejs. Do you also import cejs?
The module needs cejs. Do you also import cejs?
I've imported "cejs" but I still get the same issue:
[24:36:56] [snowpack] + wikiapi@1.15.1
[24:36:57] [esinstall:wikiapi] Home\DEV\ppsl-app-v1.5\node_modules\wikiapi\Wikiapi.js
Import "./_CeL.loader.nodejs.js" could not be resolved from file.
[24:36:57] [esinstall:wikiapi] Home\DEV\ppsl-app-v1.5\node_modules\wikiapi\Wikiapi.js
Import "./_CeL.loader.nodejs.js" could not be resolved from file.
[24:36:57] [esinstall:wikiapi] Home\DEV\ppsl-app-v1.5\node_modules\wikiapi\_CeL.loader.nodejs.js?commonjs-external
Module "Home\DEV\ppsl-app-v1.5\node_modules\wikiapi\_CeL.loader.nodejs.js" could not be resolved by Snowpack (Is it installed?).
[24:36:57] [snowpack] Install failed.
hmm... Do you have codes to test?
hmm... Do you have codes to test?
I've made a reproducible Github repository over here: https://github.com/KararTY/wikiapi-test
This is still broken, I've updated https://github.com/KararTY/wikiapi-test
The new error I'm getting is:
cejs.v4.2.2.js:91 TypeError: fs.readFileSync is not a function
at cejs.v4.2.2.js:55
at cejs.v4.2.2.js:79
at createCommonjsModule (cejs.v4.2.2.js:10)
at cejs.v4.2.2.js:30
(anonymous) @ cejs.v4.2.2.js:91
createCommonjsModule @ cejs.v4.2.2.js:10
(anonymous) @ cejs.v4.2.2.js:30
wikiapi.v1.15.1.js:530 Uncaught TypeError: Cannot read property 'match' of undefined
at wikiapi.v1.15.1.js:530
at wikiapi.v1.15.1.js:643
at createCommonjsModule (wikiapi.v1.15.1.js:239)
at wikiapi.v1.15.1.js:509
(anonymous) @ wikiapi.v1.15.1.js:530
(anonymous) @ wikiapi.v1.15.1.js:643
createCommonjsModule @ wikiapi.v1.15.1.js:239
(anonymous) @ wikiapi.v1.15.1.js:509
Are you sure this module works in the browser? There's a lot of filesystem (fs) calls and module calls.
This looks a bit complicated... still trying...
This looks a bit complicated... still trying...
What's the usual way of importing this module into the browser?
It is a pure npm now. For browser, I using the method list in https://github.com/kanasimi/CeJS/tree/master/application/net/wiki#usage-in-mediawiki-user-script-userexamplecommonjs
// Since Snowpack cannot read utf-8 or utf-16 script file now,
// you MUST create a web server, and set main_script_URL.
//window.CeL = { main_script_URL: 'https://localhost/path/to/ce.js' };
// Default URL to ce.js is https://kanasimi.github.io/CeJS/ce.js
import cejs from 'cejs';
cejs.then(CeL_module => import('wikiapi')).then(Wikiapi_module => main_process(Wikiapi_module.default));
async function main_process(Wikiapi) {
const wiki = new Wikiapi({ project: 'en', origin: '*' });
const page_data = await wiki.page('ABC');
console.log(page_data);
}
Does this module support browsers?
I'm specifically using it together with Snowpack (& Skypack CDN) to make it work on the browser but I get the following errors:
This is how I import it: