Skip to content

Commit

Permalink
Adopt type=module (#238)
Browse files Browse the repository at this point in the history
* Adopt type=module

follow changes in d3-format:
* type=module
* add exports
* remove zip
* license: ISC
* update dependencies

* fix compare-image

* obsolete render-reference

* compute-scale

* remove Sublime project

* add eslint.json

* update dependencies

* .mjs ↦ .js

* Update README

* stricter eslint

* cleaner imports

* cleaner imports

Co-authored-by: Mike Bostock <mbostock@gmail.com>
  • Loading branch information
Fil and mbostock committed Jun 5, 2021
1 parent 8d3f3a9 commit 1b961c8
Show file tree
Hide file tree
Showing 53 changed files with 2,639 additions and 2,981 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.json
Expand Up @@ -4,11 +4,6 @@
"sourceType": "module",
"ecmaVersion": 8
},
"env": {
"es6": true,
"node": true,
"browser": true
},
"rules": {
"no-cond-assign": 0,
"no-constant-condition": 0,
Expand Down
18 changes: 18 additions & 0 deletions .github/eslint.json
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "eslint-compact",
"pattern": [
{
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yml
@@ -0,0 +1,30 @@
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: |
echo ::add-matcher::.github/eslint.json
yarn run eslint src test --format=compact
- run: yarn test
40 changes: 13 additions & 27 deletions LICENSE
@@ -1,30 +1,16 @@
Copyright 2010-2016 Mike Bostock
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright 2010-2021 Mike Bostock

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

This license applies to GeographicLib, versions 1.12 and later.

Expand Down
23 changes: 18 additions & 5 deletions README.md
Expand Up @@ -22,15 +22,28 @@ D3 uses [GeoJSON](http://geojson.org/geojson-spec.html) to represent geographic

## Installing

If you use NPM, `npm install d3-geo`. Otherwise, download the [latest release](https://github.com/d3/d3-geo/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-geo.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
If you use npm, `npm install d3-geo`. You can also download the [latest release on GitHub](https://github.com/d3/d3-geo/releases/latest). For vanilla HTML in modern browsers, import d3-geo from Skypack:

```html
<script src="https://d3js.org/d3-array.v2.min.js"></script>
<script src="https://d3js.org/d3-geo.v2.min.js"></script>
<script type="module">
import {geoEqualEarth, geoPath} from "https://cdn.skypack.dev/d3-geo@3";
const projection = geoEqualEarth();
const path = geoPath(projection);
</script>
```

For legacy environments, you can load d3-geo’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported:

```html
<script src="https://cdn.jsdelivr.net/npm/d3-array@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-geo@3"></script>
<script>
var projection = d3.geoEqualEarth(),
path = d3.geoPath(projection);
const projection = d3.geoEqualEarth();
const path = d3.geoPath(projection);
</script>
```
Expand Down
17 changes: 0 additions & 17 deletions d3-geo.sublime-project

This file was deleted.

54 changes: 30 additions & 24 deletions package.json
Expand Up @@ -2,50 +2,56 @@
"name": "d3-geo",
"version": "2.0.1",
"description": "Shapes and calculators for spherical coordinates.",
"homepage": "https://d3js.org/d3-geo/",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3-geo.git"
},
"keywords": [
"d3",
"d3-module",
"geo",
"maps",
"cartography"
],
"homepage": "https://d3js.org/d3-geo/",
"license": "BSD-3-Clause",
"license": "ISC",
"author": {
"name": "Mike Bostock",
"url": "https://bost.ocks.org/mike"
},
"main": "dist/d3-geo.js",
"unpkg": "dist/d3-geo.min.js",
"jsdelivr": "dist/d3-geo.min.js",
"module": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3-geo.git"
},
"type": "module",
"files": [
"dist/**/*.js",
"src/**/*.js"
],
"scripts": {
"pretest": "rollup -c",
"test": "tape -r esm 'test/**/*-test.js' && eslint src",
"prepublishOnly": "rm -rf dist && yarn test && mkdir -p test/output && test/compare-images",
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"
"module": "src/index.js",
"main": "src/index.js",
"jsdelivr": "dist/d3-geo.min.js",
"unpkg": "dist/d3-geo.min.js",
"exports": {
"umd": "./dist/d3-geo.min.js",
"default": "./src/index.js"
},
"sideEffects": false,
"dependencies": {
"d3-array": "^2.5.0"
"d3-array": "2.5.0 - 3"
},
"sideEffects": false,
"devDependencies": {
"canvas": "1 - 2",
"d3-format": "1 - 2",
"eslint": "6",
"esm": "3",
"rollup": "1",
"rollup-plugin-terser": "5",
"tape": "4",
"canvas": "2",
"d3-format": "1 - 3",
"eslint": "7",
"mocha": "8",
"rollup": "2",
"rollup-plugin-terser": "7",
"topojson-client": "3",
"world-atlas": "1"
},
"scripts": {
"test": "mocha 'test/**/*-test.js' && eslint src test",
"prepublishOnly": "rm -rf dist && yarn test && rollup -c && mkdir -p test/output && test/compare-images",
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd -"
},
"engines": {
"node": ">=12"
}
}
5 changes: 1 addition & 4 deletions src/polygonContains.js
Expand Up @@ -3,10 +3,7 @@ import {cartesian, cartesianCross, cartesianNormalizeInPlace} from "./cartesian.
import {abs, asin, atan2, cos, epsilon, epsilon2, halfPi, pi, quarterPi, sign, sin, tau} from "./math.js";

function longitude(point) {
if (abs(point[0]) <= pi)
return point[0];
else
return sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);
return abs(point[0]) <= pi ? point[0] : sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);
}

export default function(polygon, point) {
Expand Down
11 changes: 11 additions & 0 deletions test/.eslintrc.json
@@ -0,0 +1,11 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
},
"env": {
"mocha": true,
"node": true
}
}

0 comments on commit 1b961c8

Please sign in to comment.