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

new npm packages can not support multiple threejs versions #21837

Closed
MrDChristop opened this issue May 15, 2021 · 5 comments
Closed

new npm packages can not support multiple threejs versions #21837

MrDChristop opened this issue May 15, 2021 · 5 comments

Comments

@MrDChristop
Copy link

Hi
i am using a webpack project and would like to test multiple versions of threejs using npm aliases
https://stackoverflow.com/questions/26414587/how-to-install-multiple-versions-of-package-using-npm

Up to 119.1 this works but in the recent versions many js files include the three js library absolutely and not relatively
for example in the node_modules many files have this
import { MathUtils } from 'three';
but they used to have this
import { MathUtils } from '../../../../build/three.module.js';

the strange thing is that in the git repo all imports are relative but when i use npm to checkout the are absolute and use 'three' instead of '../../../../build/three.module.js';

Is there anything i can do?

thanks

@gkjohnson
Copy link
Collaborator

If you'd like to understand more about why the npm-published examples were changed to import from three you can read up on it in issue #17482.

Is there anything i can do?

Is there a reason you need to import multiple versions of three at once? Can you not change which version of three is aliased between running the test suite? Being more explicit in your setup would be helpful.

@MrDChristop
Copy link
Author

Hi thanks for the quick reply.
My problem is that I want to test a new threejs version without erasing the current stable one.
Npm has now this feature called aliases. here is a snipped of my package.json
"threejs :"^0.119.1",
"threejs128": "npm:three@^0.128.0",

So in theory i just have to change the imports in the code from import 'three' to import 'three128'
but this is not working because in 128 code all internal imports are like this
import { MathUtils } from 'three';

so it get the code from the old 119 version.
In 119 the imports were like this
import { MathUtils } from '../../../../build/three.module.js';

which was working with this method because the threejs code would go and read its own library instead of using the webpack way.

I understand why you updated the import path to 'three' is there another way to use multiple versions of threejs for testing?

Thanks

@Mugen87
Copy link
Collaborator

Mugen87 commented May 17, 2021

You have to use another workflow in your project to solve this issue. Instead of doing this:

i just have to change the imports in the code from import 'three' to import 'three128'

You have to change the three dependency in your package.json or use a custom package.json for your test suite.

@MrDChristop
Copy link
Author

Hi
i dont understand the "change the three dependency in your package json".
What do you mean?

@Mugen87
Copy link
Collaborator

Mugen87 commented May 17, 2021

I've meant instead of changing the imports in your code (which is no good approach anyway), you modify the dependency in package.json.

Sorry, but we are not going to change something in the repository. If you need more help, I suggest you try it at stackoverflow or the forum.

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

No branches or pull requests

3 participants