Import/require how to load neo4j-driver

I'm kind of stumped here; I'm trying to integrate neo4j JavaScript driver into my Antora site. I have already figured out neovis, but ran into a couple of issues. I would like to try d3 with the neo4j-driver. However when trying to load the driver I either get a message that 'require is not defined' or that 'import cannot be used outside a module'.

I have this in my footer scripts:

<script>
<script src="https://cdn.jsdelivr.net/npm/neo4j-driver@4.2.2/lib/browser/neo4j-web.min.js"></script>
  import neo4j from 'neo4j-driver';
  // Connect to the Neo4j database
  <!-- const neo4j = require('neo4j-driver'); -->
  const driver = neo4j.driver('neo4j+s://1a53c4f7.databases.neo4j.io', neo4j.auth.basic('neo4j', 'password'));
  const session = driver.session();

I am using Antora, and since that is why you guys also use for your documentation I actually grabbed the cdn script from your website footer-scripts.hbs. But it is not working for me.

I did also npm install the neo4j-driver but it seems that Antora does not recognise stuff in node_modules without some other magic. Their js scripts seem to be all under src/js/vendor. I hunted around under node_modules/neo4j-driver and then tried to load:

<script async src="{{uiRootPath}}/js/vendor/neo4j-web.esm.js"></script>

But then I get a console error: Uncaught SyntaxError: Unexpected token 'export' (at neo4j-web.esm.js:1:628034)

I'd like to simply use what's in node_modules but any way I can get this working by using cdn or node_modules would be fine.

How can I make this work?

Well I finally figured this out. Not much documentation from neo4j. Just says use 'require'. Even chatgpt and bard couldn't help. But persistence led to the solution. Since I am not using some framework I was able to 'import' (not require) the neo4j-web.esm.min.js file. This had to be copied to the js/vendor directory in Antora, and specified with the real path (not from node_modules). Maybe this will help someone else at some point...

import neo4j from './neo4j-web.esm.min.js';
const driver = neo4j.driver('neo4j+s://1a53c4f7.databases.neo4j.io', neo4j.auth.basic('neo4j', 'password'));
const session = driver.session();