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 from business logics #4645

Merged
merged 3 commits into from
Feb 16, 2023

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Feb 16, 2023

Do not merge this before the bump-4.15.8-0 PR.

Fixes #4643.

Changelog Entry

Added

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

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 compulim added p1 Painful if we don't fix, won't block releasing external-power-apps labels Feb 16, 2023
@compulim compulim merged commit 30b6b3c into main Feb 16, 2023
@compulim compulim deleted the feat-decouple-dljs branch February 16, 2023 19:26
@compulim compulim mentioned this pull request Feb 21, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external-power-apps p1 Painful if we don't fix, won't block releasing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tree shaking] Decouple botframework-directlinejs
2 participants