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

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

Closed
compulim opened this issue Mar 6, 2020 · 3 comments · Fixed by #3079
Closed

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

compulim opened this issue Mar 6, 2020 · 3 comments · Fixed by #3079
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color.

Comments

@compulim
Copy link
Contributor

compulim commented Mar 6, 2020

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:

  • packages/bundle/node_modules/microsoft-cognitiveservices-speech-sdk@1.10.1
  • packages/directlinespeech/node_modules/microsoft-cognitiveservices-speech-sdk@1.10.1

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]

@compulim compulim added Enhancement Bot Services Required for internal Azure reporting. Do not delete. Do not change color. labels Mar 6, 2020
@corinagum
Copy link
Contributor

Related to #2886?

@compulim
Copy link
Contributor Author

compulim commented Mar 27, 2020

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

For example:

  • packages/bundle/node_modules/microsoft-cognitiveservices-speech-sdk@1.10.1
  • packages/directlinespeech/node_modules/microsoft-cognitiveservices-speech-sdk@1.10.1

Both of them are @1.10.1, but since their paths are different, Webpack will bundle them separately in the bundle.

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.

@compulim
Copy link
Contributor Author

compulim commented Apr 2, 2020

We should do this with #2481.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants