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

Decouple botframework-directlinejs #4644

Closed
wants to merge 2 commits into from

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Feb 16, 2023

Fixes #4643.

Changelog Entry

Added

  • Resolved #4643. Decoupling botframework-directlinejs from business logic of Web Chat for better tree-shaking, by @compulim, in PR #4644

Description

Outside of createDirectLine, Web Chat should decouple itself from botframework-directlinejs.

We found that the only coupling is at connectSaga.js, which it imported implementation code from bf-dljs. For other places, it is importing only the types.

After this is done, we saw a 11.5% decrease in bundle size, if only our root UI component is imported.

Design

Web Chat generally decouple itself from bf-dljs. Only typing (non-runtime code) and explicit-import (import { createDirectLine } from 'bf-wc') is coupled to bf-dljs.

Once this is done, when importing our root UI component, we saw a sharp decrease of app bundle size:

import { ReactWebChat } from 'botframework-webchat/lib/ReactWebChat';

However, note should be taken. ReactWebChat is NOT expected to be imported via bf-wc/lib/ReactWebChat. Web Chat should carefully design its named exports for this to fully work. And named exports could means breaking changes for web devs who use NPM version of Web Chat.

Specific Changes

  • Update connectSaga.js and bring DLJS ConnectionStatus in connectSaga
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim
Copy link
Contributor Author

Reopening from another branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tree shaking] Decouple botframework-directlinejs
1 participant