Skip to content

Export browser bundle of drivers as ECMAScript module #1038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Dec 21, 2022

Conversation

bigmontz
Copy link
Contributor

@bigmontz bigmontz commented Dec 6, 2022

ECMAScript modules are the official standard format to package JavaScript code for reuse. This is standard improve the modularity of the applications by avoiding leaking global variables and other benefits.

Usage example of the neo4j-driver-lite esm in browser:

// jsDelivr CDN minified for production use, version X.Y.Z where X.Y.Z >= 5.4.0
import neo4j from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/browser/neo4j-lite-web.esm.min.js'

const driver = neo4j.driver(/* your host */, neo4j.auth.basic(/* user */, /* password */))

driver.verifyConnectivity()
	.then(() => console.log('Connected'))
	.catch(e => console.error(e))

Changes in the neo4j-driver-lite

Browserify was replaced by rollup as the browser building tool for building umd and esm outputs. Since rollup is already being used in the testkit-backend, this change also standardise the tooling in the monorepo.

The esm module is exported as neo4j-lite-web.esm.js (non-minified) and neo4j-lite-web.esm.min.js (minified). The files are available under lib/browser along with umd modules.

Changes in the neo4j-driver

Browserify was replace by rollup as in the neo4j-driver-lite. However, its usage is done using gulp. The library build was changed to use tsc building tool instead of babel.

Removed dev dependencies:

  • @babel/eslint-parser
  • @babel/preset-env
  • @istanbuljs/nyc-config-babel
  • babel-plugin-istanbul
  • babelify
  • browserify
  • browserify-transform-tools
  • gulp-babel
  • istanbul
  • karma-browserify
  • nyc
  • vinyl-source-stream

Removed prod dependencies:

  • @babel/runtime

Some babel dependencies still needed since the gulp script depends on ES6 imports.

@bigmontz bigmontz force-pushed the 5.x-export-esm-package branch 2 times, most recently from 7b43d67 to d1ac098 Compare December 8, 2022 16:22
@bigmontz bigmontz marked this pull request as ready for review December 15, 2022 14:53
ECMAScript modules are the official standard format to package JavaScript code for reuse.
This is standard improve the modularity of the applications by avoiding leaking global variables and other benefits.

Usage example of the `neo4j-driver-lite` esm in browser:

```javascript
// jsDelivr CDN minified for production use, version X.Y.Z where X.Y.Z >= 5.4.0
import neo4j from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/browser/neo4j-lite-web.esm.min.js'

const driver = neo4j.driver(/* your host */, neo4j.auth.basic(/* user */, /* password */))

driver.verifyConnectivity()
	.then(() => console.log('Connected'))
	.catch(e => console.error(e))
```

**Changes in the `neo4j-driver-lite`**

`Browserify` was replaced by `rollup` as the browser building tool for building `umd` and `esm` outputs.
Since `rollup` is already being used in the `testkit-backend`, this change also standardise the tooling in the monorepo.

The esm module is exported as `neo4j-lite-web.esm.js` (non-minified) and `neo4j-lite-web.esm.min.js` (minified).
The files are available under `lib/browser` along with `umd` modules.
Remove dependencies:

* vinyl-source-stream
* gulp-babel
@bigmontz bigmontz force-pushed the 5.x-export-esm-package branch from 82fd558 to df85fd9 Compare December 15, 2022 14:54
@bigmontz bigmontz merged commit a62ecba into neo4j:5.0 Dec 21, 2022
@bigmontz bigmontz deleted the 5.x-export-esm-package branch December 21, 2022 11:24
bigmontz added a commit to bigmontz/neo4j-javascript-driver that referenced this pull request Jan 9, 2023
ECMAScript modules are the official standard format to package JavaScript code for reuse. This is standard improve the modularity of the applications by avoiding leaking global variables and other benefits.

Usage example of the `neo4j-driver-lite` esm in browser:

```javascript
// jsDelivr CDN minified for production use, version X.Y.Z where X.Y.Z >= 5.4.0
import neo4j from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/browser/neo4j-lite-web.esm.min.js'

const driver = neo4j.driver(/* your host */, neo4j.auth.basic(/* user */, /* password */))

driver.verifyConnectivity()
	.then(() => console.log('Connected'))
	.catch(e => console.error(e))
```

**Changes in the `neo4j-driver-lite`**

`Browserify` was replaced by `rollup` as the browser building tool for building `umd` and `esm` outputs. Since `rollup` is already being used in the `testkit-backend`, this change also standardise the tooling in the monorepo.

The esm module is exported as `neo4j-lite-web.esm.js` (non-minified) and `neo4j-lite-web.esm.min.js` (minified). The files are available under `lib/browser` along with `umd` modules.

**Changes in the `neo4j-driver`**

`Browserify` was replace by `rollup` as in the `neo4j-driver-lite`. However, its usage is done using `gulp`. The library build was changed to use `tsc` building tool instead of `babel`. 

Removed dev dependencies:

* @babel/eslint-parser
* @babel/preset-env
* @istanbuljs/nyc-config-babel
* babel-plugin-istanbul
* babelify
* browserify
* browserify-transform-tools
* gulp-babel
* istanbul
* karma-browserify
* nyc
* vinyl-source-stream

Removed prod dependencies:

* @babel/runtime

Some babel dependencies still needed since the gulp script depends on ES6 imports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant