Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove mainFields in webpack.config.js #3726

Merged
merged 3 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Although it no locker lock up microphone, clicking on the microphone button has no effect because Direct Line Speech does not support aborting speech recognition
- Fixes [#3421](https://github.com/microsoft/BotFramework-WebChat/issues/3421). With Direct Line Speech, after not able to recognize any speech, it should no longer stop working, by [@compulim](https://github.com/compulim) in PR [#3694](https://github.com/microsoft/BotFramework-WebChat/pull/3694)
- Fixes [#3616](https://github.com/microsoft/BotFramework-WebChat/issues/3616). [Accessibility documentation] Update activity timestamp grouping to match visual UI, by [@amal-khalaf](https://github.com/amal-khalaf) in PR [#3708](https://github.com/microsoft/BotFramework-WebChat/pull/3708)
- Fixes [#3718](https://github.com/microsoft/BotFramework-WebChat/issues/3718). Fixed `webpack.config.js` to use default settings of `['browser', 'module', 'main']` and resolved issues with `uuid` package in IE11, by [@compulim](https://github.com/compulim) in PR [#3726](https://github.com/microsoft/BotFramework-WebChat/pull/3726)

### Changed

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AudioConfig } from 'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/AudioConfig';
import { MicAudioSource } from 'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/MicAudioSource';
import createPonyfill from 'web-speech-cognitive-services/lib/SpeechServices';

function resolveFunction(fnOrValue) {
Expand Down Expand Up @@ -61,42 +60,6 @@ export default function createCognitiveServicesSpeechServicesPonyfillFactory({
audioConfig = audioInputDeviceId
? AudioConfig.fromMicrophoneInput(audioInputDeviceId)
: AudioConfig.fromDefaultMicrophoneInput();

const source = audioConfig.privSource;

// WORKAROUND: In Speech SDK 1.12.0-1.13.1, it dropped support of macOS/iOS Safari.
// This code is adopted from microsoft-cognitiveservices-speech-sdk/src/common.browser/MicAudioSource.ts.
// We will not need this code when using Speech SDK 1.14.0 or up.
// TODO: [P1] #3575 Remove the following lines when bumping to Speech SDK 1.14.0 or higher
source.createAudioContext = () => {
// eslint-disable-next-line no-extra-boolean-cast
if (!!source.privContext) {
return;
}

const AudioContext = window.AudioContext || window.webkitAudioContext;

if (typeof AudioContext === 'undefined') {
throw new Error('Browser does not support Web Audio API (AudioContext/webkitAudioContext is not available).');
}

if (navigator.mediaDevices.getSupportedConstraints().sampleRate) {
source.privContext = new AudioContext({ sampleRate: MicAudioSource.AUDIOFORMAT.samplesPerSec });
} else {
source.privContext = new AudioContext();
}
};

// This piece of code is adopted from microsoft-cognitiveservices-speech-sdk/common.browser/MicAudioSource.ts.
// Instead of closing the AudioContext, it will just suspend it. And the next time it is needed, it will be resumed (by the original code).
source.destroyAudioContext = () => {
if (!source.privContext) {
return;
}

source.privRecorder.releaseMediaResources(source.privContext);
source.privContext.state === 'running' && source.privContext.suspend();
};
}

return ({ referenceGrammarID } = {}) => {
Expand Down
24 changes: 6 additions & 18 deletions packages/bundle/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* eslint @typescript-eslint/no-var-requires: "off" */
/* eslint no-magic-numbers: ["error", { "ignore": [2] }] */
/* global __dirname, module, process */

const { join } = require('path');
const { resolve } = require('path');
const { StatsWriterPlugin } = require('webpack-stats-plugin');
Expand Down Expand Up @@ -42,11 +46,6 @@ let config = {
__dirname,
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/AudioConfig.js'
),
// TODO: [P1] #3575 Remove the following line when bumping to Speech SDK 1.14.0 or higher
'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/MicAudioSource': resolve(
__dirname,
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.browser/MicAudioSource.js'
),
'microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk': resolve(
__dirname,
'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk.js'
Expand All @@ -57,18 +56,7 @@ let config = {
),
react: resolve(__dirname, 'node_modules/isomorphic-react/dist/react.js'),
'react-dom': resolve(__dirname, 'node_modules/isomorphic-react-dom/dist/react-dom.js')
},

// Since Webpack is configured not to transpile, we cannot use package.json/module field to load a module.
// The default Webpack module resolution order is: "module", then "browser", then "main".
//
// De facto entrypoint definitions:
// - "module": ES.next: transpilation is required for this entrypoint. It should yield code with smallest footprint.
// - "main": Plain old Node.js or browser: should be ES5 compatible. It may be configured to work only on either Node.js or browser.
// - "browser": Plain old browsers (ES5, which is supported by IE9). This entrypoint will not work on Node.js.
//
// If both "main" and "browser" are present, "main" will be for Node.js and "browser" will be for browsers.
mainFields: ['browser', 'main']
}
}
};

Expand Down Expand Up @@ -97,7 +85,7 @@ if (node_env !== 'production' && node_env !== 'test') {
join(__dirname, '../core/lib'),
join(__dirname, '../directlinespeech/lib')
],
test: /\.js$/,
test: /\.js$/iu,
use: ['source-map-loader']
}
]
Expand Down