neo4j-javascript-driver
neo4j-javascript-driver copied to clipboard
Can it be used as a module in the browser?
Browsers have had support for loading ECMAScript modules directly (no tools like Webpack required)
in index.html
, I do this
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<script type="module" src="neo4j.js"></script>
</head>
<body>
// Do some stuff ....
</body>
</html>
in neo4j.js
/*jshint esversion: 6 */
import neo4j from 'https://unpkg.com/[email protected]/lib/browser/neo4j-web.min.js';
I got this error
SyntaxError: The requested module 'https://unpkg.com/[email protected]/lib/browser/neo4j-web.min.js' does not provide an export named 'default'
With this
/*jshint esversion: 6 */
import { neo4j } from 'https://unpkg.com/[email protected]/lib/browser/neo4j-web.min.js';
I got
SyntaxError: The requested module 'https://unpkg.com/[email protected]/lib/browser/neo4j-web.min.js' does not provide an export named 'neo4j'
Is possible to use neo4j-javascript-driver
has module in browser?
Hi @LeMoussel,
We currently does not support esversion 6. You can found more info about using this driver in browser in https://github.com/neo4j/neo4j-javascript-driver#in-web-browser
Cheers, Zhen
Hi @zhenlineo I think it could be cool to have this package compiled as a ESM, this could perhaps use my usecase in deno
where I use:
import neo4j from "https://cdn.skypack.dev/neo4j-driver";
To import both the .d.ts files and the lib it self, not sure if this is something that could be worked on easily making a ESM package? and in the mean time maybe look at some export map
as described here: https://docs.skypack.dev/package-authors/package-checks#export-map (this is rather new to my self, but I do find it interesting), I see you are already doing something similar with unpkg and jsdeliver.
edit link to the skypack repo: https://www.skypack.dev/view/neo4j-driver
This can be done since 5.4.0, more about it on https://www.npmjs.com/package/neo4j-driver#in-web-browser