Skip to content

Commit 05982a5

Browse files
committed
Bundle geoip-location
1 parent 9f2d6f3 commit 05982a5

File tree

5 files changed

+159
-10
lines changed

5 files changed

+159
-10
lines changed

Dockerfile.node

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUN --mount=type=cache,target=/root/.npm \
77
npm run bootstrap-pkg --package=@streamr/proto-rpc && \
88
npm run bootstrap-pkg --package=@streamr/autocertifier-client && \
99
npm run bootstrap-pkg --package=@streamr/cdn-location && \
10+
npm run bootstrap-pkg --package=@streamr/geoip-location && \
1011
npm run bootstrap-pkg --package=@streamr/dht && \
1112
npm run bootstrap-pkg --package=@streamr/trackerless-network && \
1213
npm run bootstrap-pkg --package=@streamr/sdk && \

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: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
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
15-
},
16-
"types": "dist/src/exports.d.ts",
10+
"main": "./dist/exports.cjs",
11+
"module": "./dist/exports.js",
12+
"types": "./dist/exports.d.ts",
1713
"files": [
1814
"dist",
15+
"!dist/src",
1916
"!*.tsbuildinfo",
2017
"README.md",
2118
"LICENSE"
2219
],
2320
"license": "Apache-2.0",
2421
"author": "Streamr Network AG <contact@streamr.network>",
2522
"scripts": {
23+
"prebuild": "npm run reset-self",
2624
"build": "tsc -b",
25+
"postbuild": "NODE_OPTIONS='--import tsx' rollup -c rollup.config.mts",
2726
"check": "tsc -p tsconfig.jest.json",
27+
"reset-self": "rimraf --glob 'dist/**/*.tsbuildinfo'",
2828
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2929
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
3030
"test": "jest test/unit",
@@ -39,8 +39,13 @@
3939
"uuid": "^11.1.0"
4040
},
4141
"devDependencies": {
42+
"@rollup/plugin-node-resolve": "^16.0.3",
4243
"@types/long-timeout": "^0.1.2",
4344
"@types/tar": "^6.1.11",
44-
"express": "^5.2.0"
45+
"express": "^5.2.0",
46+
"rimraf": "^6.1.2",
47+
"rollup": "^4.55.1",
48+
"rollup-plugin-dts": "^6.3.0",
49+
"tsx": "^4.21.0"
4550
}
4651
}
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/exports.js',
17+
sourcemap: true,
18+
},
19+
{
20+
format: 'cjs',
21+
file: './dist/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/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)