Skip to content

Conversation

@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Dec 12, 2020

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Main PR: #12219
RFC: babel/rfcs#5

I also introduced a warning when both loose and setPublicClassFields/privateFieldsAsProperties are set (while still maintianing the fallback behavior we have for the other assumptions).
This is because loose support for these class features plugins is a mess and easily breaks: it was what initially lead me to the assumptions RFC. We should encourage users to fully migrate to assumptions for these plugins when they start using them, to avoid other possible configuration conflicts caused by the implicit dependencies between them.

The tests are what we already had for loose.

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 12, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/37890/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 12, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2fce14d:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

// TODO(Babel 8): Remove the default falue
api = { assumption: () => {} },
}) {
const setPublicClassFields = api.assumption("setPublicClassFields");
Copy link
Contributor

@JLHwung JLHwung Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw on @babel/core 7.12 + @babel/plugin-class-properties 7.13 because api is defined but api.assumption is not provided.
Never mind, I always forget the fact that api.assumption has been provided by helper plugin utils.

JLHwung
JLHwung previously approved these changes Dec 14, 2020
@JLHwung JLHwung dismissed their stale review December 14, 2020 16:27

CI error is related.

@nicolo-ribaudo
Copy link
Member Author

The CI failure caught an assumption I didn't notice while writing the RFC.

The super binding of a class instance is mutable:

class B {
  method() { alert("B!"); }
}

class C {
  method() { alert("C!"); }
}

class A extends B {
  run() { super.method(); }
}

Object.setPrototypeOf(A.prototype, C.prototype);

new A().run();

For this reason, we compile super.method to _get(_getPrototypeOf(A.prototype), "method", this).

However, in loose mode we assume that it's never mutated and thus we compile it to _B.prototype.method.

I'm going to add this to the RFC.

path,
privateNamesMap,
loose,
privateFieldsAsProperties,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider change the signature to { privateFieldsAsProperties: boolean } so we can pass noDocumentAll later. This function is not a public interface so it should be okay.

@nicolo-ribaudo nicolo-ribaudo force-pushed the assumption/class-features branch from 1864522 to 98ad298 Compare December 14, 2020 23:25
@nicolo-ribaudo nicolo-ribaudo requested a review from hzoo January 12, 2021 15:28
@nicolo-ribaudo nicolo-ribaudo force-pushed the assumption/class-features branch 2 times, most recently from dac1080 to 63e45fe Compare January 12, 2021 16:33
@nicolo-ribaudo nicolo-ribaudo force-pushed the feat-7.13.0/babel-core-features branch from 63c7a5a to caa4fda Compare January 12, 2021 16:35
@nicolo-ribaudo nicolo-ribaudo force-pushed the assumption/class-features branch from 63e45fe to 2fce14d Compare January 19, 2021 14:55
@nicolo-ribaudo nicolo-ribaudo merged commit b634b01 into babel:feat-7.13.0/babel-core-features Jan 23, 2021
@nicolo-ribaudo nicolo-ribaudo deleted the assumption/class-features branch January 23, 2021 02:41
nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Feb 4, 2021
nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Feb 10, 2021
nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Feb 11, 2021
nicolo-ribaudo added a commit that referenced this pull request Feb 16, 2021
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408)
- `setClassMethods` (#12407)
- `setComputedProperties` (#12490)
- `ignoreFunctionLength` (#12491)
- `noDocumentAll` (#12481)
- `iterableIsArray` and `arrayLikeIsIterable` (#12489)
- `pureGetters` (#12504)
- `skipForOfIteratorClosing` (#12496)
- `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505)
- `noNewArrows` (#12613, #12793)
- `setPublicClassFields` and `privateFieldsAsProperties` (#12497)
- `constantReexports` and `enumerableModuleMeta` (#12618)
- `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726)

Co-authored-by: Justin Ridgewell <[email protected]>
Co-authored-by: Huáng Jùnliàng <[email protected]>
nicolo-ribaudo added a commit that referenced this pull request Feb 16, 2021
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408)
- `setClassMethods` (#12407)
- `setComputedProperties` (#12490)
- `ignoreFunctionLength` (#12491)
- `noDocumentAll` (#12481)
- `iterableIsArray` and `arrayLikeIsIterable` (#12489)
- `pureGetters` (#12504)
- `skipForOfIteratorClosing` (#12496)
- `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505)
- `noNewArrows` (#12613, #12793)
- `setPublicClassFields` and `privateFieldsAsProperties` (#12497)
- `constantReexports` and `enumerableModuleMeta` (#12618)
- `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726)

Co-authored-by: Justin Ridgewell <[email protected]>
Co-authored-by: Huáng Jùnliàng <[email protected]>
nicolo-ribaudo added a commit that referenced this pull request Feb 21, 2021
- `mutableTemplateObject` and `ignoreToPrimitiveHint` (#12408)
- `setClassMethods` (#12407)
- `setComputedProperties` (#12490)
- `ignoreFunctionLength` (#12491)
- `noDocumentAll` (#12481)
- `iterableIsArray` and `arrayLikeIsIterable` (#12489)
- `pureGetters` (#12504)
- `skipForOfIteratorClosing` (#12496)
- `objectRestNoSymbols`, `setSpreadProperties` and `pureGetters` (#12505)
- `noNewArrows` (#12613, #12793)
- `setPublicClassFields` and `privateFieldsAsProperties` (#12497)
- `constantReexports` and `enumerableModuleMeta` (#12618)
- `constantSuper`, `superIsCallableConstructor` and `noClassCalls` (#12726)

Co-authored-by: Justin Ridgewell <[email protected]>
Co-authored-by: Huáng Jùnliàng <[email protected]>
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: assumptions outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories Spec: Brand Check for Private Fields Spec: Class Fields Spec: Private Methods

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants