Skip to content

Commit 73ee44a

Browse files
compulimOEvgeny
andauthored
Emit ESM build via tsup (#5148)
* Rename to .jsx * Ignore /dist/ * Rename to .jsx * Rename to .jsx * Rename to .jsx * Revert "Rename to .jsx" This reverts commit 324f8f0. * Revert "Rename to .jsx" This reverts commit 04a77e5. * Revert "Rename to .jsx" This reverts commit d68dea2. * Revert "Rename to .jsx" This reverts commit d111d1b. * Compile globalize under /src/ * Remove connectToWebChat * Fix main field * Remove connectToWebChat * Fix globalize * Rename to .ts * Rename to .ts * Use internal Observable for typing * Improve type portability * Remove unneeded @ts-expect-error * Fix types * Remove unneeded polyfill * Fix typing * Fix props typing * Use internal hook * Improve type portability * Use ESNext * Fix typing * Fix typing and improve type portability * Use globalThis * Fix typing * Use @types/dom-speech-recognition * Add .js to import * Add tsup * Typo * Fix precommit * Add fluent-theme * Update tsd * Fix deprecated tests * Fix flakiness * Use ESM for Webpack * Add instrumentation to tsup * Fix ES5 build * Skip *.worker.js * Hack synthetic import * Move NODE_ENV to run * Instrument TypeScript files * Add @istanbuljs/nyc-config-typescript * Our own istanbuljs plugin * Add local dependencies * Use babel.profile.config.json * Add @babel/preset-react * Inherit base ESBuild plug-ins * Update YouTube player * Don't collect coverage under packages/test * Add coverage to fluent-theme * Skip coverage from packages/test * Remove coveragePathIgnorePatterns * Add latest tag style * Add default exports * Add types field * Add pack-all script * Remove older tag * Remove older tag * Revert import from index * Clean up * Clean up * Better comment * Add type * Clean up naming * Remove commented code * Mark microsoft-cognitiveservices-speech-sdk as no external * Add entry * Add 4.17.0 * Add theme pack * Add theme pack support * Update meta tag * Move default to the last * Zip without directory * Tag CJS build * Update README.md Co-authored-by: Eugene <[email protected]> * Rename transpiler to build-tool * Update babel.config.json for build_tool --------- Co-authored-by: Eugene <[email protected]>
1 parent edca85d commit 73ee44a

File tree

162 files changed

+4600
-1687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+4600
-1687
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ body:
118118
- Others or unrelated
119119
validations:
120120
required: true
121+
- type: dropdown
122+
id: theme-pack
123+
attributes:
124+
label: Which theme pack does this issue affect?
125+
multiple: true
126+
options:
127+
- I did not test it on other theme packs
128+
- Fluent UI
129+
validations:
130+
required: true
121131
- type: input
122132
id: url
123133
attributes:

.github/workflows/pull-request-validation.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- run: npm run bootstrap
5050

51-
- run: npm run build --if-present
51+
- run: npm run build --if-present # Add instrumentation code
5252

5353
- name: Pack Docker artifact
5454
run: |
@@ -187,12 +187,20 @@ jobs:
187187

188188
- run: npm run build --if-present
189189

190-
- name: Run tsd under packages/bundle
191-
run: ./node_modules/.bin/tsd
190+
- name: Run tsd under packages/bundle (CJS)
191+
run: ./node_modules/.bin/tsd -t ./lib/index.d.ts
192+
working-directory: ./packages/bundle
193+
194+
- name: Run tsd under packages/bundle (ESM)
195+
run: ./node_modules/.bin/tsd -t ./dist/botframework-webchat.d.mts
192196
working-directory: ./packages/bundle
193197

194-
- name: Run tsd under packages/core
195-
run: ./node_modules/.bin/tsd
198+
- name: Run tsd under packages/core (CJS)
199+
run: ./node_modules/.bin/tsd -t ./lib/index.d.ts
200+
working-directory: ./packages/core
201+
202+
- name: Run tsd under packages/core (ESM)
203+
run: ./node_modules/.bin/tsd -t ./dist/botframework-webchat-core.d.mts
196204
working-directory: ./packages/core
197205

198206
html-test:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/__tests__/__image_snapshots__/**/__diff_output__
22
/.env
3+
/*.tgz
34
/coverage
45
/debug.log
56
/gh-pages
67
/lerna-debug.log
78
/node_modules
9+
/tarball.zip
810

911
# Do not commit binaries
1012
/chromedriver*

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2727
- `useSendMessage` hook is updated to support sending attachments with a message. To reduce complexity, the `useSendFiles` hook is being deprecated. The hook will be removed on or after 2026-04-03
2828
- `styleOptions.uploadThumbnailHeight` and `styleOptions.uploadThumbnailWidth` must be a `number` of pixels
2929
- `useSuggestedActions` type is updated to align with its actual implementation, by [@OEvgeny](https://github.com/OEvgeny), in PR [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)
30+
- Removed deprecated code: `connect*`, `useRenderActivity`, `useRenderActivityStatus`, `useRenderAvatar`, in PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148), by [@compulim](https://github.com/compulim)
31+
- Added named exports in both CommonJS and ES Modules module format, in PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148), by [@compulim](https://github.com/compulim)
3032

3133
### Added
3234

@@ -54,18 +56,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5456
- (Experimental) Added `<LocalizeString />` component which can be used to localize strings, by [@OEvgeny](https://github.com/OEvgeny) in PR [#5140](https://github.com/microsoft/BotFramework-WebChat/pull/5140)
5557
- Added `<ThemeProvider>` component to apply theme pack to Web Chat, by [@compulim](https://github.com/compulim), in PR [#5120](https://github.com/microsoft/BotFramework-WebChat/pull/5120)
5658
- Added `useMakeThumbnail` hook option to create a thumbnail from the file given, by [@compulim](https://github.com/compulim), in PR [#5123](https://github.com/microsoft/BotFramework-WebChat/pull/5123) and [#5122](https://github.com/microsoft/BotFramework-WebChat/pull/5122)
59+
- Added `moduleFormat` and `transpiler` build info to `<meta>` tag, in PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148), by [@compulim](https://github.com/compulim)
5760

5861
### Fixed
5962

6063
- Fixes [#5050](https://github.com/microsoft/BotFramework-WebChat/issues/5050). Fixed focus should not blur briefly after tapping on a suggested action, by [@compulim](https://github.com/compulim), in PR [#5097](https://github.com/microsoft/BotFramework-WebChat/issues/pull/5097)
6164
- Fixes [#5111](https://github.com/microsoft/BotFramework-WebChat/issues/5111). Fixed keyboard help screen to use HTML description list, by [@compulim](https://github.com/compulim), in PR [#5116](https://github.com/microsoft/BotFramework-WebChat/issues/pull/5116)
6265
- Fixes [#5080](https://github.com/microsoft/BotFramework-WebChat/issues/5080). Fixed `dateToLocaleISOString` for handling sub-hour, by [@marclundgren](https://github.com/marclundgren), in PR [#5114](https://github.com/microsoft/BotFramework-WebChat/pull/5114)
6366
- Fixes [#5146](https://github.com/microsoft/BotFramework-WebChat/issues/5146). Fixed chat history focus indicator should not show up on tap, by [@OEvgeny](https://github.com/OEvgeny), in PR [#5145](https://github.com/microsoft/BotFramework-WebChat/pull/5145)
67+
- Fixes type portability issues by exporting types from all exported code, in PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148), by [@compulim](https://github.com/compulim)
68+
- Fixes missing exports of `useNotifications`, in PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148), by [@compulim](https://github.com/compulim)
6469

6570
### Changed
6671

6772
- Moved pull request validation pipeline to GitHub Actions, by [@compulim](https://github.com/compulim), in PR [#4976](https://github.com/microsoft/BotFramework-WebChat/pull/4976)
68-
- Bumped all dependencies to the latest versions, by [@compulim](https://github.com/compulim) in PR [#4973](https://github.com/microsoft/BotFramework-WebChat/pull/4973) and PR [#5115](https://github.com/microsoft/BotFramework-WebChat/pull/5115)
73+
- Bumped all dependencies to the latest versions, by [@compulim](https://github.com/compulim) in PR [#4973](https://github.com/microsoft/BotFramework-WebChat/pull/4973), PR [#5115](https://github.com/microsoft/BotFramework-WebChat/pull/5115), and PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148)
6974
- Notes: Some components/features in Adaptive Cards are in preview and not ready for production use. Web Chat does not support these components and features
7075
- Production dependencies
7176
- [`[email protected]`](https://npmjs.com/package/adaptivecards)
@@ -82,7 +87,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
8287
- Development dependencies
8388
- [`@types/[email protected]`](https://npmjs.com/package/@types/dom-speech-recognition)
8489
- [`@types/[email protected]`](https://npmjs.com/package/@types/node)
85-
- [`@types/react@18.2.42`](https://npmjs.com/package/@types/react)
90+
- [`@types/react@16.14.60`](https://npmjs.com/package/@types/react)
8691
- [`@typescript-eslint/[email protected]`](https://npmjs.com/package/@typescript-eslint/eslint-plugin)
8792
- [`@typescript-eslint/[email protected]`](https://npmjs.com/package/@typescript-eslint/parser)
8893
- [`[email protected]`](https://npmjs.com/package/axe-core)

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,41 @@ Web Chat supports [Content Security Policy (CSP)](https://developer.mozilla.org/
1919

2020
> This section points out important version notes. For further information, please see the related links and check the [`CHANGELOG.md`](https://github.com/microsoft/BotFramework-WebChat/blob/main/CHANGELOG.md)
2121
22+
### 4.17.0 notable changes
23+
24+
#### Debut of ES Modules
25+
26+
Web Chat now exports as ES Modules (named exports) along with CommonJS (named and unnamed exports).
27+
28+
#### Improvement to file upload experience
29+
30+
End-user can now add a message and confirm before uploading their file to the bot. To opt-out of the new experience, pass `sendAttachmentOn: 'send'` in style options.
31+
32+
#### Theme pack support
33+
34+
We are excited to add theme pack support. Developers can now pack all their customization in a single package and publish it to NPM.
35+
36+
#### Experimental Fluent UI theme pack
37+
38+
We are excited to announce Fluent UI theme pack is in the work and is currently in experimental phase. This theme pack is designed for web developers who want to bring a native Copilot user experience to their customers.
39+
40+
We will continue to add new features and support both white-label experience and Fluent UI experience with the same level of parity.
41+
42+
You can wrap Web Chat with `<FluentThemeProvider>` to try out the new experience.
43+
44+
```tsx
45+
import ReactWebChat from 'botframework-webchat';
46+
import { FluentThemeProvider } from 'botframework-webchat-fluent-theme';
47+
48+
export default function MyComponent() {
49+
return (
50+
<FluentThemeProvider>
51+
<ReactWebChat />
52+
</FluentThemeProvider>
53+
);
54+
}
55+
```
56+
2257
### 4.16.1 notable changes
2358

2459
Web Chat now supports [Adaptive Cards schema up to 1.6](https://adaptivecards.io/explorer/). Some features in Adaptive Cards are in preview or designed to use outside of Bot Framework. Web Chat does not support these features.

__tests__/html/fluentTheme/fluentThemeFallback.dark.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
expect(document.activeElement).toBe(
115115
document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTelephoneKeypadButton1}"]`)
116116
);
117+
await pageConditions.scrollToBottomCompleted();
117118
await host.snapshot();
118119

119120
// THEN: Close keypad

__tests__/html/fluentTheme/simple.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@
4040
await pageConditions.numActivitiesShown(1);
4141

4242
// THEN: Fluent theme should be loaded.
43-
expect(
44-
document.querySelector('meta[name="botframework-webchat-fluent-theme:version"]').getAttribute('name')
45-
).toBeTruthy();
43+
const buildInfo = Object.fromEntries(
44+
document
45+
.querySelector('head > meta[name="botframework-webchat:fluent-theme"]')
46+
.content.split(';')
47+
.map(value => value.trim().split('='))
48+
);
49+
50+
expect(buildInfo).toHaveProperty('build-tool', 'tsup');
51+
expect(buildInfo).toHaveProperty('module-format', 'esmodules');
52+
expect(buildInfo.version).toMatch(/^\d+\.\d+\.\d+($|-)/u);
4653

4754
expect(window.WebChat.FluentThemeProvider).toBeTruthy();
4855

0 commit comments

Comments
 (0)