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

[Tree shaking] Decouple botframework-directlinejs #4643

Closed
compulim opened this issue Feb 16, 2023 · 0 comments · Fixed by #4645 or #4648
Closed

[Tree shaking] Decouple botframework-directlinejs #4643

compulim opened this issue Feb 16, 2023 · 0 comments · Fixed by #4645 or #4648

Comments

@compulim
Copy link
Contributor

compulim commented Feb 16, 2023

Is your feature request related to a problem?

When using Web Chat outside of DirectLineJS, the botframework-directlinejs is always loaded regardless of how tree shaking is done.

Describe the suggestion or request in detail

Searching the code for importing botframework-directlinejs, it yielded connectSaga.js is the only place that import bf-dljs implementation code.

For other places, it's either intentionally importing (say, createDirectLine), or only importing its typing (i.e. import type {} from 'bf-dljs'.

After some experiments, it is clear that after decoupling DLJS in connectSaga.js, the bf-dljs package will bee tree-shaken off, if createDirectLine is not loaded.

However, more work need to be done on exporting ReactWebChat alone. Instead of exporting it like today, we need to export it via export { ReactWebChat } from 'botframework-webchat/ReactWebChat.

Describe alternatives you have considered

I tested that export { ReactWebChat } from 'botframework-webchat' does not help tree-shaking. This is because by simply import 'botframework-directlinejs' without using it, it will load core-js/features/promise and rxjs/*.

We need named exports to make sure tree-shaking works properly.

More details at https://github.com/compulim/experiment-treeshake-directlinejs/.

Additional context

Based on 4.15.7. After connectSaga.js removed reference to botframework-directlinejs.

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

console.log(ReactWebChat);

image

In contrast, without modifying connectSaga.js.

image

When importing from root.

image

@compulim compulim added customer-reported Required for internal Azure reporting. Do not delete. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. feature-request Azure report label labels Feb 16, 2023
@compulim compulim added external-power-apps and removed customer-reported Required for internal Azure reporting. Do not delete. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. labels Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment