HomePhabricator

resourceloader: Allow modules to mark themselves as ES6-only

Tags
None
Referenced Files
None
Subscribers
None

Description

resourceloader: Allow modules to mark themselves as ES6-only

Modules that set "es6": true in their module definition will error when
a non-ES6 client tries to load them.

To detect ES6 support, this looks for native Promise support,
RegExp.prototype.flags, and non-BMP characters in variable names. All
browsers that lack full ES6 support fail at least one of those checks.

To flag modules as requiring ES6, this adds a ! to the end of their
version string. This takes up much less space than adding another
register() parameter (which would have to be at the end). It's hacky,
but we expect this feature to be relatively temporary, until we require
ES6 for running any JS at all (probably in about a year).

For distinguishing different types of errors thrown from
sortDependencies(), use e.name. We can't subclass Error properly because
that requires ES6.

Bug: T272104
Change-Id: I45670c910ff12eb422ae54c9fcf372e45c7b2bf1

Details

Provenance
CatropeAuthored on Jan 23 2021, 7:33 AM
Parents
rMWdeb624a6f8ac: Merge "DeprecatedGlobal: remove unneeded phpcs suppression"
Branches
Unknown
Tags
Unknown
ChangeId
I45670c910ff12eb422ae54c9fcf372e45c7b2bf1