padarom / guacamole-common-js

:avocado: The JavaScript Guacamole client library modified for easy installation and usage via npm
http://guac-dev.org/
Apache License 2.0
41 stars 18 forks source link

Uncaught ReferenceError: module is not defined at guacamole-common.min.js:1:70567 #25

Closed pranavelric closed 8 months ago

pranavelric commented 1 year ago

We are using guacamole-common-js in one of our projects and using guacamole-common.min.js in the script results in a module not found error: <script type="text/javascript" src="guacamole-common.min.js"></script>

image-20230127-190011

I am using guacamole-common.js: 1.4.0-a

padarom commented 1 year ago

Sorry for the long delay. It seems this issue is caused by the library not actually exporting any ES modules. I just released guacamole-common-js@1.4.0-b which contains both a CJS and an ESM export (in dist/cjs and dist/esm respectively).

I'm not sure that your use case would work though. Even though the module exports the Guacamole object, if you simply import the script using an HTML script tag it won't be automatically accessible by any other scripts on the page. For that you'd want to write a separate script with your actual Guacamole logic, such as

<script type="module">
import Guacamole from './path/to/guacamole-common.min';
const client = Guacamole.Client(...);
</script>