Skip to content

Commit 6674754

Browse files
committed
Bundle geoip-location
1 parent 457fd9e commit 6674754

File tree

4 files changed

+163
-10
lines changed

4 files changed

+163
-10
lines changed

package-lock.json

Lines changed: 87 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/geoip-location/package.json

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,29 @@
77
"url": "git+https://github.com/streamr-dev/network.git",
88
"directory": "packages/geoip-location"
99
},
10-
"main": "dist/src/exports.js",
11-
"browser": {
12-
"dist/src/exports.js": false,
13-
"dist/src/GeoIpLocator.js": false,
14-
"dist/src/downloadGeoIpDatabase.js": false
10+
"exports": {
11+
".": {
12+
"default": {
13+
"types": "./dist/src/exports.d.ts",
14+
"import": "./dist/src/exports.js",
15+
"require": "./dist/src/exports.cjs"
16+
}
17+
}
1518
},
16-
"types": "dist/src/exports.d.ts",
1719
"files": [
18-
"dist",
20+
"dist/src/exports.*",
1921
"!*.tsbuildinfo",
2022
"README.md",
2123
"LICENSE"
2224
],
2325
"license": "Apache-2.0",
2426
"author": "Streamr Network AG <contact@streamr.network>",
2527
"scripts": {
28+
"prebuild": "npm run reset-self",
2629
"build": "tsc -b",
30+
"postbuild": "NODE_OPTIONS='--import tsx' rollup -c rollup.config.mts",
2731
"check": "tsc -p tsconfig.jest.json",
32+
"reset-self": "rimraf --glob '**/*.tsbuildinfo'",
2833
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2934
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3035
"test": "jest test/unit",
@@ -39,8 +44,13 @@
3944
"uuid": "^11.1.0"
4045
},
4146
"devDependencies": {
47+
"@rollup/plugin-node-resolve": "^16.0.3",
4248
"@types/long-timeout": "^0.1.2",
4349
"@types/tar": "^6.1.11",
44-
"express": "^5.2.0"
50+
"express": "^5.2.0",
51+
"rimraf": "^6.1.2",
52+
"rollup": "^4.53.5",
53+
"rollup-plugin-dts": "^6.3.0",
54+
"tsx": "^4.21.0"
4555
}
4656
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { defineConfig, type RollupOptions } from 'rollup'
2+
import { dts } from 'rollup-plugin-dts'
3+
import { nodeResolve } from '@rollup/plugin-node-resolve'
4+
5+
export default defineConfig([
6+
nodejs(),
7+
nodejsTypes(),
8+
])
9+
10+
function nodejs(): RollupOptions {
11+
return {
12+
input: './dist/src/exports.js',
13+
output: [
14+
{
15+
format: 'es',
16+
file: './dist/src/exports.js',
17+
sourcemap: true,
18+
},
19+
{
20+
format: 'cjs',
21+
file: './dist/src/exports.cjs',
22+
sourcemap: true,
23+
},
24+
],
25+
plugins: [
26+
nodeResolve({
27+
preferBuiltins: true,
28+
}),
29+
],
30+
external: [
31+
/node_modules/,
32+
/@streamr\//,
33+
],
34+
}
35+
}
36+
37+
function nodejsTypes(): RollupOptions {
38+
return {
39+
input: './dist/src/exports.d.ts',
40+
output: [
41+
{ file: './dist/src/exports.d.ts' },
42+
],
43+
plugins: [
44+
nodeResolve(),
45+
dts(),
46+
],
47+
external: [
48+
/node_modules/,
49+
/@streamr\//,
50+
],
51+
}
52+
}

packages/geoip-location/tsconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"extends": "../../tsconfig.node.json",
33
"compilerOptions": {
4-
"outDir": "dist"
4+
"outDir": "dist",
5+
6+
/* Resolution */
7+
"module": "preserve",
8+
"moduleResolution": "bundler",
9+
"baseUrl": "."
510
},
611
"include": [
712
"src"

0 commit comments

Comments
 (0)