Skip to content

Converge all versions of microsoft-cognitiveservices-speech-sdk #2987

@compulim

Description

@compulim

Feature Request

Background

As microsoft-cognitiveservices-speech-sdk has stable release for Direct Line Speech, we should converge all versions used in Web Chat to a single one, reducing out footprint.

Marked are 3 copies of microsoft-cognitiveservices-speech-sdk in webchat.js.

image

Update on 2020-03-26

Despite converging, Webpack doesn't dedupe packages based on their name + version.

For example, we have:

Both of them are @1.10.1, but since their paths are different, Webpack will bundle them separately in the bundle. Every microsoft-cognitiveservices-speech-sdk will take up about 250-300 KB after minified before gzip.

Short-term solution

What we could do temporarily is to use resolve.alias to alias microsoft-cognitiveservices-speech-sdk together. But it need to be elaborated if we are using tree-shaking, like below:

  resolve: {
    alias: {
+     'microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/AudioConfig': resolve(__dirname, 'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/sdk/Audio/AudioConfig.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'),
+     'microsoft-cognitiveservices-speech-sdk': resolve(__dirname, 'node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/microsoft.cognitiveservices.speech.sdk.js'),
      react: resolve(__dirname, 'node_modules/isomorphic-react/dist/react.js'),
      'react-dom': resolve(__dirname, 'node_modules/isomorphic-react-dom/dist/react-dom.js')
    },

Long-term solution

Since we cannot hoist packages due to technical problems, what we could do for long-term is to write a ResolverPlugin for Webpack that will do dedupe based on package name and version numbers.
[Enhancement]

Metadata

Metadata

Assignees

Labels

Bot ServicesRequired for internal Azure reporting. Do not delete. Do not change color.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions