-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
update import not work #22437
Comments
i have the same issue. please let me know when u solve that. |
@hqzh what build system and what version are you using? It looks like create-react-app? |
That looks like the general Webpack error overlay but I'm also getting this with CRA. |
Same problem here, but only when bundling everything with rollup. I also use # privates in my viewer code and had no problems so far. Maybe rollup needs another option for the three stuff... i have to figure out... Update: |
Was it too early to start using private class variables? Should we rename |
@marcofugaro yep, happening in facebook/create-react-app. It's not really an issue with three (support for private fields is quite good) - but Adding latest @babel/preset-env does solve the issue, but requires ejecting / taking apart the |
happening in vue-cli my here |
This is unrelated to the use of private variables. If you look at the release notes you'll see that the exports have changed: https://github.com/mrdoob/three.js/wiki/Migration-Guide#131--132
|
Yeah current bundlers are not quite ready for private class properties yet. Newer version of bundler tools such as create-react-app 5.0 alpha are rolling out and they support private properties fine. |
For my full viewer bundle I could fix the problem by excluding three from beeing excluded from babel: |
|
People, could you test if the latest version is working fine? Are normal class properties supported at least? |
I'm afraid they are not, getting the same error on CRA:
|
🤦♂️ |
Ok not even those. We could transpile the whole Alternative is not using class properties for now. What do you think @mrdoob? |
That sounds very unappealing... Babel slows down the dev iteration process considerably. Probably the only solution is to define these variables in the constructors instead. Very disappointed with the bundlers ecosystem 😔 |
Okay! Thanks @Mugen87 for the PR! |
Indeed. When using new language features, checking the browser support isn't enough anymore. Would be great to have something like |
|
The exception here is probably esbuild (nice of them to give us our benchmark right on the homepage! 😅 ). $ echo 'class Foo { #bar = 0; }' | esbuild --loader=js --target=es2020 var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var _bar;
class Foo {
constructor() {
__privateAdd(this, _bar, 0);
}
}
_bar = new WeakMap(); |
Hmm, not sure... I'm worried switching to esbuild may come with its own set of complications 😶 I guess using pseudo private is not too bad for now. Maybe we could try using private class vars on the webgpu code though. |
@mrdoob additionally to the browser / bundler support, setting Some useful third-party libraries and helpers may depend on hacking around and accessing these props to work. (Tiny edit: the demo used both troika and vanruesc postprocessing, and it seems that it's actually troika material breaking and also I have no idea how to read errors - but the point stands about third-party libs overall 😅) |
@mjurczyk what npm version is being used in that error? |
|
This sounds like a misunderstanding. CRA automatically applies the env preset so this doesn’t quite make sense. Let’s chat about this in facebook/create-react-app#11339. |
if version is r128,it's working
when i update and just write
The text was updated successfully, but these errors were encountered: