From 920144610e1a6127f2e1ed4b15e90b3f43b02993 Mon Sep 17 00:00:00 2001 From: Curran Kelleher Date: Sat, 12 Sep 2020 09:53:42 -0400 Subject: [PATCH 1/2] Add fit methods. Adopt Prettier --- package.json | 11 ++++++++--- rollup.config.js | 6 +++--- src/index.js | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 526141a..dfad732 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,11 @@ "main": "dist/geo-albers-usa-territories.js", "scripts": { "prepublish": "rollup --config", - "postpublish": "git push && git push --tags" + "postpublish": "git push && git push --tags", + "prettier": "prettier './src/**/*.js' --write" + }, + "prettier": { + "singleQuote": true }, "repository": { "type": "git", @@ -31,8 +35,9 @@ }, "homepage": "https://github.com/stamen/geo-albers-usa-territories#readme", "devDependencies": { - "rollup": "^2.26.11", - "d3-geo": "^2.0.1" + "d3-geo": "^2.0.1", + "prettier": "^2.1.1", + "rollup": "^2.26.11" }, "peerDependencies": { "d3-geo": "^2.0.1" diff --git a/rollup.config.js b/rollup.config.js index 26e450e..b99ad52 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,7 +6,7 @@ export default { format: 'umd', name: 'geoAlbersUsaTerritories', globals: { - 'd3-geo': 'd3' - } - } + 'd3-geo': 'd3', + }, + }, }; diff --git a/src/index.js b/src/index.js index 47ead18..3342c70 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ import { geoAlbers, geoConicEqualArea } from 'd3-geo'; +import { fitExtent, fitSize, fitWidth, fitHeight } from 'd3-geo/src/fit.js'; var epsilon = 0.000001; @@ -186,6 +187,22 @@ export function geoAlbersUsaTerritories() { return reset(); }; + albersUsaTerritories.fitExtent = function (extent, object) { + return fitExtent(albersUsaTerritories, extent, object); + }; + + albersUsaTerritories.fitSize = function (size, object) { + return fitSize(albersUsaTerritories, size, object); + }; + + albersUsaTerritories.fitWidth = function (width, object) { + return fitWidth(albersUsaTerritories, width, object); + }; + + albersUsaTerritories.fitHeight = function (height, object) { + return fitHeight(albersUsaTerritories, height, object); + }; + function reset() { cache = cacheStream = null; return albersUsaTerritories; From 50c88150e5561e495b46f0ba1e69733a5935be73 Mon Sep 17 00:00:00 2001 From: Curran Kelleher Date: Sat, 12 Sep 2020 10:18:07 -0400 Subject: [PATCH 2/2] Attempt to import fit internals via Rollup --- package.json | 6 ++++-- rollup.config.js | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index dfad732..f54cfd0 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "prepublish": "rollup --config", "postpublish": "git push && git push --tags", - "prettier": "prettier './src/**/*.js' --write" + "prettier": "prettier './src/**/*.js' 'rollup.config.js' --write" }, "prettier": { "singleQuote": true @@ -35,9 +35,11 @@ }, "homepage": "https://github.com/stamen/geo-albers-usa-territories#readme", "devDependencies": { + "@rollup/plugin-node-resolve": "^9.0.0", "d3-geo": "^2.0.1", "prettier": "^2.1.1", - "rollup": "^2.26.11" + "rollup": "^2.26.11", + "rollup-plugin-commonjs": "^10.1.0" }, "peerDependencies": { "d3-geo": "^2.0.1" diff --git a/rollup.config.js b/rollup.config.js index b99ad52..949e580 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,12 +1,18 @@ +import { nodeResolve } from '@rollup/plugin-node-resolve'; +import commonjs from 'rollup-plugin-commonjs'; + export default { input: 'src/index.js', - external: ['d3-geo'], output: { file: 'dist/geo-albers-usa-territories.js', format: 'umd', name: 'geoAlbersUsaTerritories', - globals: { - 'd3-geo': 'd3', - }, }, + // external: ['d3-geo', 'd3-geo/src/fit.js'], + plugins: [ + nodeResolve(), + commonjs({ + include: 'node_modules/**', + }), + ], };