From 5d79dfe8ca32cf4537c928996c512a5259d04a69 Mon Sep 17 00:00:00 2001 From: Trevor Burnham Date: Fri, 22 Aug 2025 22:54:23 -0400 Subject: [PATCH] perf: replace aws-sdk with @types/aws-sdk2-types This is a second attempt at fixing #417. The first attempt was #425, which moved `aws-sdk` from `dependencies` to `devDependencies`. That change was reverted by #535. The `aws-sdk` dependency is only being used for TypeScript types. Including it in `dependencies` rather than `devDependencies` ensures that those types are available to package consumers, at the expense of bringing in a 100MB+ dependency. The solution here is to replace the `aws-sdk` dependency with `@types/aws-sdk2-types`, which is a relatively lightweight 2.3MB. These types should be identical, as they were pulled directly from `aws-sdk`: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64111 I considered inlining the types with dts-bundle-generator, which would allow `@types/aws-sdk2-types` to be moved to `devDependencies`, but this turned out to be impractical with the current export structure, since the types would have to be inlined separately in each `.d.ts` file that uses them. I would recommend that solution if the package moves to having a single defined entrypoint in the future (perhaps in the next major version). --- package-lock.json | 129 +++++------------- runtimes/package.json | 2 +- runtimes/runtimes/base-runtime.ts | 4 +- runtimes/runtimes/standalone.ts | 4 +- .../util/standalone/experimentalProxyUtil.ts | 2 +- .../runtimes/util/standalone/proxyUtil.ts | 2 +- .../server-interface/sdk-initializator.ts | 4 +- runtimes/testing/TestFeatures.ts | 4 +- 8 files changed, 43 insertions(+), 108 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0336cfcd..547cc9a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1055,6 +1055,15 @@ "node": ">=18.0.0" } }, + "node_modules/@types/aws-sdk2-types": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@types/aws-sdk2-types/-/aws-sdk2-types-0.0.5.tgz", + "integrity": "sha512-FIOe05YZpdvafyZxlAmflV5jStj2TJoyFBtLJvXJnQauxQGFSVrazauVws1mlLRwS0GnITlFipNh0kHWdnUU1g==", + "license": "Apache-2.0", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/chai": { "version": "5.0.1", "dev": true, @@ -1288,6 +1297,7 @@ }, "node_modules/available-typed-arrays": { "version": "1.0.7", + "dev": true, "license": "MIT", "dependencies": { "possible-typed-array-names": "^1.0.0" @@ -1299,35 +1309,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/aws-sdk": { - "version": "2.1692.0", - "hasInstallScript": true, - "license": "Apache-2.0", - "dependencies": { - "buffer": "4.9.2", - "events": "1.1.1", - "ieee754": "1.1.13", - "jmespath": "0.16.0", - "querystring": "0.2.0", - "sax": "1.2.1", - "url": "0.10.3", - "util": "^0.12.4", - "uuid": "8.0.0", - "xml2js": "0.6.2" - }, - "engines": { - "node": ">= 10.0.0" - } - }, - "node_modules/aws-sdk/node_modules/uuid": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.0.0.tgz", - "integrity": "sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==", - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "dev": true, @@ -1449,27 +1430,15 @@ "license": "ISC", "peer": true }, - "node_modules/buffer": { - "version": "4.9.2", - "license": "MIT", - "dependencies": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4", - "isarray": "^1.0.0" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "dev": true, "license": "MIT", "peer": true }, - "node_modules/buffer/node_modules/isarray": { - "version": "1.0.0", - "license": "MIT" - }, "node_modules/call-bind": { "version": "1.0.7", + "dev": true, "license": "MIT", "dependencies": { "es-define-property": "^1.0.0", @@ -1860,6 +1829,7 @@ }, "node_modules/define-data-property": { "version": "1.1.4", + "dev": true, "license": "MIT", "dependencies": { "es-define-property": "^1.0.0", @@ -1962,6 +1932,7 @@ }, "node_modules/es-define-property": { "version": "1.0.0", + "dev": true, "license": "MIT", "dependencies": { "get-intrinsic": "^1.2.4" @@ -1972,6 +1943,7 @@ }, "node_modules/es-errors": { "version": "1.3.0", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -1997,13 +1969,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/events": { - "version": "1.1.1", - "license": "MIT", - "engines": { - "node": ">=0.4.x" - } - }, "node_modules/expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", @@ -2097,6 +2062,7 @@ }, "node_modules/for-each": { "version": "0.3.3", + "dev": true, "license": "MIT", "dependencies": { "is-callable": "^1.1.3" @@ -2128,6 +2094,7 @@ }, "node_modules/function-bind": { "version": "1.1.2", + "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2207,6 +2174,7 @@ }, "node_modules/get-intrinsic": { "version": "1.2.4", + "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", @@ -2294,6 +2262,7 @@ }, "node_modules/gopd": { "version": "1.1.0", + "dev": true, "license": "MIT", "dependencies": { "get-intrinsic": "^1.2.4" @@ -2315,6 +2284,7 @@ }, "node_modules/has-property-descriptors": { "version": "1.0.2", + "dev": true, "license": "MIT", "dependencies": { "es-define-property": "^1.0.0" @@ -2325,6 +2295,7 @@ }, "node_modules/has-proto": { "version": "1.1.0", + "dev": true, "license": "MIT", "dependencies": { "call-bind": "^1.0.7" @@ -2338,6 +2309,7 @@ }, "node_modules/has-symbols": { "version": "1.1.0", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -2348,6 +2320,7 @@ }, "node_modules/has-tostringtag": { "version": "1.0.2", + "dev": true, "license": "MIT", "dependencies": { "has-symbols": "^1.0.3" @@ -2367,6 +2340,7 @@ }, "node_modules/hasown": { "version": "2.0.2", + "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -2492,6 +2466,7 @@ }, "node_modules/is-arguments": { "version": "1.1.1", + "dev": true, "license": "MIT", "dependencies": { "call-bind": "^1.0.2", @@ -2525,6 +2500,7 @@ }, "node_modules/is-callable": { "version": "1.2.7", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -2568,6 +2544,7 @@ }, "node_modules/is-generator-function": { "version": "1.0.10", + "dev": true, "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" @@ -2653,6 +2630,7 @@ }, "node_modules/is-typed-array": { "version": "1.1.13", + "dev": true, "license": "MIT", "dependencies": { "which-typed-array": "^1.1.14" @@ -2696,13 +2674,6 @@ "jiti": "lib/jiti-cli.mjs" } }, - "node_modules/jmespath": { - "version": "0.16.0", - "license": "Apache-2.0", - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -3340,6 +3311,7 @@ }, "node_modules/possible-typed-array-names": { "version": "1.0.0", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -3475,16 +3447,6 @@ "once": "^1.3.1" } }, - "node_modules/punycode": { - "version": "1.3.2", - "license": "MIT" - }, - "node_modules/querystring": { - "version": "0.2.0", - "engines": { - "node": ">=0.4.x" - } - }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -3694,10 +3656,6 @@ ], "license": "MIT" }, - "node_modules/sax": { - "version": "1.2.1", - "license": "ISC" - }, "node_modules/semver": { "version": "7.7.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", @@ -3728,6 +3686,7 @@ }, "node_modules/set-function-length": { "version": "1.2.2", + "dev": true, "license": "MIT", "dependencies": { "define-data-property": "^1.1.4", @@ -4441,16 +4400,9 @@ "node": ">=8" } }, - "node_modules/url": { - "version": "0.10.3", - "license": "MIT", - "dependencies": { - "punycode": "1.3.2", - "querystring": "0.2.0" - } - }, "node_modules/util": { "version": "0.12.5", + "dev": true, "license": "MIT", "dependencies": { "inherits": "^2.0.3", @@ -4527,6 +4479,7 @@ }, "node_modules/which-typed-array": { "version": "1.1.16", + "dev": true, "license": "MIT", "dependencies": { "available-typed-arrays": "^1.0.7", @@ -4588,24 +4541,6 @@ "version": "1.0.2", "license": "ISC" }, - "node_modules/xml2js": { - "version": "0.6.2", - "license": "MIT", - "dependencies": { - "sax": ">=0.6.0", - "xmlbuilder": "~11.0.0" - }, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/xmlbuilder": { - "version": "11.0.1", - "license": "MIT", - "engines": { - "node": ">=4.0" - } - }, "node_modules/xtend": { "version": "4.0.2", "dev": true, @@ -4697,8 +4632,8 @@ "@opentelemetry/sdk-logs": "^0.200.0", "@opentelemetry/sdk-metrics": "^2.0.1", "@smithy/node-http-handler": "^4.0.4", + "@types/aws-sdk2-types": "^0.0.5", "ajv": "^8.17.1", - "aws-sdk": "^2.1692.0", "hpagent": "^1.2.0", "jose": "^5.9.6", "mac-ca": "^3.1.1", diff --git a/runtimes/package.json b/runtimes/package.json index 5d2263c0..1c875458 100644 --- a/runtimes/package.json +++ b/runtimes/package.json @@ -40,8 +40,8 @@ "@opentelemetry/sdk-logs": "^0.200.0", "@opentelemetry/sdk-metrics": "^2.0.1", "@smithy/node-http-handler": "^4.0.4", + "@types/aws-sdk2-types": "^0.0.5", "ajv": "^8.17.1", - "aws-sdk": "^2.1692.0", "hpagent": "^1.2.0", "jose": "^5.9.6", "mac-ca": "^3.1.1", diff --git a/runtimes/runtimes/base-runtime.ts b/runtimes/runtimes/base-runtime.ts index 96a5a3bb..aa1c3342 100644 --- a/runtimes/runtimes/base-runtime.ts +++ b/runtimes/runtimes/base-runtime.ts @@ -98,8 +98,8 @@ import { import { IdentityManagement } from '../server-interface/identity-management' import { WebBase64Encoding } from './encoding' import { LoggingServer } from './lsp/router/loggingServer' -import { Service } from 'aws-sdk' -import { ServiceConfigurationOptions } from 'aws-sdk/lib/service' +import { Service } from 'aws-sdk2-types' +import { ServiceConfigurationOptions } from 'aws-sdk2-types/lib/service' import { getClientInitializeParamsHandlerFactory } from './util/lspCacheUtil' import { newAgent } from './agent' import { ShowSaveFileDialogRequestType, CheckDiagnosticsRequestType } from '../protocol/window' diff --git a/runtimes/runtimes/standalone.ts b/runtimes/runtimes/standalone.ts index 54e8bb9f..c5e46d06 100644 --- a/runtimes/runtimes/standalone.ts +++ b/runtimes/runtimes/standalone.ts @@ -87,8 +87,8 @@ import { getServerDataDirPath } from './util/serverDataDirPath' import { ProxyConfigManager } from './util/standalone/experimentalProxyUtil' import { Encoding } from './encoding' import { LoggingServer } from './lsp/router/loggingServer' -import { Service } from 'aws-sdk' -import { ServiceConfigurationOptions } from 'aws-sdk/lib/service' +import { Service } from 'aws-sdk2-types' +import { ServiceConfigurationOptions } from 'aws-sdk2-types/lib/service' import { getTelemetryLspServer } from './util/telemetryLspServer' import { getClientInitializeParamsHandlerFactory } from './util/lspCacheUtil' import { makeProxyConfigv2Standalone, makeProxyConfigv3Standalone } from './util/standalone/proxyUtil' diff --git a/runtimes/runtimes/util/standalone/experimentalProxyUtil.ts b/runtimes/runtimes/util/standalone/experimentalProxyUtil.ts index 99e0d9ea..8aad380c 100644 --- a/runtimes/runtimes/util/standalone/experimentalProxyUtil.ts +++ b/runtimes/runtimes/util/standalone/experimentalProxyUtil.ts @@ -7,7 +7,7 @@ import { readFileSync } from 'node:fs' import * as tls from 'node:tls' import { Agent as HttpsAgent } from 'node:https' import { X509Certificate } from 'node:crypto' -import { ConfigurationOptions } from 'aws-sdk' +import { ConfigurationOptions } from 'aws-sdk2-types' import { HttpsProxyAgent } from 'hpagent' import { NodeHttpHandler } from '@smithy/node-http-handler' import { readMacosCertificates, readLinuxCertificates, readWindowsCertificates } from './certificatesReaders' diff --git a/runtimes/runtimes/util/standalone/proxyUtil.ts b/runtimes/runtimes/util/standalone/proxyUtil.ts index 8b4967cf..cdd7fc4d 100644 --- a/runtimes/runtimes/util/standalone/proxyUtil.ts +++ b/runtimes/runtimes/util/standalone/proxyUtil.ts @@ -1,6 +1,6 @@ import { Workspace } from '../../../server-interface' -import { ConfigurationOptions } from 'aws-sdk' +import { ConfigurationOptions } from 'aws-sdk2-types' import { HttpsProxyAgent } from 'hpagent' import { NodeHttpHandler } from '@smithy/node-http-handler' diff --git a/runtimes/server-interface/sdk-initializator.ts b/runtimes/server-interface/sdk-initializator.ts index 264a3818..f0291dd3 100644 --- a/runtimes/server-interface/sdk-initializator.ts +++ b/runtimes/server-interface/sdk-initializator.ts @@ -1,5 +1,5 @@ -import { Service } from 'aws-sdk' -import { ServiceConfigurationOptions } from 'aws-sdk/lib/service' +import { Service } from 'aws-sdk2-types' +import { ServiceConfigurationOptions } from 'aws-sdk2-types/lib/service' // aws sdk v2 clients constructor type export type SDKClientConstructorV2 = new (config?: P) => T diff --git a/runtimes/testing/TestFeatures.ts b/runtimes/testing/TestFeatures.ts index 9fa7142b..19919e98 100644 --- a/runtimes/testing/TestFeatures.ts +++ b/runtimes/testing/TestFeatures.ts @@ -30,8 +30,8 @@ import { InitializeParams, } from '../protocol' import { IdentityManagement } from '../server-interface/identity-management' -import { Service } from 'aws-sdk' -import { ServiceConfigurationOptions } from 'aws-sdk/lib/service' +import { Service } from 'aws-sdk2-types' +import { ServiceConfigurationOptions } from 'aws-sdk2-types/lib/service' /** * A test helper package to test Server implementations. Accepts a single callback