Skip to content

Commit 222c6bc

Browse files
authored
fix: use correct build for publish (#230)
1 parent f1c195b commit 222c6bc

File tree

8 files changed

+272
-251
lines changed

8 files changed

+272
-251
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ node_modules/
3232
/ts/*/*.d.ts
3333
/ts/*/*.js.map
3434
/ts/*/*.js
35+
/ts/*/*.tgz

package-lock.json

+229-246
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@vaadin/observability-kit-monorepo",
33
"private": true,
44
"description": "Observability Kit monorepo",
5-
"main": "index.js",
5+
"main": "",
66
"type": "module",
77
"engines": {
88
"node": ">=16.19.0",
@@ -13,6 +13,7 @@
1313
"build": "nx run-many -t build --all",
1414
"lint": "nx run-many -t lint --all",
1515
"test": "echo \"Error: no test specified\" && exit 1",
16+
"prepare": "npm run build",
1617
"typecheck": "nx run-many -t typecheck --all"
1718
},
1819
"repository": {
@@ -32,6 +33,7 @@
3233
"esbuild": "^0.17.19",
3334
"eslint": "^8.38.0",
3435
"eslint-config-vaadin": "^1.0.0-alpha.12",
36+
"glob": "^10.2.7",
3537
"karma": "^6.4.2",
3638
"karma-chrome-launcher": "^3.2.0",
3739
"karma-coverage": "^2.2.0",

scripts/build.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { readFile } from 'node:fs/promises';
2+
import { sep } from 'node:path';
3+
import { fileURLToPath, pathToFileURL } from 'url';
4+
import { build } from 'esbuild';
5+
import { glob } from 'glob';
6+
import type { PackageJson } from 'type-fest';
7+
8+
const root = pathToFileURL(process.cwd() + sep);
9+
const [packageJsonFile, srcFiles] = await Promise.all([
10+
readFile(new URL('package.json', root), 'utf8'),
11+
glob('src/**/*.ts'),
12+
]);
13+
14+
const packageJson: PackageJson = JSON.parse(packageJsonFile);
15+
16+
await build({
17+
define: {
18+
__VERSION__: `'${packageJson.version ?? '0.0.0'}'`,
19+
},
20+
entryPoints: srcFiles.map((file) => new URL(file, root)).map(fileURLToPath),
21+
minify: true,
22+
outdir: fileURLToPath(root),
23+
sourcemap: 'linked',
24+
sourcesContent: true,
25+
tsconfig: fileURLToPath(new URL('./tsconfig.build.json', root)),
26+
});

ts/observability-kit-client/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
"*.{d.ts.map,d.ts,js.map,js}"
1515
],
1616
"scripts": {
17-
"build": "tsc -p tsconfig.build.json",
17+
"build": "concurrently npm:build:code npm:build:dts",
18+
"build:code": "tsx ../../scripts/build.ts",
19+
"build:dts": "tsc -p tsconfig.build.json",
1820
"lint": "eslint src/**/*.ts",
21+
"postversion": "npm run build",
1922
"typecheck": "tsc --noEmit"
2023
},
2124
"exports": {

ts/observability-kit-client/src/FrontendErrorInstrumentation.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
55

66
export class FrontendErrorInstrumentation extends InstrumentationBase {
77
readonly component: string = 'frontend-error';
8-
moduleName = this.component;
8+
moduleName: string;
99
readonly version: string = '1';
1010
#listenerControllers = new Map<keyof WindowEventMap, AbortController>();
1111

1212
constructor(config: InstrumentationConfig = { enabled: true }) {
1313
// Avoid issue when `enable` is called in the super constructor and fails
1414
// because of private methods
1515
super('@vaadin/frontend-error-instrumentation', '2.1-SNAPSHOT', { enabled: false });
16+
this.moduleName = this.component;
17+
1618
if (config.enabled) {
1719
this.enable();
1820
}

ts/observability-kit-client/src/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export * from './HillaEndpointExporter.js';
22
export * from './init.js';
33

4+
declare const __VERSION__: string;
5+
46
declare global {
57
interface VaadinRegistration {
68
is: string;
@@ -20,5 +22,5 @@ window.Vaadin ??= {};
2022
window.Vaadin.registrations ??= [];
2123
window.Vaadin.registrations.push({
2224
is: '@hilla/observability-kit-client',
23-
version: /* updated-by-script */ '2.1-alpha.0',
25+
version: __VERSION__,
2426
});
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4+
"alwaysStrict": false,
45
"rootDir": "src",
5-
"outDir": "."
6+
"outDir": ".",
7+
"emitDeclarationOnly": true
68
},
79
"include": ["src"]
810
}

0 commit comments

Comments
 (0)