Skip to content

Commit 2b67985

Browse files
authored
export node apart from browser (#12)
* 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. * git ignore generated types * fix import path
1 parent eac001c commit 2b67985

File tree

7 files changed

+37
-7
lines changed

7 files changed

+37
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
package-lock.json
33
coverage
44
*.tgz
5+
/types

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'

src/toGeoJson.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { decodeWKB } from './wkb.js'
77
* An AsyncBuffer is a buffer-like object that can be read asynchronously.
88
*
99
* @import { AsyncBuffer, Compressors } from 'hyparquet'
10-
* @import { Feature, GeoJSON } from './geojson.js'
10+
* @import { Feature, GeoJSON } from '../src/geojson.js'
1111
* @param {Object} options
1212
* @param {AsyncBuffer} options.file
1313
* @param {Compressors} [options.compressors]

src/wkb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const geometryTypeCompoundSurface = 24
2727
/**
2828
* WKB (Well Known Binary) decoder for geometry objects.
2929
*
30-
* @import { Geometry } from './geojson.js'
30+
* @import { Geometry } from '../src/geojson.js'
3131
* @param {Uint8Array} wkb
3232
* @returns {Geometry} GeoJSON geometry object
3333
*/

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+

0 commit comments

Comments
 (0)