mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
In addition to the existing `exports` conditional exports we ship as part of APF v13, we want to expose the non-bundled ESM2020 output through the `esm2020` conditional name. Additionally we will expose the flat ES2020 files through the `es2020` conditional field, allowing consumers (like the CLI) to prioritize certain formats. e.g. consider the case with RXJS where it currently defaults to the ESM5 output. The CLI could now set `es2015` as the conditional to leverage the ES2015 output of RXJS. This unveils a problem though since this would also mean that `ES2015` output of the framework Angular packages would be used instead of the available ES2020 output. Here is the additional `es2020` conditional helpful as it allows the CLI to prioritize `es2020`, fallback to `es2015` and lastly fallback to `default`. if none do match for a certain package. PR Close #43740
25 lines
914 B
TypeScript
25 lines
914 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* Jasmine asymmetric matcher that compares a given object ensuring that it matches deep
|
|
* with the other while also respecting the order of keys. This is useful when comparing
|
|
* the NodeJS `package.json` `exports` field where order matters.
|
|
*/
|
|
export function matchesObjectWithOrder(expected: any): jasmine.AsymmetricMatcher<any> {
|
|
return {
|
|
asymmetricMatch(actual: any): boolean {
|
|
// Use JSON stringify to compare the object with respect to the order of keys
|
|
// in the object, and its nested objects.
|
|
return JSON.stringify(actual) === JSON.stringify(expected);
|
|
},
|
|
jasmineToString(prettyPrint: typeof jasmine.pp): string {
|
|
return prettyPrint(expected);
|
|
}
|
|
};
|
|
}
|