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

r80 incorrectly handles "exports" as global #9489

Closed
2 of 9 tasks
killroy42 opened this issue Aug 11, 2016 · 3 comments
Closed
2 of 9 tasks

r80 incorrectly handles "exports" as global #9489

killroy42 opened this issue Aug 11, 2016 · 3 comments

Comments

@killroy42
Copy link

killroy42 commented Aug 11, 2016

Description of the problem

r80 tries to detect a module environment and passes "exports" as global into the factory class. But below that, there is additional code that accesses "THREE" in the global scope, not on exports. So if the environment has module/exports functions and objects, THREE will fail to load, EVEN if there is a THREE empty object in the global scope, since the factory will not write to the global scope, but to exports instead.

This worked fine in r79, which consistently operated in the same scope.

It appears this is a half-way transition to supporting modularization.

My use case is a module loader that "impersonates" exports/module and captures values written there and makes them available via "require".

Current workaround: Load THREE before initializing my module system.

Three.js version
  • [x ] r80dev
    Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • Linux
  • Android
  • IOS
Hardware Requirements (graphics card, VR Device, ...)
@mrdoob
Copy link
Owner

mrdoob commented Aug 15, 2016

/ping @Rich-Harris

Rich-Harris added a commit to Rich-Harris/three.js that referenced this issue Aug 16, 2016
Rich-Harris added a commit to Rich-Harris/three.js that referenced this issue Aug 16, 2016
mrdoob pushed a commit that referenced this issue Aug 16, 2016
* alternative fix for #9489

* export BoxGeometry as CubeGeometry
@killroy42
Copy link
Author

Looks like r80 now correctly bundles everything in the same closure, but other modules (such as /examples/../*controls) still expect a global (rather than a const THREE = require('THREE'), for example). I guess the plan is to move everything over to some kind of module format compatibility?

@GGAlanSmithee
Copy link
Contributor

@killroy42 here is a related discussion regarding modularization of examples: #9562

@mrdoob mrdoob closed this as completed Aug 23, 2016
aardgoose pushed a commit to aardgoose/three.js that referenced this issue Oct 7, 2016
* alternative fix for mrdoob#9489

* export BoxGeometry as CubeGeometry
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 a pull request may close this issue.

3 participants