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
V2: Scope Hoisting Static Class Property not Working #3664
Comments
@devongovett Should we remove our own mangler and just leave this to terser? |
@mischnic I ran it on one of my projects on a Mac Book Pro (13-inch, 2017, 2,3 GHz Dual-Core Intel Core i5, 6 GB 2133 MHz LPDDR) using cc75395 . With mangleScope (cold cache) Without mangleScope (cold cache) With mangleScope (hot cache) Without mangleScope (hot cache) Does this help? |
Is this the output file after terser? The size should stay the same... |
It is. I run the same command but removed the line of code as described. |
@mischnic Just ran the version without mangling again and checked the dist file, it contains a lot of variables like Do I need to activate this somewhere else? |
I took this afternoon trying to isolate this problem and understand what was happening with parcel. Was going to open a new issue, but then I found this one. Just made a small gist with the reproduction of this bug (based on what I currently have in one of my projects), I hope it helps somehow: https://gist.github.com/flisboac/c9c6c7f475f34bb2b9b5995a0c3e1ecf |
@flisboac thanks for the investigation! As far as I understand this was a bug in Babel which should be solved, but we are waiting for the next release, v7.8.4. |
@garthenweb I'm happy we already have a fix en route, this is great! Thank you! :) |
Babel 7.8.4 was just released. |
@mischnic I will try to check it out at the weekend! |
@mischnic npm ls @babel/traverse
parcel2-bug@1.0.0 /home/alan/dev/regiontog/parcel2-bug
└─┬ parcel@2.0.0-alpha.3.2
└─┬ @parcel/config-default@2.0.0-alpha.3.1
├─┬ @parcel/packager-js@2.0.0-alpha.3.1
│ └─┬ @parcel/scope-hoisting@2.0.0-alpha.3.1
│ └── @babel/traverse@7.7.4 deduped
├─┬ @parcel/transformer-babel@2.0.0-alpha.3.1
│ ├─┬ @babel/core@7.7.5
│ │ ├─┬ @babel/helpers@7.7.4
│ │ │ └── @babel/traverse@7.7.4 deduped
│ │ └── @babel/traverse@7.7.4 deduped
│ ├─┬ @babel/plugin-transform-typescript@7.7.4
│ │ └─┬ @babel/helper-create-class-features-plugin@7.7.4
│ │ └─┬ @babel/helper-replace-supers@7.7.4
│ │ └── @babel/traverse@7.7.4 deduped
│ ├─┬ @babel/preset-env@7.7.6
│ │ ├─┬ @babel/plugin-proposal-async-generator-functions@7.7.4
│ │ │ └─┬ @babel/helper-remap-async-to-generator@7.7.4
│ │ │ ├─┬ @babel/helper-wrap-function@7.7.4
│ │ │ │ └── @babel/traverse@7.7.4 deduped
│ │ │ └── @babel/traverse@7.7.4 deduped
│ │ ├─┬ @babel/plugin-transform-exponentiation-operator@7.7.4
│ │ │ └─┬ @babel/helper-builder-binary-assignment-operator-visitor@7.7.4
│ │ │ └─┬ @babel/helper-explode-assignable-expression@7.7.4
│ │ │ └── @babel/traverse@7.7.4 deduped
│ │ └─┬ @babel/plugin-transform-parameters@7.7.4
│ │ └─┬ @babel/helper-call-delegate@7.7.4
│ │ └── @babel/traverse@7.7.4 deduped
│ └── @babel/traverse@7.7.4
└─┬ @parcel/transformer-js@2.0.0-alpha.3.1
└── @babel/traverse@7.7.4 deduped |
Checked it now as well. |
Ah, it's the lockfile in my project that causes my version to stay at 7.7.4! npm pulls in the newest version and sets the lockfile after |
I have same issue with 1.12.4, with a static member being used inside a static method. Any way to fix it for 1.12.4? |
Maybe updating babel (delete lockfile?) |
Actually in my case I solved it by refactoring my code (simplified): With problem:
Without problem:
To be noted that with |
Due to a bug in parcel, static functions and properties don't work properly when it is enabled. See: parcel-bundler/parcel#3664
Seems like this is probably fixed. |
🐛 bug report
When using a static class property within the class itself or outside/ in another file, the reference to its class is not renamed properly.
🎛 Configuration (.babelrc, package.json, cli command)
.babelrc
package.json
🤔 Expected Behavior
Should rename static properties within classes properly.
😯 Current Behavior
Does not rename static property which results in
Uncaught ReferenceError: $c4ee6a119cd77881a886bf5cd2629a0$var$A is not defined
at runtime.💻 Code Sample
index.js
dist/index.js
🌍 Your Environment
The text was updated successfully, but these errors were encountered: