diff --git a/package.json b/package.json index 526141a..f54cfd0 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' 'rollup.config.js' --write" + }, + "prettier": { + "singleQuote": true }, "repository": { "type": "git", @@ -31,8 +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", - "d3-geo": "^2.0.1" + "rollup-plugin-commonjs": "^10.1.0" }, "peerDependencies": { "d3-geo": "^2.0.1" diff --git a/rollup.config.js b/rollup.config.js index 26e450e..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/**', + }), + ], }; 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;