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

Disable Annex B by default in @babel/parser #10986

nicolo-ribaudo opened this issue Jan 11, 2020 · 1 comment

Disable Annex B by default in @babel/parser #10986

nicolo-ribaudo opened this issue Jan 11, 2020 · 1 comment


Copy link

@nicolo-ribaudo nicolo-ribaudo commented Jan 11, 2020

Feature Request

From the Annex B introduction in the spec:

This annex describes various legacy features and other characteristics of web browser based ECMAScript implementations. All of the language features and behaviours specified in this annex have one or more undesirable characteristics and in the absence of legacy usage would be removed from this specification. However, the usage of these features by large numbers of existing web pages means that web browsers must continue to support them. The specifications in this annex define the requirements for interoperable implementations of these legacy features.

These features are not considered part of the core ECMAScript language. Programmers should not use or assume the existence of these features and behaviours when writing new ECMAScript code. ECMAScript implementations are discouraged from implementing these features unless the implementation is part of a web browser or is required to run the same legacy ECMAScript code that web browsers encounter.

Most of the Annex B features are only used by legacy code, which probably isn't using Babel. Modern code is discouraged from using them, and browsers can't remove them because of the "don't break the web" constraint.

Well, we can break things 😛

Supporting Annex B features by default means that, by default, we are not compliant with the non-Annex B parts of the spec. For example, this code should fail but Annex B makes it valid (source):

try {} catch (err) { for (var err of [2]) {} }

I propose to add a new parser plugin, annexb, and only parse those "features" when it is enabled.


This comment has been minimized.

Copy link

@JLHwung JLHwung commented Jan 11, 2020

Note that Annex B also includes grammar extension to regex. We may also need to propose annex B option to regjsparser, which is used in regexpu-core offering multiple regex features support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.