Skip to content

Commit 457fd9e

Browse files
committed
Bundle cdn-location
1 parent e9c757c commit 457fd9e

File tree

4 files changed

+166
-6
lines changed

4 files changed

+166
-6
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/cdn-location/package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,29 @@
77
"url": "git+https://github.com/streamr-dev/network.git",
88
"directory": "packages/cdn-location"
99
},
10-
"main": "dist/src/exports.js",
11-
"types": "dist/src/exports.d.ts",
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+
}
18+
},
1219
"files": [
13-
"dist",
20+
"dist/src/exports.*",
1421
"!*.tsbuildinfo",
1522
"README.md",
1623
"LICENSE"
1724
],
1825
"license": "Apache-2.0",
1926
"author": "Streamr Network AG <[email protected]>",
2027
"scripts": {
28+
"prebuild": "npm run reset-self",
2129
"build": "tsc -b",
30+
"postbuild": "NODE_OPTIONS='--import tsx' rollup -c rollup.config.mts",
2231
"check": "tsc -p tsconfig.jest.json",
32+
"reset-self": "rimraf --glob '**/*.tsbuildinfo'",
2333
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
2434
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
2535
"test": "jest test/integration",
@@ -32,6 +42,11 @@
3242
"haversine": "^1.1.1"
3343
},
3444
"devDependencies": {
35-
"@types/haversine": "^1.1.8"
45+
"@rollup/plugin-node-resolve": "^16.0.3",
46+
"@types/haversine": "^1.1.8",
47+
"rimraf": "^6.1.2",
48+
"rollup": "^4.53.5",
49+
"rollup-plugin-dts": "^6.3.0",
50+
"tsx": "^4.21.0"
3651
}
3752
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
{
42+
file: './dist/src/exports.d.ts',
43+
},
44+
],
45+
plugins: [
46+
nodeResolve(),
47+
dts(),
48+
],
49+
external: [
50+
/node_modules/,
51+
/@streamr\//,
52+
],
53+
}
54+
}

packages/cdn-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)