arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
600 stars 106 forks source link

Issue importing arangojs in svelte application #726

Closed jandot closed 3 years ago

jandot commented 3 years ago

Issue

When trying to access an arangodb database from a svelte-application (https://svelte.dev), I get the error "Uncaught ReferenceError: querystring_1 is not defined".

To recreate:

  1. Create new svelte app: npx degit sveltejs/template arango_example
  2. cd arango_example
  3. npm install
  4. npm install arangojs
  5. Replace all content in src/App.svelte with the following:
    <script>
    import { Database } from 'arangojs';
    </script>
  6. Start server: npm run dev

The console will now show Uncaught ReferenceError: querystring_1 is not defined.

pluma commented 3 years ago

(answered in the community slack)

The solution was to use the web build of arangojs instead of the regular npm release. This means using the arangojs/web entrypoint instead of arangojs. Svelte does not seem to bundle node compatibility modules on demand by default so querystring was undefined.