Skip to content

Commit 07edae6

Browse files
committed
Remove private packages from exporting publicly
1 parent 2e8c80e commit 07edae6

16 files changed

Lines changed: 66 additions & 26 deletions

File tree

packages/api/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@
6565
],
6666
"homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/component#readme",
6767
"scripts": {
68-
"build": "npm run build:globalize && npm run build:tsup",
68+
"build": "npm run build:globalize && npm run build:tsup && npm run build:validate",
6969
"build:globalize": "node scripts/createPrecompiledGlobalize.mjs",
7070
"build:tsup": "tsup",
71+
"build:validate": "if grep -R -n -F --include='*.d.ts' --include='*.d.mts' '@msinternal/' ./dist/; then echo '*.d.ts files should not import \"@msinternal/*\"' >&2; exit 1; fi",
7172
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
7273
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
7374
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",

packages/base/tsup.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { applyConfig } from '../../tsup.base.config';
55
// TODO: [P1] Compute this automatically.
66
const DEPENDENT_PATHS = [
77
'api/src/index.ts',
8-
'api-middleware/src/index.ts',
98
'bundle/src/full.ts',
109
'component/src/index.ts',
1110
'core/src/index.ts',

packages/bundle/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
}
5959
},
6060
"scripts": {
61-
"build": "tsup",
61+
"build": "npm run build:tsup && npm run build:validate",
62+
"build:tsup": "tsup",
63+
"build:validate": "if grep -R -n -F --include='*.d.ts' --include='*.d.mts' '@msinternal/' ./dist/; then echo '*.d.ts files should not import \"@msinternal/*\"' >&2; exit 1; fi",
6264
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
6365
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
6466
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
@@ -68,10 +70,14 @@
6870
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
6971
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
7072
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
71-
"start": "npm run build -- --watch",
73+
"start": "npm run build:tsup -- --watch",
7274
"test:tsd": "../../node_modules/.bin/tsd"
7375
},
7476
"localDependencies": {
77+
"botframework-directlinespeech-sdk": "production",
78+
"botframework-webchat-api": "production",
79+
"botframework-webchat-component": "production",
80+
"botframework-webchat-core": "production",
7581
"@msinternal/botframework-webchat-base": "development",
7682
"@msinternal/botframework-webchat-tsconfig": "development",
7783
"@msinternal/isomorphic-react": "development",

packages/component/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
],
5656
"homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/component#readme",
5757
"scripts": {
58-
"build": "tsup",
58+
"build": "npm run build:tsup && npm run build:validate",
59+
"build:tsup": "tsup",
60+
"build:validate": "if grep -R -n -F --include='*.d.ts' --include='*.d.mts' '@msinternal/' ./dist/; then echo '*.d.ts files should not import \"@msinternal/*\"' >&2; exit 1; fi",
5961
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
6062
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
6163
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
@@ -65,7 +67,7 @@
6567
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
6668
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
6769
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
68-
"start": "npm run build -- --watch"
70+
"start": "npm run build:tsup -- --watch"
6971
},
7072
"localDependencies": {
7173
"@msinternal/botframework-webchat-base": "development",

packages/core/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@
5656
}
5757
},
5858
"scripts": {
59-
"build": "tsup",
59+
"build": "npm run build:tsup && npm run build:validate",
60+
"build:tsup": "tsup",
61+
"build:validate": "if grep -R -n -F --include='*.d.ts' --include='*.d.mts' '@msinternal/' ./dist/; then echo '*.d.ts files should not import \"@msinternal/*\"' >&2; exit 1; fi",
6062
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
6163
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
6264
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
@@ -66,7 +68,7 @@
6668
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
6769
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
6870
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
69-
"start": "npm run build -- --watch"
71+
"start": "npm run build:tsup -- --watch"
7072
},
7173
"engines": {
7274
"node": ">=12.0.0"

packages/core/src/createPromiseQueue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withResolvers } from '@msinternal/botframework-webchat-base/utils';
1+
import withResolvers from './utils/withResolvers';
22

33
export default function createPromiseQueue() {
44
let promiseWithResolvers;

packages/core/src/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { withResolvers, type PromiseWithResolvers } from '@msinternal/botframework-webchat-base/utils';
21
import connect from './actions/connect';
32
import disconnect from './actions/disconnect';
43
import dismissNotification from './actions/dismissNotification';
@@ -85,6 +84,8 @@ import type { UserReview as OrgSchemaUserReview } from './types/external/OrgSche
8584

8685
const Constants = { ActivityClientState, DictateState };
8786

87+
export { default as withResolvers, type PromiseWithResolvers } from './utils/withResolvers';
88+
8889
export {
8990
connect,
9091
Constants,
@@ -126,8 +127,7 @@ export {
126127
stopDictate,
127128
stopSpeakingActivity,
128129
submitSendBox,
129-
warnOnce,
130-
withResolvers
130+
warnOnce
131131
};
132132

133133
export type {
@@ -154,7 +154,6 @@ export type {
154154
OrgSchemaProject,
155155
OrgSchemaThing,
156156
OrgSchemaUserReview,
157-
PromiseWithResolvers,
158157
SendBoxAttachment,
159158
WebChatActivity
160159
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// tsup wrongly included typings from private packages marked as `noExternal` or `devDependencies`.
2+
// We cannot direct re-export from private packages without rebuilding their types.
3+
// tsup bug: https://github.com/egoist/tsup/issues/1071
4+
5+
import { withResolvers as withResolvers_ } from '@msinternal/botframework-webchat-base/utils';
6+
7+
type PromiseWithResolvers<T> = {
8+
promise: Promise<T>;
9+
reject: (error: unknown) => void;
10+
resolve: (result: T) => void;
11+
};
12+
13+
const withResolvers = withResolvers_ as <T>() => PromiseWithResolvers<T>;
14+
15+
export default withResolvers;
16+
export { type PromiseWithResolvers };

packages/core/tsup.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default defineConfig([
2121
...commonConfig.define,
2222
'globalThis.WEB_CHAT_BUILD_INFO_MODULE_FORMAT': '"esmodules"'
2323
},
24+
dts: { resolve: true },
2425
format: 'esm'
2526
},
2627
{
@@ -29,6 +30,7 @@ export default defineConfig([
2930
...commonConfig.define,
3031
'globalThis.WEB_CHAT_BUILD_INFO_MODULE_FORMAT': '"commonjs"'
3132
},
33+
dts: { resolve: true },
3234
format: 'cjs',
3335
target: [...commonConfig.target, 'es2019']
3436
}

packages/debug-theme/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
"localDependencies": {},
3939
"homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/debug-theme#readme",
4040
"scripts": {
41-
"build": "tsup --config ./tsup.config.ts",
41+
"build": "npm run build:tsup && npm run build:validate",
42+
"build:tsup": "tsup",
43+
"build:validate": "if grep -R -n -F --include='*.d.ts' --include='*.d.mts' '@msinternal/' ./dist/; then echo '*.d.ts files should not import \"@msinternal/*\"' >&2; exit 1; fi",
4244
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
4345
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
4446
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
@@ -48,7 +50,7 @@
4850
"precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0",
4951
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
5052
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
51-
"start": "npm run build -- --watch"
53+
"start": "npm run build:tsup -- --watch"
5254
},
5355
"peerDependencies": {
5456
"react": ">= 16.8.6"

0 commit comments

Comments
 (0)