Skip to content

Commit

Permalink
Adopt type: module. (#3506)
Browse files Browse the repository at this point in the history
* remove Sublime project

* adopt type=module; update dependencies

* type: module

* GitHub actions
  • Loading branch information
mbostock committed Jun 11, 2021
1 parent 0f01226 commit 23b0212
Show file tree
Hide file tree
Showing 16 changed files with 1,406 additions and 682 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,7 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
}
}
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
14 changes: 12 additions & 2 deletions CHANGES.md
@@ -1,9 +1,19 @@
# Changes in D3 6.0
# Changes in D3 7.0

[Released August 26, 2020.](https://github.com/d3/d3/releases/tag/v6.0.0)
[Released June 11, 2021.](https://github.com/d3/d3/releases/tag/v7.0.0)

*This document covers only major changes. For minor and patch changes, please see the [release notes](https://github.com/d3/d3/releases).*

D3 now ships as pure ES modules, requiring Node.js 12 or higher. For more, please read [Sindre Sorhus’s FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).

[d3.bin](https://github.com/d3/d3-array/blob/main/README.md#bin) now ignores nulls. [d3.ascending](https://github.com/d3/d3-array/blob/main/README.md#ascending) and [d3.descending](https://github.com/d3/d3-array/blob/main/README.md#descending) no longer consider null comparable.

[Ordinal scales](https://github.com/d3/d3-scale/blob/main/README.md#ordinal-scales) now use [InternMap](https://github.com/mbostock/internmap) for domains; domain values are now uniqued by coercing to a primitive value via *object*.valueOf instead of coercing to a string via *object*.toString.

# Changes in D3 6.0

[Released August 26, 2020.](https://github.com/d3/d3/releases/tag/v6.0.0)

D3 now **uses native collections** (Map and Set) and **accepts iterables**. [d3.group and d3.rollup](https://observablehq.com/@d3/d3-group) are powerful new aggregation functions that replace d3.nest and work great [with d3-hierarchy](https://observablehq.com/d/9a453665f405eebf) and d3-selection. There are lots of new helpers in d3-array, too, such as [d3.greatest](https://observablehq.com/@d3/d3-least), [d3.quickselect](https://observablehq.com/@d3/d3-quickselect), and [d3.fsum](https://observablehq.com/@d3/d3-fsum).

D3 now **passes events directly to listeners**, replacing the d3.event global and bringing D3 inline with vanilla JavaScript and most other frameworks.
Expand Down
8 changes: 4 additions & 4 deletions ISSUE_TEMPLATE.md
Expand Up @@ -4,9 +4,9 @@ If you ignore this message and ask for help anyway, your issue will be closed wi

If you want help, please try one of the following forums instead:

Stack Overflow: https://stackoverflow.com/questions/tagged/d3.js
Slack: https://d3-slackin.herokuapp.com/
Google Groups: https://groups.google.com/d/forum/d3-js
Observable: https://observablehq.com/@d3
Observable: https://talk.observablehq.com/
Stack Overflow: https://stackoverflow.com/questions/tagged/d3.js
Slack: https://d3-slackin.herokuapp.com/
Google Groups: https://groups.google.com/d/forum/d3-js

ARE YOU REPORTING A BUG, OR MAKING A FEATURE REQUEST? Please file an issue on the relevant D3 module, not here; see https://github.com/d3. Please isolate the specific methods that exhibit unexpected behavior and precisely describe how your expectations were not met.
40 changes: 13 additions & 27 deletions LICENSE
@@ -1,27 +1,13 @@
Copyright 2010-2020 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.
29 changes: 23 additions & 6 deletions README.md
Expand Up @@ -14,25 +14,42 @@

## Installing

If you use npm, `npm install d3`. Otherwise, download the [latest release](https://github.com/d3/d3/releases/latest). The released bundle supports anonymous AMD, CommonJS, and vanilla environments. You can load directly from [d3js.org](https://d3js.org), [CDNJS](https://cdnjs.com/libraries/d3), or [unpkg](https://unpkg.com/d3/). For example:
If you use npm, `npm install d3`. You can also download the [latest release on GitHub](https://github.com/d3/d3/releases/latest). For vanilla HTML in modern browsers, import D3 from Skypack:

```html
<script src="https://d3js.org/d3.v6.js"></script>
<script type="module">
import * as d3 from "https://cdn.skypack.dev/d3@7";
const div = d3.selectAll("div");
</script>
```

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

```html
<script src="https://d3js.org/d3.v6.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
<script>
const div = d3.selectAll("div");
</script>
```

You can also use the standalone D3 microlibraries. For example, [d3-selection](https://github.com/d3/d3-selection):

```html
<script src="https://d3js.org/d3-selection.v2.js"></script>
<script type="module">
import {selectAll} from "https://cdn.skypack.dev/d3-selection@3";
const div = selectAll("div");
</script>
```

D3 is written using [ES2015 modules](http://www.2ality.com/2014/09/es6-modules-final.html). Create a [custom bundle using Rollup](https://bl.ocks.org/mbostock/bb09af4c39c79cffcde4), Webpack, or your preferred bundler. To import D3 into an ES2015 application, either import specific symbols from specific D3 modules:
D3 is written using [ES2015 modules](http://www.2ality.com/2014/09/es6-modules-final.html). Create a custom bundle using Rollup, Webpack, or your preferred bundler. To import D3 into an ES2015 application, either import specific symbols from specific D3 modules:

```js
import {scaleLinear} from "d3-scale";
Expand Down
2 changes: 2 additions & 0 deletions bundle.js
@@ -0,0 +1,2 @@
export {version} from "./package.json";
export * from "./src/index.js";
17 changes: 0 additions & 17 deletions d3.sublime-project

This file was deleted.

113 changes: 60 additions & 53 deletions package.json
Expand Up @@ -2,77 +2,84 @@
"name": "d3",
"version": "6.7.0",
"description": "Data-Driven Documents",
"homepage": "https://d3js.org",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3.git"
},
"keywords": [
"d3",
"dom",
"visualization",
"svg",
"animation",
"canvas"
],
"homepage": "https://d3js.org",
"license": "BSD-3-Clause",
"license": "ISC",
"author": {
"name": "Mike Bostock",
"url": "https://bost.ocks.org/mike"
},
"main": "dist/d3.node.js",
"unpkg": "dist/d3.min.js",
"jsdelivr": "dist/d3.min.js",
"module": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3.git"
},
"type": "module",
"files": [
"dist/**/*.js",
"index.js"
"src/**/*.js"
],
"scripts": {
"pretest": "rimraf dist && mkdir dist && json2module package.json > dist/package.js && rollup -c",
"test": "tape 'test/**/*-test.js'",
"prepublishOnly": "yarn test",
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../d3/dist/d3.js d3.v${npm_package_version%%.*}.js && cp ../d3/dist/d3.min.js d3.v${npm_package_version%%.*}.min.js && git add d3.v${npm_package_version%%.*}.js d3.v${npm_package_version%%.*}.min.js && git commit -m \"d3 ${npm_package_version}\" && git push && cd - && zip -j dist/d3.zip -- LICENSE README.md API.md CHANGES.md dist/d3.js dist/d3.min.js"
"module": "src/index.js",
"main": "src/index.js",
"jsdelivr": "dist/d3.min.js",
"unpkg": "dist/d3.min.js",
"exports": {
"umd": "./dist/d3.min.js",
"default": "./src/index.js"
},
"dependencies": {
"d3-array": "3",
"d3-axis": "3",
"d3-brush": "3",
"d3-chord": "3",
"d3-color": "3",
"d3-contour": "3",
"d3-delaunay": "6",
"d3-dispatch": "3",
"d3-drag": "3",
"d3-dsv": "3",
"d3-ease": "3",
"d3-fetch": "3",
"d3-force": "3",
"d3-format": "3",
"d3-geo": "3",
"d3-hierarchy": "3",
"d3-interpolate": "3",
"d3-path": "3",
"d3-polygon": "3",
"d3-quadtree": "3",
"d3-random": "3",
"d3-scale": "4",
"d3-scale-chromatic": "3",
"d3-selection": "3",
"d3-shape": "3",
"d3-time": "3",
"d3-time-format": "4",
"d3-timer": "3",
"d3-transition": "3",
"d3-zoom": "3"
},
"devDependencies": {
"json2module": "0.0",
"rimraf": "3",
"@rollup/plugin-json": "4",
"@rollup/plugin-node-resolve": "13",
"eslint": "7",
"mocha": "9",
"rollup": "2",
"rollup-plugin-ascii": "0.0",
"rollup-plugin-node-resolve": "5",
"rollup-plugin-terser": "7",
"tape": "4",
"tape-await": "0.1"
"rollup-plugin-terser": "7"
},
"dependencies": {
"d3-array": "2",
"d3-axis": "2",
"d3-brush": "2",
"d3-chord": "2",
"d3-color": "2",
"d3-contour": "2",
"d3-delaunay": "5",
"d3-dispatch": "2",
"d3-drag": "2",
"d3-dsv": "2",
"d3-ease": "2",
"d3-fetch": "2",
"d3-force": "2",
"d3-format": "2",
"d3-geo": "2",
"d3-hierarchy": "2",
"d3-interpolate": "2",
"d3-path": "2",
"d3-polygon": "2",
"d3-quadtree": "2",
"d3-random": "2",
"d3-scale": "3",
"d3-scale-chromatic": "2",
"d3-selection": "2",
"d3-shape": "2",
"d3-time": "2",
"d3-time-format": "3",
"d3-timer": "2",
"d3-transition": "2",
"d3-zoom": "2"
"scripts": {
"test": "mocha 'test/**/*-test.js' && eslint src test",
"prepublishOnly": "rm -rf dist && yarn test && rollup -c && git push",
"postpublish": "git push --tags && cd ../d3.github.com && git pull && cp ../d3/dist/d3.js d3.v${npm_package_version%%.*}.js && cp ../d3/dist/d3.min.js d3.v${npm_package_version%%.*}.min.js && git add d3.v${npm_package_version%%.*}.js d3.v${npm_package_version%%.*}.min.js && git commit -m \"d3 ${npm_package_version}\" && git push && cd -"
},
"engines": {
"node": ">=12"
}
}

0 comments on commit 23b0212

Please sign in to comment.