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

Split out the context for ConfigProvider as a package for supporting dynamic-import via esmodule server #38596

Open
Justinidlerz opened this issue Nov 16, 2022 · 0 comments
Labels

Comments

@Justinidlerz
Copy link

Justinidlerz commented Nov 16, 2022

What problem does this feature solve?

For the bundle-less case, we will use import('https://some.cnd.com/antd/es/${componentName}') to import the needed components.
But many dependencies loaded via the network will slow down the page speed (waterfall).
Such as load a button component must run the flow to download dependencies:
button.js -> button-group.js -> LoadingIcon.js -> etc... and another outside-of-the-button package dependencies

To prevent the above problem, we bundle each component package, see like: import('https://some.cnd.com/antd/es/${componentName}?bundle')
And the download will be reduced to button.bundle.js and another outside-of-the-button package dependencies

When needs to config some global settings using the ConfigProvider, the context will be bundled into the config-provider.bundle.js file, so the button component will not import the same context file with the config-provider.

What does the proposed API look like?

The feature hasn't changed API, But needs to modify the packages structure:
Origin structure:

- | components
------ | config-provider
-------------- | context.ts
-------------- | index.ts

New structure:

- | components
------ | config-provider
-------------- | index.ts 
------ | context
-------------- | index.ts 

And the bundled es module will see like:

- | es
------ | config-provider
-------------- | index.js 
------ | context
-------------- | index.js 

And the browser will download the same context/inde.bundle.js file to share the React's context to solve the problem.

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

No branches or pull requests

1 participant