Closed NathanielPoteat closed 1 year ago
There's an example provided by another user in the readme. Worth a look if you haven't yet: https://github.com/keckxde/node-disnetworkclient
There's an example provided by another user in the readme. Worth a look if you haven't yet: https://github.com/keckxde/node-disnetworkclient
I have already looked into how open-dis is imported there. I believe that the issue lies in trying to import open-dis into a browser rather than NodeJS. I'll probably either have to create a fork and convert the imports to the ES6 syntax or just take the hopefully easy way and use requirejs or browserify.
Ok I am not familiar with running it directly in a browser. If you get it working and don't mind sharing your results I'm curious how it turns out.
Trying to import open-dis using a browserify and requirejs didn't work, so I looked into making some changes to the source code to implement the JavaScript ES6 import method instead. That got me closer, but it now throws a was blocked because of a disallowed MIME type (“”).
I'm going to keep looking into it, but it doesn't seem like it will be a quick fix to get open-dis to import to and work on the browser.
Ok I am not familiar with running it directly in a browser. If you get it working and don't mind sharing your results I'm curious how it turns out.
I ended up creating a fork and swapped out the nodejs import/export syntax for the es6 import/export syntax and it works in the browser now. You can check out the fork repository here at https://github.com/NathanielPoteat/open-dis-ts-es6/tree/ts-es6-conversions
to see the changes I made to make it work. As an aside and a matter of preference, I also took the liberty of converting the files in my fork to TypeScript and created a min file containing only the files I needed for the project I'm working on.
Glad to hear it worked out.
I'm trying to import open-dis into a project that I'm working on to be able to package Pdus clientside, but keep getting the error message in the title when importing as
import open-dis;
.When importing as
const dis = require("open-dis");
I instead get an error message that that states:Uncaught ReferenceError: require is not defined
.Otherwise, I can import
import { Pdu } from 'open-dis/src/dis/Pdu'
. However, in this case, I get an error message in the browser stating: ` Uncaught ReferenceError: assignment to undeclared variable dis js SignalPdu.js:11 __require2 chunk-ASBRWZGP.js:15