Skip to content

Commit 894e970

Browse files
committed
WIP react support with sub-package
1 parent af297a6 commit 894e970

File tree

10 files changed

+168
-105
lines changed

10 files changed

+168
-105
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": "../../config/api-extractor.json",
3+
"mainEntryPointFilePath": "<projectFolder>/dist/react/index.d.ts",
4+
"dtsRollup": {
5+
"enabled": true,
6+
"untrimmedFilePath": "<projectFolder>/dist/react/index.d.ts"
7+
},
8+
"apiReport": {
9+
"enabled": false
10+
},
11+
"docModel": {
12+
"enabled": false
13+
},
14+
"tsdocMetadata": {
15+
"enabled": false
16+
}
17+
}

packages/telemetry/index.node.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ registerTelemetry();
2929
export * from './src/api';
3030
export * from './src/public-types';
3131
export * from './src/next';
32-
export * from './src/react';

packages/telemetry/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ registerTelemetry();
2222
export * from './src/api';
2323
export * from './src/public-types';
2424
export * from './src/next';
25-
export * from './src/react';

packages/telemetry/package.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@
1919
},
2020
"default": "./dist/index.esm.js"
2121
},
22+
"./react": {
23+
"types": "./dist/react/index.d.ts",
24+
"node": {
25+
"import": "./dist/react-node-esm/index.node.esm.js",
26+
"default": "./dist/react.node.cjs.js"
27+
},
28+
"browser": {
29+
"require": "./dist/react.cjs.js",
30+
"import": "./dist/react.esm.js"
31+
},
32+
"default": "./dist/react.esm.js"
33+
},
2234
"./package.json": "./package.json"
2335
},
2436
"files": [
@@ -36,14 +48,24 @@
3648
"test:browser": "karma start",
3749
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha src/**/*.test.* --config ../../config/mocharc.node.js",
3850
"trusted-type-check": "tsec -p tsconfig.json --noEmit",
39-
"api-report": "api-extractor run --local --verbose",
51+
"api-report": "yarn api-report:main && yarn api-report:react",
52+
"api-report:main": "api-extractor run --local --verbose",
53+
"api-report:react": "api-extractor run --config api-extractor.react.json --local --verbose",
4054
"typings:public": "node ../../scripts/build/use_typings.js ./dist/telemetry-public.d.ts"
4155
},
4256
"peerDependencies": {
4357
"@firebase/app": "0.x",
4458
"@firebase/app-types": "0.x",
45-
"@types/react": "19.x",
46-
"react": "19.x"
59+
"@types/react": "17.x || 18.x || 19.x",
60+
"react": "17.x || 18.x || 19.x"
61+
},
62+
"peerDependenciesMeta": {
63+
"react": {
64+
"optional": true
65+
},
66+
"@types/react": {
67+
"optional": true
68+
}
4769
},
4870
"dependencies": {
4971
"@firebase/component": "0.7.0",
@@ -54,7 +76,7 @@
5476
"@opentelemetry/otlp-transformer": "0.205.0",
5577
"@opentelemetry/resources": "2.0.1",
5678
"@opentelemetry/sdk-logs": "0.203.0",
57-
"@opentelemetry/semantic-conventions": "1.36.0",
79+
"@opentelemetry/semantic-conventions": "1.36.0",
5880
"tslib": "^2.1.0"
5981
},
6082
"license": "Apache-2.0",

packages/telemetry/rollup.config.js

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const browserBuilds = [
4141
{
4242
input: 'index.ts',
4343
output: {
44-
file: './dist/index.cjs.js',
44+
file: pkg.exports['.'].browser.require,
4545
format: 'cjs',
4646
sourcemap: true
4747
},
@@ -73,4 +73,100 @@ const nodeBuilds = [
7373
}
7474
];
7575

76-
export default [...browserBuilds, ...nodeBuilds];
76+
const reactBuilds = [
77+
{
78+
input: 'src/react/index.ts',
79+
output: {
80+
file: pkg.exports['./react'].browser.import,
81+
format: 'es',
82+
sourcemap: true,
83+
banner: `'use client';`
84+
},
85+
plugins: [
86+
typescriptPlugin({
87+
typescript,
88+
tsconfigOverride: {
89+
compilerOptions: {
90+
declarationDir: 'dist/react'
91+
}
92+
}
93+
}),
94+
json()
95+
],
96+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
97+
},
98+
{
99+
input: 'src/react/index.ts',
100+
output: {
101+
file: pkg.exports['./react'].browser.require,
102+
format: 'cjs',
103+
sourcemap: true,
104+
banner: `'use client';`
105+
},
106+
plugins: [
107+
typescriptPlugin({
108+
typescript,
109+
tsconfigOverride: {
110+
compilerOptions: {
111+
declarationDir: 'dist/react'
112+
}
113+
}
114+
}),
115+
json()
116+
],
117+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
118+
}
119+
];
120+
121+
const reactNodeBuilds = [
122+
{
123+
input: 'src/react/index.ts',
124+
output: {
125+
file: pkg.exports['./react'].node.default,
126+
format: 'cjs',
127+
sourcemap: true,
128+
banner: `'use client';`
129+
},
130+
plugins: [
131+
typescriptPlugin({
132+
typescript,
133+
tsconfigOverride: {
134+
compilerOptions: {
135+
declarationDir: 'dist/react'
136+
}
137+
}
138+
}),
139+
json()
140+
],
141+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
142+
},
143+
{
144+
input: 'src/react/index.ts',
145+
output: {
146+
file: pkg.exports['./react'].node.import,
147+
format: 'es',
148+
sourcemap: true,
149+
banner: `'use client';`
150+
},
151+
plugins: [
152+
typescriptPlugin({
153+
typescript,
154+
tsconfigOverride: {
155+
compilerOptions: {
156+
declarationDir: 'dist/react'
157+
}
158+
}
159+
}),
160+
json(),
161+
emitModulePackageFile()
162+
],
163+
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
164+
}
165+
];
166+
167+
export default [
168+
...browserBuilds,
169+
...nodeBuilds,
170+
...reactBuilds,
171+
...reactNodeBuilds
172+
];

packages/telemetry/src/react.test.tsx

Lines changed: 0 additions & 57 deletions
This file was deleted.

packages/telemetry/src/react.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
3+
export interface FirebaseTelemetryBoundaryProps {
4+
children: React.ReactNode;
5+
}
6+
7+
export class FirebaseTelemetryBoundary extends React.Component<FirebaseTelemetryBoundaryProps> {
8+
constructor(public props: FirebaseTelemetryBoundaryProps) {
9+
super(props);
10+
11+
console.info('init firebase telemetry boundary');
12+
}
13+
14+
render(): React.ReactNode {
15+
console.info('abc');
16+
return this.props.children;
17+
}
18+
}

packages/telemetry/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"extends": "../../config/tsconfig.base.json",
33
"compilerOptions": {
4-
"outDir": "dist",
5-
"jsx": "react"
4+
"outDir": "dist"
65
},
76
"exclude": ["dist/**/*"]
87
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "dist/react",
5+
"declarationDir": "dist/react"
6+
},
7+
"include": ["src/react/index.ts"]
8+
}

0 commit comments

Comments
 (0)