-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: Strip Symbol from production builds #6389
Conversation
These occurences of Symbol might be replaced by this `symbol`, similar but different in the sense it is iterable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in the description, this doesn't change the Symbol
usage for IS_IDENTIFIER
on identifiers. I believe for that particular usage we do not want an enumerable symbol as we want to ensure ease of use and ease of serializability when handing them out to users (these other locations don't have this same constraint).
For IS_IDENTIFIER
I suspect a weak-map lookup is what we want as more than likely that will be less expensive than defining a non-enumerable property, although I'm not 100% sure on this. cc @krisselden and @rwjblue for their thoughts on that.
Ya, I agree. I'd go with a |
I’ll update symbol implementation with WeakMap very soon (incl. for identifiers related Symbols). |
I've digged a bit and couldn't figure out how the |
@dcyriller in general, the idea would be that instead of:
data/packages/store/addon/-private/identifiers/cache.ts Lines 418 to 423 in f472f27
You would do something akin to: const IDENTIFIERS = new WeakMap();
export function isStableIdentifier(identifier) {
return IDENTIFIERS.has(identifier);
}
export function markStableIdentifier(identifier) {
IDENTIFIERS.set(identifier);
} |
* Add a Symbol-like symbol (thank you glimmer-vm) This is similar to what is implemented here: https://github.com/glimmerjs/glimmer-vm/blob/72718d0d6ebb2614ec984f51435a44830d410e4c/packages/%40glimmer/reference/lib/validators.ts * Replace `Symbol`s that may be iterable by `symbol`s These occurences of Symbol might be replaced by this `symbol`, similar but different in the sense it is iterable.
* Add a Symbol-like symbol (thank you glimmer-vm) This is similar to what is implemented here: https://github.com/glimmerjs/glimmer-vm/blob/72718d0d6ebb2614ec984f51435a44830d410e4c/packages/%40glimmer/reference/lib/validators.ts * Replace `Symbol`s that may be iterable by `symbol`s These occurences of Symbol might be replaced by this `symbol`, similar but different in the sense it is iterable.
To ensure compatibility with IE11.
This should close #6380.
This implementation is taken from glimmer-vm. It is enumerable (as opposed to Symbol which is non-enumerable). But making it non-enumerable would come with a cost. And it will only be required for
identifiers
-related Symbols.These remaining Symbols are still unpublished or behind a feature flag (not sure but they are not part of the build outputs). They are not included in this PR. As they'll require a more sophisticated approach to be specifically non-enumerable. As we said, I'll leave it to you @runspired.