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

Enable treeshaking #89

Open
s-yadav opened this issue Aug 19, 2020 · 0 comments
Open

Enable treeshaking #89

s-yadav opened this issue Aug 19, 2020 · 0 comments
Labels
bundle size Label for improving bundle size

Comments

@s-yadav
Copy link
Collaborator

s-yadav commented Aug 19, 2020

Proposal

Right now we add all the methods in default export so that we can access the method directly from Brahmos namespace. like
Brahmos.Component, Brahmos.createElement etc.

This was done so the aliasing of React to Brahmos can be done easily. But it necessarily increases the bundle size.

Though this might be required on umd bundle, but for es modules, we are not able to utilize proper tree shaking.

Plus this issue can be solved on compiler level easily on below code,

import Brahmos from 'brahmos';

class App extends Brahmos.Component {
    render Brahmos.createElement('div', {}, 'Hello World!')
}

we can easily find Brahmos.Component usage and can optimize the above syntax to

import {createElement, Component} from 'brahmos';

class App extends Component {
    render createElement('div', {}, 'Hello World!')
}

Complexity

  • How this can work with third-party react components. The babel plugin does not run on node modules.
  • Handle mangling done by the optimizers (Uglify, Terser etc)
@s-yadav s-yadav added the bundle size Label for improving bundle size label Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bundle size Label for improving bundle size
Projects
None yet
Development

No branches or pull requests

1 participant