Skip to content

Commit e010291

Browse files
committed
export node apart from browser
Following the same PR in hyparquet: hyparam/hyparquet#80 Also: fixed a circular import message when building, by updating to hyparquet 1.17.3.
1 parent eac001c commit e010291

File tree

12 files changed

+74
-5
lines changed

12 files changed

+74
-5
lines changed

package.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"url": "git+https://github.com/hyparam/geoparquet.git"
1919
},
2020
"dependencies": {
21-
"hyparquet": "1.17.2"
21+
"hyparquet": "1.17.3"
2222
},
2323
"devDependencies": {
2424
"@rollup/plugin-node-resolve": "16.0.1",
@@ -34,15 +34,29 @@
3434
"vitest": "3.2.4"
3535
},
3636
"files": [
37-
"src"
37+
"src",
38+
"types"
3839
],
40+
"type": "module",
41+
"types": "types/index.d.ts",
3942
"main": "src/index.js",
43+
"exports": {
44+
"browser": {
45+
"types": "./types/index.d.ts",
46+
"import": "./src/index.js"
47+
},
48+
"default": {
49+
"types": "./types/node.d.ts",
50+
"import": "./src/node.js"
51+
}
52+
},
4053
"scripts": {
4154
"build": "rollup -c",
55+
"build:types": "tsc -p ./tsconfig.lib.json",
4256
"coverage": "vitest run --coverage --coverage.include=src",
4357
"lint": "eslint",
58+
"prepare": "npm run build:types",
4459
"start": "http-server -a localhost",
4560
"test": "vitest run"
46-
},
47-
"type": "module"
61+
}
4862
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export { asyncBufferFromFile, asyncBufferFromUrl } from 'hyparquet'
1+
export { asyncBufferFromUrl } from 'hyparquet'
22
export { toGeoJson } from './toGeoJson.js'
33
export { decodeWKB } from './wkb.js'

src/node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { asyncBufferFromFile } from 'hyparquet'
2+
export * from './index.js'

tsconfig.lib.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": false,
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"outDir": "types",
8+
"lib": ["esnext", "dom"],
9+
"declarationMap": true
10+
},
11+
"include": ["src"]
12+
}
13+

types/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { asyncBufferFromUrl } from "hyparquet";
2+
export { toGeoJson } from "./toGeoJson.js";
3+
export { decodeWKB } from "./wkb.js";
4+
//# sourceMappingURL=index.d.ts.map

types/index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/node.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { asyncBufferFromFile } from "hyparquet";
2+
export * from "./index.js";
3+
//# sourceMappingURL=node.d.ts.map

types/node.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/toGeoJson.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Convert a GeoParquet file to GeoJSON.
3+
* Input is an AsyncBuffer representing a GeoParquet file.
4+
* An AsyncBuffer is a buffer-like object that can be read asynchronously.
5+
*
6+
* @import { AsyncBuffer, Compressors } from 'hyparquet'
7+
* @import { Feature, GeoJSON } from './geojson.js'
8+
* @param {Object} options
9+
* @param {AsyncBuffer} options.file
10+
* @param {Compressors} [options.compressors]
11+
* @returns {Promise<GeoJSON>}
12+
*/
13+
export function toGeoJson({ file, compressors }: {
14+
file: AsyncBuffer;
15+
compressors?: import("hyparquet/src/types.js").Compressors | undefined;
16+
}): Promise<GeoJSON>;
17+
import type { AsyncBuffer } from 'hyparquet';
18+
import type { GeoJSON } from './geojson.js';
19+
//# sourceMappingURL=toGeoJson.d.ts.map

types/toGeoJson.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)