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

MathUtils: convert to esmodules to allow for tree-shaking #21651

Merged
merged 2 commits into from
Apr 14, 2021

Conversation

marcofugaro
Copy link
Contributor

Related issue: -

Description

This is the pattern to use if we want to allow for tree-shaking for the util-functions files. The API of MathUtils does not change, just the import internally changes.

The downside is: you can't add methods dynamically from outside the file. It was being done in Three.Legacy.js, and I had to remove the methods there.

@mrdoob
Copy link
Owner

mrdoob commented Apr 14, 2021

Interesting...

@mrdoob mrdoob added this to the r128 milestone Apr 14, 2021
@mrdoob mrdoob merged commit 354f955 into mrdoob:dev Apr 14, 2021
@mrdoob
Copy link
Owner

mrdoob commented Apr 14, 2021

Thanks!

jonnycornwell added a commit to jonnycornwell/DefinitelyTyped that referenced this pull request May 19, 2021
- It has been updated and no longer exports a namespace, see
mrdoob/three.js#21651
- The following:
import { MathUtils } from 'three/src/math/MathUtils';
results in a runtime error as MathUtils will be undefined
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