aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

[feature request] Share VERSION of the package in client

Open trivikr opened this issue 5 years ago • 6 comments
trafficstars

Is your feature request related to a problem? Please describe.

  • In v2, the version of the package can be viewed by printing VERSION as follows:
const AWS = require("aws-sdk");
console.log(AWS.VERSION);
  • As v3 is modular, there's no equivalent global package as per design, and the client package doesn't have key storing it's version number

Describe the solution you'd like

  • The client object prints it's version in VERSION as follows:
const { S3 } = require("@aws-sdk/client-s3");
console.log(S3.VERSION);
  • This applies to the barebones client too:
const { S3Client } = require("@aws-sdk/client-s3");
console.log(S3Client.VERSION);

Describe alternatives you've considered Running npm list <PACKAGE_NAME> to get the version number in the minimal repro repository as follows:

$ npm list @aws-sdk/client-s3
└─ @aws-sdk/[email protected]

trivikr avatar Jan 27 '20 19:01 trivikr

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

github-actions[bot] avatar Jan 27 '21 00:01 github-actions[bot]

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

github-actions[bot] avatar Jan 29 '22 00:01 github-actions[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

github-actions[bot] avatar Feb 17 '22 00:02 github-actions[bot]

Alternatives is requesting importing package.json directly.

CJS

const { version } = require("@aws-sdk/client-s3/package.json");
console.log(version);

trivikr avatar Nov 10 '23 19:11 trivikr

MJS has two options

Use createRequire to require package.json

import { createRequire } from "module"
const require = createRequire(import.meta.url)
const { version } = require("@aws-sdk/client-s3/package.json");

console.log(version);

Default import using import assertions

import packageJson from "@aws-sdk/client-s3/package.json" assert { type: "json" };

console.log(packageJson.version);

trivikr avatar Nov 16 '23 15:11 trivikr

Verified that:

  • createRequire was added in v12.x: https://nodejs.org/docs/latest-v12.x/api/module.html#module_module_createrequire_filename
  • import.meta.url is present in v14.x: https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_import_meta_url

trivikr avatar Nov 22 '23 20:11 trivikr

For anyone who comes across this, Lambda team recommended to import version from @aws-sdk/client-s3/package.json as mentioned in this docs.

const { version } = require("@aws-sdk/client-s3/package.json");

exports.handler = async () => ({ version });

Closing the issue.

aBurmeseDev avatar Jun 20 '24 00:06 aBurmeseDev

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

github-actions[bot] avatar Jul 05 '24 00:07 github-actions[bot]