Geoblocks are pieces of code:
- with minimal dependencies choosing versions;
- independant;
- easy to use;
- tested and documented testing;
- maintained by the people who use them;
- written in plain ES6 or typescript;
- distributed as ES6 modules + typescript d.ts typing.
Each block is maintained in its own independant github
repository in the
github geoblocks organisation.
Blocks are published on npm
in the
npm geoblocks organisation.
The proj
block exposes OpenLayers
projections. To use them:
npm i --save @geoblocks/proj
import EPSG_2056 from '@geoblocks/proj/src/EPSG_2056.js';
- you are done!
- Create issue / PR in the block;
- A block maintainer will review and merge;
- To create new blocks get in touch with us.
Each block has a package.json
file specifying the dependencies of the block.
For each dependency, the block author must specify a range starting at the smallest usable version.
Let's take an example.
The proj
block depends on OpenLayers 5. It is usable with all the versions in
the range [5.3.0, current] so the package.json file must contain:
ol": ">=5.3.0",
During the CI tests, both version 5.3.0 and the latest version are tested. Here is how it is handled.
Blocks can be written as plain ES6 modules. But to catch errors early and to benefit from modern Javascript editing in code editors like VSCode, it is required to:
- publish typescript definition files (d.ts);
- define typescript interfaces when implementing a generic feature.
With proper annotations, note that plain ES6 modules blocks can use typescript as a typechecker.
- enable CI with tests and coverage example with JEST;
- publish a documentation;
- eventually publish examples.
See the sources block.