Open brianmhunt opened 3 years ago
Noting: https://mathiasbynens.be/notes/javascript-identifiers-es6
In ES2015, identifiers must start with $, _, or any symbol with the Unicode derived core property ID_Start.
The rest of the identifier can contain $, _, U+200C zero width non-joiner, U+200D zero width joiner, or any symbol with the Unicode derived core property ID_Continue.
Noting: https://github.com/tc39/proposal-regexp-unicode-property-escapes#other-examples
const regexIdentifierStart = /[$_\p{ID_Start}]/u;
const regexIdentifierPart = /[$_\u200C\u200D\p{ID_Continue}]/u;
const regexIdentifierName = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u;
I have not worked with unicode ranges before, but shouldn't the regex be able to be generated runtime (maybe as a fallback)? The website used to generate the regex clearly does it runtime. The regex generation may be slow, but I think it's better as a fallback than nothing. Am I missing something?
This may become our min browser: Chrome 50
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicode
We can then get rid of the following 10kb:
https://github.com/knockout/tko/blob/4a0c9c0d03bb2ed53aa058672b5429d88bf92264/packages/utils.parser/src/identifierExpressions.js