Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript error in exificient.js line 2998 - Uncaught ReferenceError: exports is not defined #18

Open
jsbiff opened this issue Jan 21, 2023 · 4 comments

Comments

@jsbiff
Copy link

jsbiff commented Jan 21, 2023

When trying to use exificient.js, Firefox (109.0 Windows 64-bit) is logging an error:

Uncaught ReferenceError: exports is not defined
https://unpkg.com/[email protected]/dist/exificient.js:2998


The line in question is:

exports.EXI4JSON = EXI4JSON;

I think this is preventing exificient from working at all.

@jsbiff
Copy link
Author

jsbiff commented Jan 21, 2023

So, this might be a harmless warning in the browser. I did some googling on this error, and it seems to have something to do with TypeScript, and additionally, I noticed the exificient.js demo works, but it ALSO throws that error.

@danielpeintner
Copy link
Member

I tried the demos on http://exificient.github.io/javascript/ and they seem to work fine.

BTW, yes, on the console I see the same warning.

@hoffe86
Copy link

hoffe86 commented Feb 28, 2023

The typescript type exports are missing for all classes, which are required to implement and XML encoding and decoding like described in the example from the main page.

// Note: the necessary grammars can be generated from XML schema using
// the project https://github.com/EXIficient/exificient-grammars
// class com.siemens.ct.exi.grammars.persistency.Grammars2JSON 

// encode XML
var exiEncoder = new EXIEncoder(grammars);	
exiEncoder.encodeXmlText(textXML);
var uint8ArrayLength = exiEncoder.getUint8ArrayLength();
var uint8Array = exiEncoder.getUint8Array();

// decode EXI to XML again
var exiDecoder = new EXIDecoder(grammars);
var xmlHandler = new XMLEventHandler(); // register XML handler
exiDecoder.registerEventHandler(xmlHandler);
exiDecoder.decode(arrayBuffer); // EXI input data
xmlHandler.getXML(); // get XML

@danielpeintner
Copy link
Member

The typescript type exports are missing for all classes,

That is correct, since it is meant to be used as JS library. No need for TS export, even though TS support might be useful as well.

.. which are required to implement and XML encoding and decoding like described in the example from the main page.

Note sure why TS exports are needed. As you can see the online demo at the http://exificient.github.io/javascript/ works.
Having said that, there are currently no plans to work on updates...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants