Skip to content

Commit a8ff179

Browse files
authored
Bump webpack and remove event-target-shim (#5156)
* Bump webpack and remove event-target-shim * Update entry
1 parent c30e4e2 commit a8ff179

File tree

10 files changed

+380
-393
lines changed

10 files changed

+380
-393
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2222

2323
## [Unreleased]
2424

25+
### Known issues
26+
27+
- Web Chat is not loading with error `Uncaught TypeError: Super constructor null of anonymous class is not a constructor`
28+
- A [bug in webpack@>=5.84.1](https://github.com/webpack/webpack/issues/17711) is causing the issue. Please update to [`webpack@>=5.90.0`](https://npmjs.com/package/webpack/v/5.90.0)
29+
2530
### Breaking changes
2631

2732
- `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
@@ -70,11 +75,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7075
- 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)
7176
- Fixes missing exports of `useNotifications`, in PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148), by [@compulim](https://github.com/compulim)
7277
- Fixes suggested actions keyboard navigation skips actions after suggested actions got updated, in PR [#5150](https://github.com/microsoft/BotFramework-WebChat/pull/5150), by [@OEvgeny](https://github.com/OEvgeny)
78+
- Fixes [#5155](https://github.com/microsoft/BotFramework-WebChat/issues/5155). Fixed "Super constructor null of anonymous class is not a constructor" error in CDN bundle by bumping to [`[email protected]`](https://www.npmjs.com/package/webpack/v/5.91.0), in PR [#5156](https://github.com/microsoft/BotFramework-WebChat/pull/5156), by [@compulim](https://github.com/compulim)
7379

7480
### Changed
7581

7682
- 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)
77-
- 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)
83+
- 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), PR [#5148](https://github.com/microsoft/BotFramework-WebChat/pull/5148), and PR [#5156](https://github.com/microsoft/BotFramework-WebChat/pull/5156)
7884
- 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
7985
- Production dependencies
8086
- [`[email protected]`](https://npmjs.com/package/adaptivecards)
@@ -112,7 +118,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
112118
- [`[email protected]`](https://npmjs.com/package/read-pkg)
113119
- [`[email protected]`](https://npmjs.com/package/selenium-webdriver)
114120
- [`[email protected]`](https://npmjs.com/package/typescript)
115-
- [`webpack@5.89.0`](https://npmjs.com/package/webpack)
121+
- [`webpack@5.91.0`](https://npmjs.com/package/webpack)
116122

117123
## [4.16.0] - 2023-11-16
118124

packages/bundle/package-lock.json

Lines changed: 230 additions & 352 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/bundle/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
"tsd": "^0.30.3",
170170
"type-fest": "^4.9.0",
171171
"typescript": "^5.3.2",
172-
"webpack": "^5.89.0",
172+
"webpack": "^5.91.0",
173173
"webpack-cli": "^5.1.4",
174174
"webpack-stats-plugin": "^1.1.3"
175175
},

packages/component/package-lock.json

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/component/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
"classnames": "2.3.2",
121121
"compute-scroll-into-view": "1.0.20",
122122
"deep-freeze-strict": "^1.1.1",
123-
"event-target-shim": "6.0.2",
124123
"markdown-it": "13.0.2",
125124
"math-random": "2.0.1",
126125
"mdast-util-from-markdown": "2.0.0",

packages/component/src/hooks/internal/BypassSpeechSynthesisPonyfill.js

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* eslint max-classes-per-file: ["error", 4] */
77
/* eslint no-empty-function: "off" */
88

9-
import EventTarget, { Event, getEventAttributeValue, setEventAttributeValue } from 'event-target-shim';
9+
import createOnEventShim from './private/createOnEventShim';
1010

1111
class SpeechSynthesisEvent extends Event {
1212
constructor(type, utterance) {
@@ -42,6 +42,8 @@ class SpeechSynthesisUtterance extends EventTarget {
4242
this._text = text;
4343
this._voice = null;
4444
this._volume = 1;
45+
46+
this._shim = createOnEventShim(this);
4547
}
4648

4749
get lang() {
@@ -93,59 +95,59 @@ class SpeechSynthesisUtterance extends EventTarget {
9395
}
9496

9597
get onboundary() {
96-
return getEventAttributeValue(this, 'boundary');
98+
return this._shim.get('boundary');
9799
}
98100

99101
set onboundary(value) {
100-
setEventAttributeValue(this, 'boundary', value);
102+
this._shim.set('boundary', value);
101103
}
102104

103105
get onend() {
104-
return getEventAttributeValue(this, 'end');
106+
return this._shim.get('end');
105107
}
106108

107109
set onend(value) {
108-
setEventAttributeValue(this, 'end', value);
110+
this._shim.set('end', value);
109111
}
110112

111113
get onerror() {
112-
return getEventAttributeValue(this, 'error');
114+
return this._shim.get('error');
113115
}
114116

115117
set onerror(value) {
116-
setEventAttributeValue(this, 'error', value);
118+
this._shim.set('error', value);
117119
}
118120

119121
get onmark() {
120-
return getEventAttributeValue(this, 'mark');
122+
return this._shim.get('mark');
121123
}
122124

123125
set onmark(value) {
124-
setEventAttributeValue(this, 'mark', value);
126+
this._shim.set('mark', value);
125127
}
126128

127129
get onpause() {
128-
return getEventAttributeValue(this, 'pause');
130+
return this._shim.get('pause');
129131
}
130132

131133
set onpause(value) {
132-
setEventAttributeValue(this, 'pause', value);
134+
this._shim.set('pause', value);
133135
}
134136

135137
get onresume() {
136-
return getEventAttributeValue(this, 'resume');
138+
return this._shim.get('resume');
137139
}
138140

139141
set onresume(value) {
140-
setEventAttributeValue(this, 'resume', value);
142+
this._shim.set('resume', value);
141143
}
142144

143145
get onstart() {
144-
return getEventAttributeValue(this, 'start');
146+
return this._shim.get('start');
145147
}
146148

147149
set onstart(value) {
148-
setEventAttributeValue(this, 'start', value);
150+
this._shim.set('start', value);
149151
}
150152
}
151153

@@ -172,6 +174,12 @@ class SpeechSynthesisVoice {
172174
}
173175

174176
class SpeechSynthesis extends EventTarget {
177+
constructor() {
178+
super();
179+
180+
this._shim = createOnEventShim(this);
181+
}
182+
175183
get paused() {
176184
return false;
177185
}
@@ -204,14 +212,14 @@ class SpeechSynthesis extends EventTarget {
204212
}
205213

206214
get onvoiceschanged() {
207-
return getEventAttributeValue(this, 'voiceschanged');
215+
return this._shim.get('voiceschanged');
208216
}
209217

210218
set onvoiceschanged(value) {
211-
setEventAttributeValue(this, 'voiceschanged', value);
219+
this._shim.set('voiceschanged', value);
212220
}
213221
}
214222

215223
const speechSynthesis = new SpeechSynthesis();
216224

217-
export { speechSynthesis, SpeechSynthesisEvent, SpeechSynthesisUtterance, SpeechSynthesisVoice };
225+
export { SpeechSynthesisEvent, SpeechSynthesisUtterance, SpeechSynthesisVoice, speechSynthesis };
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import createOnEventShim from './createOnEventShim';
2+
3+
describe('A shimmed event target', () => {
4+
class MyEventTarget extends EventTarget {
5+
#shim = createOnEventShim<'message'>(this);
6+
7+
get onmessage() {
8+
return this.#shim.get('message');
9+
}
10+
11+
set onmessage(listener: EventListener) {
12+
this.#shim.set('message', listener);
13+
}
14+
}
15+
16+
describe('with an "onmessage" handler', () => {
17+
let eventTarget: MyEventTarget;
18+
let messageEventListener: jest.Mock<void, []>;
19+
20+
beforeEach(() => {
21+
eventTarget = new MyEventTarget();
22+
messageEventListener = jest.fn();
23+
eventTarget.onmessage = messageEventListener;
24+
});
25+
26+
test('"onmessage" getter should return the event listener', () =>
27+
expect(eventTarget.onmessage).toBe(messageEventListener));
28+
29+
describe('when a "message" event is dispatched', () => {
30+
let messageEvent: Event;
31+
32+
beforeEach(() => {
33+
messageEvent = new Event('message');
34+
eventTarget.dispatchEvent(messageEvent);
35+
});
36+
37+
test('"onmessage" handler should be called once', () => expect(messageEventListener).toHaveBeenCalledTimes(1));
38+
test('"onmessage" handler should be called with the event', () =>
39+
expect(messageEventListener).toHaveBeenNthCalledWith(1, messageEvent));
40+
});
41+
42+
describe('replaced with another "onmessage" handler', () => {
43+
let anotherMessageEventListener: jest.Mock<void, []>;
44+
45+
beforeEach(() => {
46+
anotherMessageEventListener = jest.fn();
47+
eventTarget.onmessage = anotherMessageEventListener;
48+
});
49+
50+
test('"onmessage" getter should return the updated event listener', () =>
51+
expect(eventTarget.onmessage).toBe(anotherMessageEventListener));
52+
53+
describe('when a "message" event is dispatched', () => {
54+
let messageEvent: Event;
55+
56+
beforeEach(() => {
57+
messageEvent = new Event('message');
58+
eventTarget.dispatchEvent(messageEvent);
59+
});
60+
61+
test('the previous "onmessage" handler should not be called', () =>
62+
expect(messageEventListener).toHaveBeenCalledTimes(0));
63+
test('the updated "onmessage" handler should be called once', () =>
64+
expect(anotherMessageEventListener).toHaveBeenCalledTimes(1));
65+
test('the updated "onmessage" handler should be called with the event', () =>
66+
expect(anotherMessageEventListener).toHaveBeenNthCalledWith(1, messageEvent));
67+
});
68+
});
69+
70+
describe('when the handler is removed', () => {
71+
beforeEach(() => {
72+
eventTarget.onmessage = null;
73+
});
74+
75+
test('"onmessage" getter should return falsy', () => expect(eventTarget.onmessage).toBeFalsy());
76+
77+
describe('when a "message" event is dispatched', () => {
78+
let messageEvent: Event;
79+
80+
beforeEach(() => {
81+
messageEvent = new Event('message');
82+
eventTarget.dispatchEvent(messageEvent);
83+
});
84+
85+
test('the removed "onmessage" handler should not be called', () =>
86+
expect(messageEventListener).toHaveBeenCalledTimes(0));
87+
});
88+
});
89+
});
90+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default function createOnEventShim<Name extends string = string, Target extends EventTarget = EventTarget>(
2+
target: Target
3+
) {
4+
const currentListeners: Map<Name, EventListener> = new Map();
5+
6+
return {
7+
get(name: Name): EventListener | undefined {
8+
return currentListeners.get(name);
9+
},
10+
set(name: Name, listener: EventListener | undefined): void {
11+
const current = currentListeners.get(name);
12+
13+
current && target.removeEventListener(name, current);
14+
15+
if (listener) {
16+
target.addEventListener(name, listener);
17+
currentListeners.set(name, listener);
18+
} else {
19+
currentListeners.delete(name);
20+
}
21+
}
22+
};
23+
}

packages/component/tsup.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ export default defineConfig({
55
...baseConfig,
66
entry: {
77
'botframework-webchat-component': './src/index.ts'
8-
},
9-
noExternal: ['event-target-shim']
8+
}
109
});

packages/directlinespeech/tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ export default defineConfig({
2727
SPEECH_OCSP_CACHE_ROOT: ''
2828
},
2929
esbuildPlugins: [resolveCognitiveServicesToES2015],
30+
// We need to internalize event-target-shim because it appear as transient packages with a different version.
3031
noExternal: ['event-target-shim']
3132
});

0 commit comments

Comments
 (0)