refactor(localize): update version of Babel (#44931)

The `@angular/localize` package depends on a version of Babel that is two years
old, so this commit updates to the latest version.

Some changes were made to the linker and compliance tests to account for slight
changes in source maps, along with a few code updates because of changes to
the typings of Babel.

PR Close #44931
This commit is contained in:
JoostK
2022-02-01 22:12:44 +01:00
committed by Jessica Janiuk
parent 8d634ac84d
commit 7bbddb5873
21 changed files with 518 additions and 332 deletions
@@ -6,8 +6,8 @@ $localize` pre-p ${ // SOURCE: "/i18n_message_element_whitespace.ts" "\\n pre-p
…
"\uFFFD/#2\uFFFD" // SOURCE: "/i18n_message_element_whitespace.ts" "</p>"
…
}:CLOSE_PARAGRAPH: post-p\n` // SOURCE: "/i18n_message_element_whitespace.ts" "\\n post-p\\n"
…
}:CLOSE_PARAGRAPH: post-p\n // SOURCE: "/i18n_message_element_whitespace.ts" "\\n post-p\\n"
`…
.ɵɵelementStart(0, "div") // SOURCE: "/i18n_message_element_whitespace.ts" "<div i18n>"
…
@@ -2,7 +2,7 @@
…
// TODO - map the bindings better
// TODO: Work out how to fix the broken segment for the last item in a template
.ɵɵelementEnd();\n // SOURCE: "/ng_if_templated.ts" "</div>\n "
.ɵɵelementEnd();\n // SOURCE: "/ng_if_templated.ts" "</div>\n"
…
// TODO: the `ctx_r...` appears to be dependent upon previous tests!!!
// TODO: expectMapping(mappings, { source: '{{ name }}', generated: 'i0.ɵɵtextInterpolate(ctx_r0.name)', sourceUrl: '../ng_if_templated.ts'});
@@ -2,7 +2,7 @@
…
.ɵɵprojection(1) // SOURCE: "/projection.ts" "<ng-content select="title"></ng-content>"
…
.ɵɵelementEnd() // SOURCE: "/projection.ts" "</h3>\n "
.ɵɵelementEnd() // SOURCE: "/projection.ts" "</h3>\n"
…
.ɵɵelementStart(2, "div") // SOURCE: "/projection.ts" "<div>"
…
@@ -13,7 +13,7 @@ const COMMENT_END = /\*\//;
const OPERATOR =
/!|\?|%|\*|\/|\^|&&?|\|\|?|\(|\)|\{|\}|\[|\]|:|;|<=?|>=?|={1,3}|!==?|=>|\+\+?|--?|@|,|\.|\.\.\.|\\`|\\'/;
const STRING = /'(\\'|[^'])*'|"(\\"|[^"])*"/;
const INLINE_BACKTICK_STRING = /`(([\s\S]*?)(\$\{[^}]*?\})?)*?[^\\]`/;
const INLINE_BACKTICK_STRING = /`(?:[\s\S]|(?:\$\{[^}]*?\}))*?[^\\]`/;
const SINGLE_BACKTICK_STRING = new RegExp('^' + INLINE_BACKTICK_STRING.source);
const BACKTICK_INTERPOLATION = /(\$\{[^}]*\})/;
const NUMBER = /\d+/;
@@ -80,8 +80,11 @@ function extractMappings(
fs: ReadonlyFileSystem, expected: string): {expected: string, mappings: SegmentMapping[]} {
const mappings: SegmentMapping[] = [];
// capture and remove source mapping info
// Any newline at the end of an expectation line is removed, as a mapping expectation for a
// segment within a template literal would otherwise force a newline to be matched in the template
// literal.
expected = expected.replace(
/^(.*?) \/\/ SOURCE: "([^"]*?)" "(.*?)"$/gm,
/^(.*?) \/\/ SOURCE: "([^"]*?)" "(.*?)"(?:\n|$)/gm,
(_, rawGenerated: string, rawSourceUrl: string, rawSource: string) => {
// Since segments need to appear on a single line in the expected file, any newlines in the
// segment being checked must be escaped in the expected file and then unescaped here before