44 */
55
66import { FlushMode } from "@fluidframework/runtime-definitions/internal" ;
7- // The semver package documents and encourages these imports for users that only need some of the semver functionality.
8- // eslint-disable-next-line import/no-internal-modules
9- import semverGte from "semver/functions/gte.js" ;
10- // eslint-disable-next-line import/no-internal-modules
11- import semverLte from "semver/functions/lte.js" ;
12- // eslint-disable-next-line import/no-internal-modules
13- import semverValid from "semver/functions/valid.js" ;
7+ import { compare , gte , lte , valid } from "semver-ts" ;
148
159import {
1610 disabledCompressionConfig ,
@@ -181,12 +175,12 @@ export function getConfigsForCompatMode<T extends Record<SemanticVersion, unknow
181175 for ( const key of Object . keys ( configMap ) ) {
182176 const config = configMap [ key as keyof T ] ;
183177 // Sort the versions in ascending order so we can short circuit the loop.
184- const versions = Object . keys ( config ) . sort ( ( a , b ) => ( semverGte ( b , a ) ? - 1 : 1 ) ) ;
178+ const versions = Object . keys ( config ) . sort ( compare ) ;
185179 // For each config, we iterate over the keys and check if compatibilityVersion is greater than or equal to the version.
186180 // If so, we set it as the default value for the option. At the end of the loop we should have the most recent default
187181 // value that is compatible with the version specified as the compatibilityVersion.
188182 for ( const version of versions ) {
189- if ( semverGte ( compatibilityVersion , version ) ) {
183+ if ( gte ( compatibilityVersion , version ) ) {
190184 defaultConfigs [ key ] = config [ version as MinimumMinorSemanticVersion ] ;
191185 } else {
192186 // If the compatibility mode is less than the version, we break out of the loop since we don't need to check
@@ -205,7 +199,7 @@ export function getConfigsForCompatMode<T extends Record<SemanticVersion, unknow
205199export function isValidCompatVersion ( compatibilityVersion : SemanticVersion ) : boolean {
206200 return (
207201 compatibilityVersion !== undefined &&
208- semverValid ( compatibilityVersion ) !== null &&
209- semverLte ( compatibilityVersion , pkgVersion )
202+ valid ( compatibilityVersion ) !== null &&
203+ lte ( compatibilityVersion , pkgVersion )
210204 ) ;
211205}
0 commit comments